[bot] ruby_llm Chat span metadata misses accessible generation parameters (tool_prefs, params, schema) and omits tools from streaming spans
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- ruby
调研方向
从 lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb 中的 extract_metadata 开始,将其字段与 issue 中所列的 OpenAI 和 Anthropic instrumentation 文件进行比较。确保 tool_prefs、params、schema 和 tools 在 streaming 和 non-streaming span 中都有表示,然后根据文档化的 RubyLLM Chat 属性验证所得的 metadata。
由索引模型根据 Issue 内容生成。
描述
Summary
The ruby_llm Chat integration captures only 3–4 fields in span metadata (provider, stream, model, and tools in non-streaming). The RubyLLM::Chat class exposes several accessible attr_reader attributes that contain key generation configuration — tool_prefs, params, and schema — none of which are captured. Additionally, tools is explicitly omitted from streaming spans even though it is an accessible attr_reader.
This is a significant detail gap compared with the OpenAI and Anthropic integrations, which each capture 15–20 configuration fields per span.
What is missing
1. tool_prefs not captured (accessible via attr_reader)
RubyLLM::Chat exposes attr_reader :tool_prefs, which is a hash with two keys:
tool_prefs[:choice]— tool choice mode (:auto,:required,:none), set viachat.with_tools(..., choice: :required). Introduced in ruby_llm v1.13.0.tool_prefs[:calls]— parallel tool call limit, set viachat.with_tools(..., calls: 1). Also introduced in v1.13.0.
These correspond directly to tool_choice and parallel_tool_calls that the OpenAI and Anthropic integrations capture.
2. params not captured (accessible via attr_reader)
RubyLLM::Chat exposes attr_reader :params, a hash of provider-specific generation parameters set via chat.with_params(max_tokens: 1000, top_p: 0.9, ...). This is the primary way users configure generation parameters like max_tokens, top_p, top_k, seed, and similar values.
These parameters directly affect generation quality and cost, and are the exact fields that the OpenAI (max_tokens, top_p, seed) and Anthropic (max_tokens, temperature, top_p, top_k) integrations capture.
3. schema not captured (accessible via attr_reader)
RubyLLM::Chat exposes attr_reader :schema, which holds the structured output format schema when users call chat.with_format(MyModel). Capturing this identifies which structured output format was requested — comparable to response_format captured by the OpenAI integration.
4. tools omitted from streaming spans
The extract_metadata method explicitly skips tools for streaming calls:
# lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb (lines ~162–164)
if !stream && respond_to?(:tools) && tools&.any?
metadata["tools"] = extract_tools_metadata
end
tools is an attr_reader on RubyLLM::Chat and is available during streaming calls. When users stream a tool-using chat, the span metadata contains no information about which tools were available — making it impossible to correlate tool execution spans with their governing chat configuration.
Comparison with other integrations
| Field | OpenAI | Anthropic | ruby_llm |
|---|---|---|---|
| model | ✓ | ✓ | ✓ |
| temperature | ✓ | ✓ | ✗ (in @temperature, no attr_reader) |
| max_tokens | ✓ | ✓ | ✗ (in params) |
| top_p / top_k | ✓ | ✓ | ✗ (in params) |
| seed | ✓ | – | ✗ (in params) |
| tools | ✓ | ✓ | ✓ non-streaming only |
| tool_choice | ✓ | ✓ | ✗ (in tool_prefs[:choice]) |
| parallel_tool_calls | ✓ | – | ✗ (in tool_prefs[:calls]) |
| response_format / schema | ✓ | – | ✗ (in schema) |
Braintrust docs status
not_found — The Braintrust ruby_llm integration docs at https://www.braintrust.dev/docs/integrations/sdk-integrations/ruby-llm describe basic chat tracing but do not document which metadata fields are captured. No mention of tool_choice, generation parameters, or structured output format in the Ruby LLM integration docs.
Upstream sources
RubyLLM::Chatsource with attr_readers: https://github.com/crmne/ruby_llm/blob/main/lib/ruby_llm/chat.rb- ruby_llm v1.13.0 release (tool_prefs/tool_choice added): https://github.com/crmne/ruby_llm/releases/tag/v1.13.0
with_tools(choice:, calls:)documentation: https://rubyllm.com/guides/tools
Local repo files inspected
lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb—extract_metadata(lines ~151–167) captures onlyprovider,stream,model, andtools(non-streaming); notool_prefs,params, orschemalib/braintrust/contrib/openai/instrumentation/chat.rb— METADATA_FIELDS captures 20 fields including model, temperature, top_p, max_tokens, response_format, seed, tools, tool_choice, parallel_tool_callslib/braintrust/contrib/anthropic/instrumentation/messages.rb— METADATA_FIELDS captures model, max_tokens, temperature, top_p, top_k, stop_sequences, tools, tool_choice, thinking, service_tier
- 主要语言
- Ruby
- 星标
- 9
- 派生
- 11
- 平均合并
- 2 天 3 小时
- 30 天内合并 PR
- 5
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-ruby 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
ruby
难度 3/5 半天 新手友好度 62/100
-
ruby
难度 3/5 1-2 天 新手友好度 45/100
查看 braintrustdata/braintrust-sdk-ruby 的全部 Issue
相似的 Issue
-
verified
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 5 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
akitaonrails/ai-book-2026#10 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
zerocracy/judges-action#2984 ·
维护者通常 1 天内回复