Skip to content

feat: Add Message Batches API instrumentation#1698

Open
Stephen Belanger (Qard) wants to merge 2 commits intomainfrom
feat/anthropic-message-batches-instrumentation
Open

feat: Add Message Batches API instrumentation#1698
Stephen Belanger (Qard) wants to merge 2 commits intomainfrom
feat/anthropic-message-batches-instrumentation

Conversation

@Qard
Copy link
Copy Markdown
Contributor

Summary

Changes

  • vendor-sdk-types/anthropic.ts: Added AnthropicBatches, AnthropicMessageBatch, AnthropicBatchCreateParams, AnthropicBatchRequest, AnthropicBatchListParams types; added batches field to AnthropicMessages
  • anthropic-channels.ts: Added 5 new diagnostic channels (messages.batches.create/retrieve/list/cancel/delete)
  • wrappers/anthropic.ts: Added batchesProxy() and wired it into messagesProxy() to intercept the batches property
  • anthropic-plugin.ts: Added traceAsyncChannel subscriptions for all 5 batch channels
  • configs/anthropic.ts: Added auto-instrumentation configs targeting Batches class methods in resources/messages/batches.mjs (>=0.39.0)

Test plan

  • Unit tests pass (pnpm run test:checks in js/)
  • No lint errors (pnpm run lint)
  • Formatting applied (pnpm run fix:formatting)
  • CI checks pass

🤖 Generated with Claude Code

Stephen Belanger (Qard) and others added 2 commits March 28, 2026 00:13
- Add vendor types for AnthropicBatches, AnthropicMessageBatch, and batch params
- Add diagnostic channels for create, retrieve, list, cancel, and delete batch ops
- Add batchesProxy() in wrapAnthropic() to intercept all Batches methods
- Add AnthropicPlugin subscriptions for batch channels via traceAsyncChannel
- Add auto-instrumentation configs targeting Batches class methods (>=0.39.0)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ractInput

The destructured parameter type annotations (e.g. `([params]: [T])`) were
stricter than the expected `(args: [T, ...any[]], event, span) => ...` type,
causing assignability errors. Removing the annotations lets TypeScript infer
the correct types from the channel's generic parameters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@lforst Luca Forstner (lforst) left a comment

Choose a reason for hiding this comment

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

Generally looks good but some e2e test assertions would be beneficial I think.

@lforst
Copy link
Copy Markdown
Member

Luca Forstner (lforst) commented Mar 28, 2026

Actually, coming back to my senses... Should we really be instrumenting create, retrieve, list, cancel, delete? Those seem more like CRUD operations and less like AI relevant things that we would like to instrument no?

create makes sense to some degree, but even there it's more an input thing and less an output thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anthropic Message Batches API (client.messages.batches.*) not instrumented

2 participants