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

[bot] Anthropic Messages API: `container` and `mcp_servers` params not captured in span metadata

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

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
ruby

调研方向

从 lib/braintrust/contrib/anthropic/instrumentation/messages.rb 和 beta_messages.rb 开始,检查列出的元数据常量以及 finalize_metadata、set_output 和 capture_beta_fields 路径。跟踪请求和响应元数据的组装方式,然后验证在稳定版、beta 和与 batch 相关的流程中都表示了 container 和 mcp_servers,同时不暴露敏感值。当相关 span 包含文档中记录的字段且现有的 instrumentation 检查通过时,即表示完成。

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

描述

Summary

The official anthropic Ruby gem's Messages and Beta Messages APIs support two significant, currently-documented fields that this SDK's instrumentation silently drops from span metadata: container (code execution tool sandbox reuse) and mcp_servers (the MCP connector, which lets Claude call tools on remote MCP servers directly during generation). Both directly affect what happens during model execution — which tools were actually available/reused, which sandbox state persisted across turns — yet neither appears in any span this SDK produces.

What is missing

  • mcp_servers (request param, beta Messages API): configures remote MCP servers Claude can call tools on mid-generation. Official Ruby example from Anthropic's own docs:

    client.beta.messages.create(
      model: "claude-opus-4-8",
      max_tokens: 1000,
      messages: [...],
      mcp_servers: [{type: "url", url: "...", name: "example-mcp", authorization_token: "..."}],
      tools: [{type: "mcp_toolset", mcp_server_name: "example-mcp"}],
      betas: ["mcp-client-2025-11-20"]
    )
    

    Also usable inside Message Batches requests.

  • container (request param + response field, both stable and beta Messages APIs): identifies/reuses the sandboxed code-execution container across requests so state (e.g. Python variable bindings) persists. Documented on Anthropic::Models::Message in the official Ruby SDK docs as "Information about the container used in the request (for the code execution tool)."

Neither field is in METADATA_FIELDS (lib/braintrust/contrib/anthropic/instrumentation/messages.rb:25-28) or BETA_METADATA_FIELDS/METADATA_FIELDS (lib/braintrust/contrib/anthropic/instrumentation/beta_messages.rb:29-37), and finalize_metadata/set_output in both files never read response.container. So a user running a code-execution or MCP-connector workflow through this SDK gets a Braintrust trace with no record of which container was reused or which MCP servers/tools were actually wired up — a debugging-critical omission for exactly the kind of agentic tool-execution traces Braintrust is meant to surface.

Braintrust docs status

not_found for Ruby — https://www.braintrust.dev/docs/integrations/ai-providers/anthropic does not mention container or mcp_servers anywhere in the Ruby-specific section. Notably, the Go section of the same page explicitly lists both as captured request parameters ("each span captures ... container, mcp_servers ..."), showing Braintrust already treats these as first-class fields for another language SDK — Ruby is the outlier.

Upstream sources

Local repo files inspected

  • lib/braintrust/contrib/anthropic/instrumentation/messages.rb — METADATA_FIELDS (lines 25-28) and finalize_metadata (lines 141-146) omit container; no mcp_servers handling anywhere
  • lib/braintrust/contrib/anthropic/instrumentation/beta_messages.rb — METADATA_FIELDS/BETA_METADATA_FIELDS (lines 29-37) and capture_beta_fields (lines 146-166) capture only betas and output_format; no container or mcp_servers
  • lib/braintrust/contrib/anthropic/instrumentation/common.rb — token usage parser only; no incidental capture of container/mcp_servers
  • Grep for container, mcp_servers, mcp_server across lib/braintrust/ returns zero relevant matches (one unrelated hit in lib/braintrust/server/services/list_service.rb)
主要语言
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 摘要。