Skip to content

fix(arena): keep a tool result's text parts apart in the next turn - #330

Open
lokicik wants to merge 1 commit into
mainfrom
fix/arena-split-tool-output
Open

lokicik wants to merge 1 commit into
mainfrom
fix/arena-split-tool-output

Conversation

@lokicik

@lokicik lokicik commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

What and why

After a vote, a background shell result came back broken in the next turn's request. The second text part (You will be notified automatically…) was glued onto the end of the first, right after the .out path, and still sent on its own too. Every contestant fork writes tool results back from a joined copy of their text, and that whole copy went into the first part. Now it's split back over the original parts.

Testing

  • [automated] bun test --timeout 30000 ./test/arena/v2-session-runtime.test.ts in arena-backend/packages/opencode: 34 passed. The two new tests fail without the fix
  • [automated] bun test --timeout 30000 ./test/arena/fork.test.ts: 8 passed
  • [automated] Engine bun run typecheck, npm run typecheck, npm run lint and npm run format:check pass
  • [AI] Claude Code ran a stub battle in the dev app on macOS where both sides ran a background shell, voted A and sent a second turn. Without the fix both turn 2 requests had the glued text and the repeated part. With the fix the two parts came through as they were
  • Not tested: real models, Windows, Linux

Checklist

  • "What and why" is at most 500 characters
  • npm run typecheck, npm run lint and npm run format pass
  • Screenshots or video attached for UI changes
  • I agree to the contribution licensing policy and have authority to license my contribution.

A contestant fork writes every projected part back through updatePart.
The projection joins a tool's text items into one output, and
preserveToolContent put that whole output into the first text item while
keeping the rest. A background shell's two-part result then reached the
next turn's model with the second part glued onto the first and sent
again on its own.

Split the output back over the original text items instead. Unchanged
output keeps the content as it is; a changed item takes its new text;
text added at a boundary stays with the item before it.
@lokicik
lokicik requested a review from a team as a code owner December 3, 2026 17:31

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.

1 participant