Repository navigation
Trace Claude tool permission refusals as denied #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Stephen Belanger (Qard)
wants to merge
5
commits into
main
Choose a base branch
from
fix/claude-permission-refusals
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+316
−82
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2a354e4
Trace native Claude permission refusals as denied
Qard 416e4de
Serialize legacy journal migration during capture and recovery
Qard 1a47346
Keep Pi tracing compatible with Oh My Pi 19.2
Qard 416948d
Share typed Claude transcript tool results
Qard 188b85b
Merge main into Claude permission refusal fix
Qard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,81 @@ | ||
| use serde::{Deserialize, Serialize}; | ||
| use super::native_field::deserialize_optional_string; | ||
| use crate::json::Field; | ||
| use serde::Deserialize; | ||
| use serde_json::Value; | ||
|
|
||
| /// Stable routing fields from one Claude transcript row. Message and tool | ||
| /// blocks intentionally remain raw because they are preserved in span I/O. | ||
| #[derive(Deserialize, Serialize)] | ||
| /// Stable routing fields from one Claude transcript row. | ||
| #[derive(Deserialize)] | ||
| pub(super) struct TranscriptEnvelope { | ||
| #[serde(rename = "type", default)] | ||
| pub(super) kind: Option<String>, | ||
| #[serde(default)] | ||
| pub(super) subtype: Option<String>, | ||
| #[serde(rename = "isCompactSummary", default)] | ||
| pub(super) is_compact_summary: bool, | ||
| message: Option<TranscriptMessage>, | ||
| // Claude stores tool-specific data here, such as a Bash or Agent result. | ||
| #[serde(rename = "toolUseResult")] | ||
| pub(super) tool_use_result: Option<Value>, | ||
| } | ||
|
|
||
| #[derive(Deserialize)] | ||
| struct TranscriptMessage { | ||
| content: Option<TranscriptContent>, | ||
| } | ||
|
|
||
| #[derive(Deserialize)] | ||
| #[serde(untagged)] | ||
| enum TranscriptContent { | ||
| Blocks(Vec<TranscriptBlock>), | ||
| Other(serde::de::IgnoredAny), | ||
| } | ||
|
|
||
| #[derive(Deserialize)] | ||
| struct TranscriptBlock { | ||
| #[serde(rename = "type")] | ||
| kind: Option<String>, | ||
| #[serde(flatten)] | ||
| result: TranscriptToolResult, | ||
| } | ||
|
|
||
| #[derive(Deserialize)] | ||
| pub(super) struct TranscriptToolResult { | ||
| #[serde(default, deserialize_with = "deserialize_optional_string")] | ||
| pub(super) tool_use_id: Option<String>, | ||
| // The tool determines the shape of its result. | ||
| #[serde(default)] | ||
| content: Field<Value>, | ||
| is_error: Option<bool>, | ||
| #[serde(rename = "isError")] | ||
| camel_case_is_error: Option<bool>, | ||
| } | ||
|
|
||
| impl TranscriptEnvelope { | ||
| pub(super) fn tool_results(&self) -> impl Iterator<Item = &TranscriptToolResult> { | ||
| let blocks = match self | ||
| .message | ||
| .as_ref() | ||
| .and_then(|message| message.content.as_ref()) | ||
| { | ||
| Some(TranscriptContent::Blocks(blocks)) => blocks.as_slice(), | ||
| _ => &[], | ||
| }; | ||
| blocks.iter().filter_map(|block| { | ||
| (block.kind.as_deref() == Some("tool_result")).then_some(&block.result) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl TranscriptToolResult { | ||
| pub(super) fn content(&self) -> Option<&Value> { | ||
| match &self.content { | ||
| Field::Missing => None, | ||
| Field::Null => Some(&Value::Null), | ||
| Field::Value(value) => Some(value), | ||
| } | ||
| } | ||
|
|
||
| pub(super) fn signals_error(&self) -> bool { | ||
| self.is_error == Some(true) || self.camel_case_is_error == Some(true) | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new failure-hook classification reads the known hook envelope with
event.payload.get("error"), and the new output fallback infinish_toolrepeats that traversal. RootAGENTS.mdexplicitly prohibits traversing known envelope fields asserde_json::Valueand requires decoding them at the input boundary. Model the optional error field in a shared typed hook payload and use it for both denial classification and reason preservation; the error content can retain flexibility where necessary for arbitrary tool results.AGENTS.md reference: AGENTS.md:L42-L48
Useful? React with 👍 / 👎.