feat(claude_agent_sdk): Instrument hooks#141
Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits intomainfrom Mar 25, 2026
Merged
feat(claude_agent_sdk): Instrument hooks#141Abhijeet Prasad (AbhiPrasad) merged 2 commits intomainfrom
Abhijeet Prasad (AbhiPrasad) merged 2 commits intomainfrom
Conversation
Instrument Claude Agent SDK hook callbacks through the Braintrust integration. This changes the request-scoped tracing flow so hook callbacks running on the SDK control channel are captured alongside the existing Claude Agent task, LLM, and tool spans. The integration now starts request tracing at query time, wraps registered hook callbacks, records hook inputs and outputs as FUNCTION spans, and preserves correct parentage for tool lifecycle hooks and Stop hooks. Users now get end-to-end visibility into Claude Agent SDK hooks, including UserPromptSubmit, PreToolUse, PostToolUse, and Stop callbacks. Hook spans attach to the matching tool span when possible, otherwise to the active LLM or task context, and UserPromptSubmit traces keep the original prompt attached to the request and LLM input. Tests were updated with cassette-backed coverage for UserPromptSubmit hook tracing, tool hook tracing, hook parent/child relationships, and prompt attachment with UserPromptSubmit enabled. The Claude Agent SDK integration test suite passes against both the latest supported SDK and 0.1.10 replay environments.
1aa555d to
45c5170
Compare
Cedric / ViaDézo1er (viadezo1er)
approved these changes
Mar 25, 2026
Contributor
Cedric / ViaDézo1er (viadezo1er)
left a comment
There was a problem hiding this comment.
good to merge
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.
resolves #67
Add support for instrumenting hooks for the claude agent sdk (https://platform.claude.com/docs/en/agent-sdk/hooks).