pi-coding-agent: Pi 1.4 system messages dropped, so LLM spans have no system prompt or tools
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
Start in js/src/instrumentation/plugins/pi-coding-agent-plugin.ts: normalizePiMessage currently returns [] for role:"system" messages and normalizePiContextInput only reads context.systemPrompt. Read pi-agent-core's StreamFn/SystemMessage docs (content, sections, toolsAdded, toolsRemoved) and reproduce with Pi 1.4 by checking that an openai.responses.create span under AgentSession.prompt gains system input and metadata.tools. Done: system messages are normalized into input, tools are folded from toolsAdded/toolsRemoved with a fallback to context.tools, and executors are wrapped from agent.state.tools.
由索引模型根据 Issue 内容生成。
描述
Summary
With @earendil-works/pi-coding-agent / pi-agent-core / pi-ai 1.4.0, the Pi Coding Agent integration (js/src/instrumentation/plugins/pi-coding-agent-plugin.ts, braintrust 3.39.0 and main at 50280e8b1) records LLM spans with no system prompt and no tool list.
Cause
Pi 1.4's agent loop calls the stream function with a normalized TranscriptContext. Its system prompt and tool declarations travel only in role: "system" messages (SystemMessage: content, sections, toolsAdded, toolsRemoved). pi-agent-core's StreamFn doc says: "the system prompt and tool declarations are carried by the transcript's system messages, never by context.systemPrompt or context.tools."
The plugin reads only those absent fields:
normalizePiContextInputadds a system message only fromcontext.systemPrompt;normalizePiMessagereturns[]for arole: "system"message, so the transcript's system messages are dropped;extractToolMetadata(context.tools)(LLM spanmetadata.tools) andwrapPiToolExecutors(context.tools)seeundefined.
Observed
In our dev project, every openai.responses.create LLM span under AgentSession.prompt has an input of only user/assistant/tool messages and no metadata.tools; the prompt span has pi_coding_agent.active_tools (names only). There is no plugin option to recover this: spanCustomizers.onSpanExport runs after the data is gone.
Suggested fix
- Normalize each
SystemMessageinto a{ role: "system", content }input message, renderingcontentfollowed by itssections(later messages replace sections by name;nullremoves one), or at least keep the message'scontentandsections. - Fold
toolsAdded/toolsRemovedacross the transcript's system messages into the declared tool set and report it asmetadata.tools, falling back tocontext.toolsfor callers that still pass it. - Wrap tool executors from the agent's tools (
agent.state.tools) rather thancontext.tools.
We work around it by adding the agent state's systemPrompt and tools to the AgentSession.prompt span through a span customizer.
- 主要语言
- TypeScript
- 星标
- 29
- 派生
- 21
- 平均合并
- 1 天 13 小时
- 30 天内合并 PR
- 67
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-javascript 的其他 Issue
-
Pi Coding Agent instrumentation double-counts tokens and estimated cost in trace rollups (AgentSession.prompt carries summed LLM usage)可能已有人在做 @sharonadhitya 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
braintrustdata/braintrust-sdk-javascript#2659 · 1 条评论 ·
维护者通常 1 天内回复
-
AI SDK tool spans don't respect `toModelOutput`可能已有人在做 @AbhiPrasad 于 3 天前认领。 未关闭typescript
braintrustdata/braintrust-sdk-javascript#2651 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
High TypeScript checking cost from generated Zod 3 schemas可能已有人在做 @lforst 于 10 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 22/100
braintrustdata/braintrust-sdk-javascript#2624 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[bot] Instrument Luma AI (17,324 weekly downloads)可能已有人在做 @karthiksenv 于 10 天前认领。 未关闭typescript
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2578 ·
维护者通常 1 天内回复
-
[bot] Instrument Letta Agent SDK (87,205 weekly downloads)可能已有人在做 @karthiksenv 于 13 天前认领。 未关闭typescript
难度 4/5 3-5 天 新手友好度 55/100
braintrustdata/braintrust-sdk-javascript#2577 ·
维护者通常 1 天内回复
查看 braintrustdata/braintrust-sdk-javascript 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 70/100
microsoft/playwright#43640 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
grasshopper-protocol/grsshppr#172 ·
维护者通常 1 天内回复
-
bug help wanted
难度 2/5 1-3 小时 新手友好度 78/100
Tencent/teamai-cli#1397 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
DouyinFE/semi-design#3641 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复