Skip to content

fix(claude-agent-sdk): propagate genuine task cancellation - #882

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/sdk-497-python-sdk-claude-agent-tracing-swallows-genuine-task
Oct 5, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/sdk-497-python-sdk-claude-agent-tracing-swallows-genuine-task

Conversation

@AbhiPrasad

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

Copy link
Copy Markdown
Member

Summary

  • Propagate asyncio.CancelledError when the current task has a pending cancellation request, while keeping suppression for transport-originated cancellation where asyncio exposes the task cancellation counter.
  • On Python 3.10, where asyncio has no cancellation counter, preserve CancelledError rather than risk masking genuine task cancellation.
  • Add cassette-backed timeout and explicit cancellation coverage for both query() and receive_response().
  • Remove fake-only cancellation tests in favor of replay through the real Claude Agent SDK transport.

Validation

Python 3.12 and 3.10, using both supported Claude Agent SDK pins:

  • latest: 50 passed
  • 0.1.10: 43 passed, 7 skipped

Refs SDK-497.

Keep transport-originated cancellation suppression while preserving task
cancellation for timeouts and explicit cancel requests.

Refs SDK-497.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 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-05T23:13:21.323482Z 32fa780 PR opened
ℹ️ 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.

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) changed the title fix(claude-agent-sdk): propagate genuine task cancellation [SDK-497] fix(claude-agent-sdk): propagate genuine task cancellation Oct 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32fa7803b7

ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/src/braintrust/integrations/claude_agent_sdk/tracing.py Outdated
Comment thread py/src/braintrust/integrations/claude_agent_sdk/test_claude_agent_sdk.py Outdated
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 09b03e9 into main Oct 5, 2026
83 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/sdk-497-python-sdk-claude-agent-tracing-swallows-genuine-task branch October 5, 2026 23:26
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.

2 participants