Repository navigation
Add experimental OpenCode 2 tracing - #259
Stephen Belanger (Qard) wants to merge 21 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d86f0708f7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| id: "braintrust.trace", | ||
| async setup(ctx: Context) { | ||
| const config = loadConfig(await readPluginConfig(ctx.location)); | ||
| if (config.enableTools && !process.env.BT_TRACE_MANAGED_RUN_ID) { |
There was a problem hiding this comment.
Preserve enabled tools in managed OpenCode 2 runs
When a user has enable_tools enabled and launches OpenCode 2 through bt trace run, this managed-run check suppresses the only v2 tool registration, so all four Braintrust data tools disappear. Unlike v1's separate trace-only entrypoint, v2 injects or de-duplicates the root package, leaving no other instance to register them; managed tracing should not override the independently configured tools setting.
AGENTS.md reference: src/plugins/opencode/content/AGENTS.md:L8-L8
Useful? React with 👍 / 👎.
| "session.text.ended" | "session.reasoning.ended" => { | ||
| let kind = if event.event == "session.text.ended" { "text" } else { "reasoning" }; | ||
| self.emit(event, ctx, "message.part.updated", json!({"properties":{"part":{"sessionID":sid,"messageID":mid,"id":data.get("ordinal").map(Value::to_string),"type":kind,"text":data.get("text"),"time":{"end":event.ts_ms}}}})) |
There was a problem hiding this comment.
Preserve every assistant text part
When one assistant message contains multiple session.text.ended or multiple reasoning parts, each translated event carries the same messageID, and the reused v1 reducer stores parts with output_parts.insert(message_id, text) and the analogous reasoning map. Consequently each event overwrites the previous ordinal, so the emitted LLM and turn output retain only the final part; the adapter needs to accumulate the ordinal-addressed parts instead.
Useful? React with 👍 / 👎.
OpenCode 2 users can trace their sessions in Braintrust while existing OpenCode 1 users continue to work as before. Traces preserve tool calls, resumed sessions and subagent conversations, including after an interruption or model failure.
Installed-package tests cover OpenCode 2.0.0, 2.1.0 and 2.2.5, with mock model and trace services. They exercise tools, attachments, subagents, permissions, failures, interruption, compaction, session continuation and delayed daemon acknowledgements. The OpenCode 1.19.5 integration test also passes.
Related to #226.