feat: Add Message Batches API instrumentation#1698
Closed
Stephen Belanger (Qard) wants to merge 3 commits intomainfrom
Closed
feat: Add Message Batches API instrumentation#1698Stephen Belanger (Qard) wants to merge 3 commits intomainfrom
Stephen Belanger (Qard) wants to merge 3 commits intomainfrom
Conversation
Luca Forstner (lforst)
previously approved these changes
Mar 27, 2026
Member
Luca Forstner (lforst)
left a comment
There was a problem hiding this comment.
Generally looks good but some e2e test assertions would be beneficial I think.
Member
|
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?
|
2 tasks
Luca Forstner (lforst)
pushed a commit
that referenced
this pull request
Mar 31, 2026
…ropic timeout (#1707) ## Summary - **Langchain canary**: Newer versions of `@langchain/openai` removed `max_tokens`, `model`, `stream`, and `temperature` from the `ls_*` metadata block (they're already captured in the standardized `ls_max_tokens`, `ls_model_name`, etc. fields). Added normalization in `assertions.ts` to delete these volatile keys from any metadata object that contains `ls_` keys, making the `wrap-langchain-js-traces` snapshot stable across both the locked (1.3.0) and latest langchain versions. - **Anthropic timeout**: Increase the `anthropic-instrumentation` scenario timeout from 90s to 150s to accommodate the additional `messages.batches` API calls (create, retrieve, list, cancel) that will land when #1698 merges. ## Test plan - [ ] `wrap-langchain-js-traces` canary test passes with both locked and latest `@langchain/openai` - [ ] Anthropic instrumentation tests unaffected (timeout increase is headroom only) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
- 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>
Adds scenario coverage and snapshot assertions for the Anthropic Message Batches API (create, retrieve, list, cancel) across all supported SDK versions (v0.39.0+). Normalizes volatile batch response fields (timestamps, batch IDs, list bodies) for stable snapshots. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5adc7f4 to
e60aacd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
messages.batches.*) — fixes Anthropic Message Batches API (client.messages.batches.*) not instrumented #1691wrapAnthropic()manual wrapping and auto-instrumentation via--import braintrust/hook.mjscreate,retrieve,list,cancel,deleteChanges
vendor-sdk-types/anthropic.ts: AddedAnthropicBatches,AnthropicMessageBatch,AnthropicBatchCreateParams,AnthropicBatchRequest,AnthropicBatchListParamstypes; addedbatchesfield toAnthropicMessagesanthropic-channels.ts: Added 5 new diagnostic channels (messages.batches.create/retrieve/list/cancel/delete)wrappers/anthropic.ts: AddedbatchesProxy()and wired it intomessagesProxy()to intercept thebatchespropertyanthropic-plugin.ts: AddedtraceAsyncChannelsubscriptions for all 5 batch channelsconfigs/anthropic.ts: Added auto-instrumentation configs targetingBatchesclass methods inresources/messages/batches.mjs(>=0.39.0)Test plan
pnpm run test:checksinjs/)pnpm run lint)pnpm run fix:formatting)🤖 Generated with Claude Code