feat(output): emit permission_denied event on JSONL stream#219
Merged
emal-avala merged 1 commit intomainfrom Apr 23, 2026
Merged
feat(output): emit permission_denied event on JSONL stream#219emal-avala merged 1 commit intomainfrom
emal-avala merged 1 commit intomainfrom
Conversation
Automation consuming the JSONL stream had to grep tool_result.output
for the literal string "Permission denied: " to tell a policy-blocked
tool call apart from a genuine tool error (file not found, timeout,
etc.). That coupling silently breaks when the executor's error text
changes — and it offered no way to distinguish the two user-facing
deny paths at all.
Adds Event::PermissionDenied { tool, reason, turn } emitted alongside
the existing ToolResult envelope. Detection pins the two exact shapes
emitted by tools/executor.rs:
- Policy-driven Deny: "Permission denied: {reason}" — reason is the
executor's explanation (e.g. "path outside cwd")
- Interactive user Deny: "Permission denied by user" — synthesizes a
stable reason string "user denied at prompt" so consumers don't
have to handle missing fields
Both shapes are covered by pinning tests so a future change to
executor.rs will fail the build here instead of silently stopping the
PermissionDenied emission. Empty-reason values are rejected so we
don't emit meaningless events, and non-error tool results are ignored
even if their body coincidentally contains the prefix.
5 new tests plus an extension of all_events_are_single_line_json that
covers a multiline reason (proving serde still escapes newlines).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automation consuming the JSONL stream had to grep `tool_result.output` for the literal string `"Permission denied: "` to tell a policy-blocked tool call apart from a genuine tool error (file not found, timeout, etc.). That coupling silently breaks when the executor's error text changes — and it offered no way to distinguish the two user-facing deny paths at all.
Adds `Event::PermissionDenied { tool, reason, turn }` emitted alongside the existing `ToolResult` envelope. Detection pins the two exact shapes emitted by `tools/executor.rs`:
Both shapes are covered by pinning tests so a future change to `executor.rs` will fail the build here instead of silently stopping the `PermissionDenied` emission.
The existing `ToolResult` is still emitted, so consumers that don't know about the new event keep working.
Test plan