Skip to content

Add native Anthropic SDK support#2

Open
anassg-lago wants to merge 2 commits into
mainfrom
feature/anthropic-native
Open

Add native Anthropic SDK support#2
anassg-lago wants to merge 2 commits into
mainfrom
feature/anthropic-native

Conversation

@anassg-lago
Copy link
Copy Markdown
Collaborator

  • src/lago_agent_sdk/adapters/anthropic_native.py — extract_anthropic_native
  • src/lago_agent_sdk/wrappers/anthropic.py — wraps messages.create (sync + async, streaming and non-streaming) and messages.stream context manager
  • Wired into sdk.wrap() dispatch and adapters/init.py exports
  • anthropic = ["anthropic>=0.30"] optional-dep group
  • 19 new unit tests + 3 live integration tests; 256 unit tests pass
  • Coverage 80.71% — gate maintained
  • 9 captured response fixtures from real Anthropic API
  • README + CHANGELOG updated

- src/lago_agent_sdk/adapters/anthropic_native.py — extract_anthropic_native
- src/lago_agent_sdk/wrappers/anthropic.py — wraps messages.create (sync + async,
  streaming and non-streaming) and messages.stream context manager
- Wired into sdk.wrap() dispatch and adapters/__init__.py exports
- anthropic = ["anthropic>=0.30"] optional-dep group
- 19 new unit tests + 3 live integration tests; 256 unit tests pass
- Coverage 80.71% — gate maintained
- 9 captured response fixtures from real Anthropic API
- README + CHANGELOG updated
The test set max_batch_size == max_buffer_size == 100, which caused the
push that brings the buffer to 100 to trigger a wake on the background
worker. The worker would take a batch (emptying the buffer) and then race
with the remaining 150 pushes to call slow_sender. On CI's slower runners
the worker sometimes squeezed in additional batches before slow_sender
finally blocked, leaving the buffer with fewer items than the expected
sliding window.

Setting max_batch_size > max_buffer_size guarantees push() never sets the
wake event (buffer can never reach max_batch_size). Combined with a long
flush_interval the worker only runs once shutdown() releases the pause in
the finally block — fully deterministic. Verified with 5 consecutive runs.
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.

1 participant