Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[bot] Anthropic Messages Batch API (`client.messages.batches`) not instrumented

未关闭
#169 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
ruby
领域
ai, observability

调研方向

从 lib/braintrust/contrib/anthropic/patcher.rb 和 lib/braintrust/contrib/anthropic/instrumentation/messages.rb 开始,然后比较现有的 create() 和 stream() instrumentation。跟踪 issue 中描述的 Anthropic Messages Batches create() 和 results() surface,包括 custom_id 关联。完成的标准是:batch 提交和每项结果都通过 spans 暴露所列出的输入、输出、token metrics 和 status,并且 coverage 与现有的 Messages integration 相匹配。

由索引模型根据 Issue 内容生成。

描述

Summary

The Anthropic Ruby SDK provides client.messages.batches for submitting multiple message requests for asynchronous Claude inference. This is a generative AI execution surface — each item in a batch runs the Claude model and produces a completion — but it is not instrumented. The SDK currently instruments the synchronous (messages.create) and streaming (messages.stream) paths for Anthropic, but not the batch path.

What is missing

The Messages Batch API (Anthropic::Resources::Messages::Batches) exposes these generative execution methods:

batches.create(requests: [...])

Submits up to 10,000 message requests for asynchronous processing. Each request item is a full MessagesCreateParams with a caller-provided custom_id. Returns a MessageBatch with a processing_status and a results_url.

batch = client.messages.batches.create(
  requests: [
    { custom_id: "req-1", params: { model: "claude-opus-4-5", max_tokens: 1024, messages: [...] } },
    { custom_id: "req-2", params: { model: "claude-opus-4-5", max_tokens: 1024, messages: [...] } }
  ]
)
batches.results(batch_id)

Streams back the completed results once the batch finishes processing. Each result item contains a custom_id, a result type (succeeded, errored, expired), and for successes a full Message response object including content, usage tokens, model, and stop reason.

What instrumentation should capture

Because batch execution is asynchronous, tracing requires instrumenting both sides:

At submit time (batches.create):

  • Each request item as input (messages, system prompt, model, max_tokens, tools, tool_choice, etc.)
  • Batch-level metadata: total request count, model(s), custom IDs

At result time (batches.results):

  • Each result item's output (content blocks, stop_reason)
  • Per-item token metrics (input_tokens, output_tokens, cache tokens) from the Message usage object
  • Per-item success/error status

A reasonable implementation is to emit one Braintrust span per batch result item when results are retrieved, carrying the original input from the corresponding custom_id request, matching the pattern the sync Messages integration already uses per-call.

Braintrust docs status

not_found — The Braintrust Anthropic integration docs at https://www.braintrust.dev/docs/integrations/ai-providers/anthropic and the Ruby SDK docs at https://www.braintrust.dev/docs do not mention batch API tracing. No Ruby-side batch instrumentation is documented anywhere in Braintrust's published docs.

Upstream sources

Local repo files inspected

  • lib/braintrust/contrib/anthropic/patcher.rb — defines MessagesPatcher and BetaMessagesPatcher; no BatchesPatcher
  • lib/braintrust/contrib/anthropic/instrumentation/messages.rb — wraps create() and stream() on Anthropic::Resources::Messages; no batches wrapper
  • lib/braintrust/contrib/anthropic/instrumentation/beta_messages.rb — wraps create() and stream() on beta messages; no batches wrapper
  • Grep for batches, MessageBatch, batch_id, custom_id across lib/braintrust/ returns zero matches
主要语言
Ruby
星标
9
派生
11
平均合并
2 天 3 小时
30 天内合并 PR
5

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

braintrustdata/braintrust-sdk-ruby 的其他 Issue

查看 braintrustdata/braintrust-sdk-ruby 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。