Prototype Claude Agent SDK instrumentation port from OpenInference (WIP)#1
Closed
eternalcuriouslearner wants to merge 4 commits into
Closed
Prototype Claude Agent SDK instrumentation port from OpenInference (WIP)#1eternalcuriouslearner wants to merge 4 commits into
eternalcuriouslearner wants to merge 4 commits into
Conversation
Feasibility prototype for porting openinference-instrumentation-claude-agent-sdk (open-telemetry#141) onto opentelemetry-util-genai: query()/ClaudeSDKClient wrappers emitting invoke_agent, execute_tool, and subagent spans. Tests, conformance scenarios, and workspace wiring not yet migrated. Assisted-by: Claude Fable 5 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLfGqEqWqFafZ9e8a7AWdQ
Drop tool and subagent span tracking (and with it all hook injection and options mutation): query() and each ClaudeSDKClient.receive_response() turn now emit a single invoke_agent span with input/output messages, token usage, model, and session id. execute_tool and subagent invoke_agent spans are deferred to a follow-up. Assisted-by: Claude Fable 5 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLfGqEqWqFafZ9e8a7AWdQ
Three scenarios (plain run, tool-calling content, reasoning content via ClaudeSDKClient) validated with weaver live-check, replaying real CLI sessions recorded in the donation-openinference repository through the SDK's public Transport interface (the SDK talks to a CLI subprocess, not HTTP, so no VCR). Wires the py314 conformance tox env and fixes the dependency-floor assertion for the claude-agent-sdk >= 0.1.45 bump. Assisted-by: Claude Fable 5 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLfGqEqWqFafZ9e8a7AWdQ
Derive the full agent hierarchy from the SDK's streamed messages, in the consumer task: tool_use/tool_result blocks become execute_tool spans (arguments/results gated on content capture, tool failures and abandoned tools recorded as errors) and subagent traffic keyed by parent_tool_use_id becomes nested invoke_agent spans named from the spawning tool's subagent_type. Parenting relies on util-genai's context stack mirroring the stream's nesting; parallel tool calls in one turn can mis-parent siblings (documented; explicit parenting in util-genai would lift this). Coexists with the Claude Code CLI's native beta claude_code.* traces: the SDK propagates trace context into the CLI subprocess, so native spans join the same trace under the invoke_agent span; documented in the README. Adds cassette-based integration tests, fake-stream error-path unit tests, model-extraction regression tests, and a multi_agent conformance scenario replaying the recorded subagent session. Assisted-by: Claude Fable 5 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLfGqEqWqFafZ9e8a7AWdQ
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.
Feasibility prototype for porting openinference-instrumentation-claude-agent-sdk
(open-telemetry#141) onto opentelemetry-util-genai:
query()/ClaudeSDKClient wrappers emitting invoke_agent, execute_tool, and
subagent spans. Tests, conformance scenarios, and workspace wiring not yet
migrated.
Assisted-by: Claude Fable 5
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01WLfGqEqWqFafZ9e8a7AWdQ