Skip to content

Add experimental OpenCode 2 tracing - #259

Draft
Stephen Belanger (Qard) wants to merge 21 commits into
mainfrom
t3/investigate-issue-226
Draft

Stephen Belanger (Qard) wants to merge 21 commits into
mainfrom
t3/investigate-issue-226

Conversation

@Qard

@Qard Stephen Belanger (Qard) commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@Qard Stephen Belanger (Qard) changed the title Begin support for OpenCode 2 traces Add experimental OpenCode 2 tracing Nov 2, 2026
@Qard
Stephen Belanger (Qard) marked this pull request as ready for review November 3, 2026 11:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T11:16:21.584577Z d86f070 Draft marked ready
ℹ️ About Codex in GitHub

Your 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.

@Qard
Stephen Belanger (Qard) marked this pull request as draft November 3, 2026 11:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread bt-daemon/src/translate/opencode_v2.rs Outdated
Comment on lines +112 to +114
"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}}}}))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread bt-daemon/tests/agent_integration.rs Dismissed

This branch has not been deployed

No deployments
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