pi-coding-agent: Pi 1.4 system messages dropped, so LLM spans have no system prompt or tools

Fermée
#2,662 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@AbhiPrasad y travaille déjà.

Depuis le 26/10/2026.

  • #2663 par @pcbeingused333 — fermée sans fusion
  • #2673 par @AbhiPrasad — fusionnée

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
node.js, typescript
Domaine
observability

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

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:

  • normalizePiContextInput adds a system message only from context.systemPrompt;
  • normalizePiMessage returns [] for a role: "system" message, so the transcript's system messages are dropped;
  • extractToolMetadata(context.tools) (LLM span metadata.tools) and wrapPiToolExecutors(context.tools) see undefined.

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 SystemMessage into a { role: "system", content } input message, rendering content followed by its sections (later messages replace sections by name; null removes one), or at least keep the message's content and sections.
  • Fold toolsAdded / toolsRemoved across the transcript's system messages into the declared tool set and report it as metadata.tools, falling back to context.tools for callers that still pass it.
  • Wrap tool executors from the agent's tools (agent.state.tools) rather than context.tools.

We work around it by adding the agent state's systemPrompt and tools to the AgentSession.prompt span through a span customizer.

Langage dominant
TypeScript
Étoiles
29
Forks
22
Merge moyen
1 j 25 min
PR mergées (30 j)
80

Préparer son environnement

  • Fournit un Dockerfile ou un fichier Docker Compose
  • Aucun modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de braintrustdata/braintrust-sdk-javascript

Toutes les issues de braintrustdata/braintrust-sdk-javascript

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.