AI SDK tool spans don't respect `toModelOutput`
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
When a Vercel AI SDK tool defines toModelOutput, the model only sees that transformed value, but the wrapAISDK tool span still logs the raw execute result via the patched execute.
Apps use toModelOutput to keep data away from the model, for example query rows a user hasn't agreed to share. Braintrust's global setMaskingFunction doesn't fix this cleanly, because it doesn't know which tool a value came from.
Repro with [email protected] and [email protected], using a mock model:
import * as ai from 'ai'
import { MockLanguageModelV4 } from 'ai/test'
import { initLogger, wrapAISDK } from 'braintrust'
import { z } from 'zod'
initLogger({ projectName: 'repro' })
const { generateText } = wrapAISDK(ai)
await generateText({
model: new MockLanguageModelV4({
doGenerate: async () => ({
content: [{ type: 'tool-call', toolCallId: 'call-1', toolName: 'runQuery', input: '{}' }],
finishReason: { unified: 'tool-calls', raw: undefined },
usage: { inputTokens: { total: 1 }, outputTokens: { total: 1 } },
warnings: [],
}),
}),
prompt: 'Count signups',
tools: {
runQuery: ai.tool({
inputSchema: z.object({}),
execute: async () => ({ rows: [{ email: '[email protected]' }] }),
toModelOutput: () => ({ type: 'text', value: 'Rows hidden from the model' }),
}),
},
})
The runQuery tool span's output is { rows: [{ email: '[email protected]' }] }. I expected Rows hidden from the model. The raw rows also appear in the parent generateText span, under steps[].content[] in the tool result. The same happens with ai.registerTelemetry(braintrustAISDKTelemetry()).
| tool span | parent span |
|---|---|
When a tool defines toModelOutput, I expect the tool span and the parent span's tool results to log its result instead of the raw execute value. That way the trace matches what the model saw and avoids privacy footguns. If this is too big a change for the default, a wrapAISDK option to turn it on would cover our case.
- 主要语言
- TypeScript
- 星标
- 29
- 派生
- 21
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 70
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-javascript 的其他 Issue
-
High TypeScript checking cost from generated Zod 3 schemas可能已有人在做 @lforst 于 11 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 22/100
braintrustdata/braintrust-sdk-javascript#2624 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[bot] Instrument Luma AI (17,324 weekly downloads)可能已有人在做 @karthiksenv 于 11 天前认领。 未关闭typescript
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2578 ·
维护者通常 1 天内回复
-
[bot] Instrument Letta Agent SDK (87,205 weekly downloads)可能已有人在做 @karthiksenv 于 14 天前认领。 未关闭typescript
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2577 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2527 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 65/100
braintrustdata/braintrust-sdk-javascript#2526 ·
维护者通常 1 天内回复
查看 braintrustdata/braintrust-sdk-javascript 的全部 Issue
相似的 Issue
-
e2e-failure ready-to-code
难度 2/5 1-3 小时 新手友好度 79/100
redhat-developer/rhdh-plugin-export-overlays#4580 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
devdotfast/whiteboard#1415 · 1 条评论 ·
维护者通常 1 天内回复
-
area/sessions comp/desktop desktop/sessions P2 type/bug
难度 2/5 1-3 小时 新手友好度 84/100
NousResearch/hermes-agent#145383 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
enhancement p2 setup
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复