pi-coding-agent: Pi 1.4 system messages dropped, so LLM spans have no system prompt or tools
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- observability
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 29
- Forks
- 21
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 67
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from braintrustdata/braintrust-sdk-javascript
-
Pi Coding Agent instrumentation double-counts tokens and estimated cost in trace rollups (AgentSession.prompt carries summed LLM usage)Possibly taken @sharonadhitya claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
braintrustdata/braintrust-sdk-javascript#2659 · 1 comment ·
Maintainers usually reply within 1 day
-
AI SDK tool spans don't respect `toModelOutput`Possibly taken @AbhiPrasad claimed this 3 days ago. Opentypescript
braintrustdata/braintrust-sdk-javascript#2651 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
High TypeScript checking cost from generated Zod 3 schemasPossibly taken @lforst claimed this 10 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 22/100
braintrustdata/braintrust-sdk-javascript#2624 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
[bot] Instrument Luma AI (17,324 weekly downloads)Possibly taken @karthiksenv claimed this 10 days ago. Opentypescript
Difficulty 4/5 3-5 days Newbie friendliness 55/100
braintrustdata/braintrust-sdk-javascript#2578 ·
Maintainers usually reply within 1 day
-
[bot] Instrument Letta Agent SDK (87,205 weekly downloads)Possibly taken @karthiksenv claimed this 13 days ago. Opentypescript
Difficulty 4/5 3-5 days Newbie friendliness 55/100
braintrustdata/braintrust-sdk-javascript#2577 ·
Maintainers usually reply within 1 day
All issues in braintrustdata/braintrust-sdk-javascript
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
microsoft/playwright#43640 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
grasshopper-protocol/grsshppr#172 ·
Maintainers usually reply within 1 day
-
bug help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Tencent/teamai-cli#1397 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
DouyinFE/semi-design#3641 ·
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day