Skip to content

fix(trace-opencode): capture system prompt in LLM span input#8

Merged
Andrew Kent (realark) merged 1 commit intomainfrom
colin-missing-prompt
Apr 17, 2026
Merged

fix(trace-opencode): capture system prompt in LLM span input#8
Andrew Kent (realark) merged 1 commit intomainfrom
colin-missing-prompt

Conversation

@colinbennettbrain
Copy link
Copy Markdown
Contributor

OpenCode emits the resolved system prompt (AGENTS.md / CLAUDE.md content) via experimental.chat.system.transform — a hook the plugin did not subscribe to. LLM spans therefore rendered with only the user turn, making it impossible to debug prompt behavior in Braintrust.

Subscribe to the hook, store the joined system prompt on SessionState, and prepend it as the first message when building LLM span input. The hook's output.system is string[] (not string as sometimes assumed); parts are joined with a blank line so the trace shows one system entry.

Mirror the capture in the EventProcessor replay path, the FileLogger, and replay.ts so recorded fixtures reconstruct system prompts too.

Tests cover: present, absent (regression guard), multi-part joining, across-turn updates, empty arrays, and the production hook wired end- to-end through createTracingHooks.

OpenCode emits the resolved system prompt (AGENTS.md / CLAUDE.md content)
via experimental.chat.system.transform — a hook the plugin did not
subscribe to. LLM spans therefore rendered with only the user turn,
making it impossible to debug prompt behavior in Braintrust.

Subscribe to the hook, store the joined system prompt on SessionState,
and prepend it as the first message when building LLM span input. The
hook's output.system is string[] (not string as sometimes assumed);
parts are joined with a blank line so the trace shows one system entry.

Mirror the capture in the EventProcessor replay path, the FileLogger,
and replay.ts so recorded fixtures reconstruct system prompts too.

Tests cover: present, absent (regression guard), multi-part joining,
across-turn updates, empty arrays, and the production hook wired end-
to-end through createTracingHooks.
@realark Andrew Kent (realark) merged commit 4ced150 into main Apr 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants