Skip to content

fix(anthropic): log requested speed metadata - #986

Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi/anthropic-speed-metadata-d8651289
Oct 20, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi/anthropic-speed-metadata-d8651289

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Include the requested Anthropic speed parameter in span metadata.
  • Assert the request metadata in the existing cassette-backed test.

Closes #972

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T19:16:35.688294Z 56dfa50 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Abhijeet Prasad (AbhiPrasad) added a commit that referenced this pull request Oct 20, 2026
…PyPI (#987)

claude-agent-sdk 0.1.9–0.1.17 were deleted from PyPI, so
`test_claude_agent_sdk(0.1.10)` can no longer install and fails every
`nox` shard (seen on #986; `main` breaks the same way on its next run).
The `exclude-newer` cutoff in the logs is not the cause.

**Matrix**
- Swap the old-version entry from 0.1.10 to 0.1.18, the oldest
installable release. Re-recorded `cassettes/0.1.18/` and removed
`cassettes/0.1.10/`.
- `min_version` stays `0.1.10`; comments explain why the tested floor is
higher.
- 0.1.18 still needs the mcp 1.x constraint (`Server.list_tools()`).

**Tracing fix (old CLIs)**
CLIs bundled before 2.1 (2.0.72 in SDK 0.1.18) call the subagent tool
`Task` and emit no `task_started` / `task_notification` messages, so
subagent runs produced no task spans. Both tool names are now
recognised. When a subagent message arrives with no task span yet, a
task span is synthesized from the tool call under its `Task`/`Agent`
tool span. It ends when the orchestrator gets that tool's result. In
every latest cassette `task_started` arrives before the subagent's
messages, so the fallback doesn't fire there.

**Tests**
- Version gates assumed only 0.1.10 vs latest. Bisecting PyPI sdists
gave the real versions: string prompts over stream-json in 0.1.31,
top-level assistant `error` parsing in 0.1.29.
- SDK API fields (`verbatim_prompts`, `AssistantMessage.usage`,
`ResultMessage.model_usage`) are feature-detected instead of
version-pinned.
- Removed dead 0.1.10 branches, including silent early `return`s that
reported passes without asserting.
- The bundled-subagent tests now run on 0.1.18. The background-agent
case skips only when the run streamed no subagent messages or task
events.
- The cassette transport won't save a recording with no `result`
message, so a failed or hung recording can't leave a truncated cassette.
Gate waits use `transport.wait_timeout` (short on replay, long when
recording).

**Test consolidation**
- Merged the interleaved and five-parallel subagent cassette tests into
the concurrent subagent test. It now also asserts per-subagent tool
pairing, task-to-`Agent`-tool parenting and end ordering, and that
parallel `Agent` calls share one orchestrator LLM span despite relay
user messages.
- Dropped four `FakeClaudeSDKClient` subagent tests whose claims those
cassettes now assert on real streams.

**Span ordering fix**
A subagent's last LLM span stayed open until request cleanup after its
TASK span closed. This happened on the existing `task_notification` path
(latest) and on the synthesized path. The LLM span is now finalized
first.

**Orchestrator parenting fix**
`_llm_parent_for_message` fell back to the most recent open task span
for any assistant message without a `parent_tool_use_id`. Every
supported SDK tags subagent messages, so the fallback only caught
orchestrator turns (e.g. `TaskOutput` polling while background subagents
run) and nested them under a subagent's task. Those turns now parent to
the root, asserted in
`test_multiple_bundled_subagents_keep_outer_orchestration_separate`.
That made the `llm_parent_export` merge guard and
`_message_starts_subagent_tool` dead, so they're removed.

**Validation**
- `nox -s "test_claude_agent_sdk(0.1.18)"` (CI mode): 37 passed, 6
skipped
- `nox -s "test_claude_agent_sdk(latest)"` (CI mode): 43 passed
- `make check-stale-cassettes`, `make check-unused-cassettes
INTEGRATIONS=claude_agent_sdk`, pre-commit, pylint: clean

Separate from #986's Anthropic `speed` change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) force-pushed the abhi/anthropic-speed-metadata-d8651289 branch from 24f51cb to 56dfa50 Compare October 20, 2026 19:14
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 68a8a7a into main Oct 20, 2026
98 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/anthropic-speed-metadata-d8651289 branch October 20, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

anthropic: log requested speed parameter in span metadata

1 participant