Skip to content

Conversation

@evalstate
Copy link
Owner

…ation

  • Replace custom CancellationError with asyncio.CancelledError for idiomatic async
  • Remove ExtendedAgentSideConnection class (fix non-compliant clients instead)
  • Implement task-based cancellation via asyncio.Task.cancel() in ACP server
  • Track asyncio tasks per session for proper cancellation support
  • Update all LLM providers (Anthropic, OpenAI, Google, Bedrock) to use asyncio.CancelledError
  • Add proper CancelledError handling in ACP prompt method

This aligns with Python asyncio best practices and provides more immediate cancellation when LLM providers are blocked on network calls.

…ation

- Replace custom CancellationError with asyncio.CancelledError for idiomatic async
- Remove ExtendedAgentSideConnection class (fix non-compliant clients instead)
- Implement task-based cancellation via asyncio.Task.cancel() in ACP server
- Track asyncio tasks per session for proper cancellation support
- Update all LLM providers (Anthropic, OpenAI, Google, Bedrock) to use
  asyncio.CancelledError
- Add proper CancelledError handling in ACP prompt method

This aligns with Python asyncio best practices and provides more immediate
cancellation when LLM providers are blocked on network calls.
Following review recommendations, this removes the now-redundant CancellationToken
class entirely. Cancellation is now handled purely through asyncio.Task.cancel(),
which raises CancelledError at the next await point.

Changes:
- Remove CancellationToken class from cancellation.py (kept module for docs)
- Remove cancellation_token parameter from all LLM providers and generate methods
- Remove token polling checks from streaming loops (task.cancel() handles it)
- Update ACP server to use only task-based cancellation
- Update all agents to remove cancellation_token parameters
- Update tests to remove CancellationToken usage

This simplifies the cancellation architecture by relying on Python's native
asyncio patterns. The _session_tasks dict in ACP server is sufficient for
cancellation - no separate token tracking needed.
@evalstate evalstate merged commit 8dbe121 into main Nov 23, 2025
6 checks passed
@evalstate evalstate deleted the claude/review-acp-cancellation-016pZUtKGNYygvM657fvbFvC branch November 27, 2025 21:52
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.

3 participants