Repository navigation
fix(session): only end a Codex tool round on items that start a message - #1260
Conversation
No other confident findings in the specified diff. I did not run, build, or install anything. |
SaulMoro
left a comment
There was a problem hiding this comment.
Reviewed at f51ebc32 (merged with origin/main 2aa8a8ad).
Findings
- [P1 blocking] Missing real-CLI verification record.
src/session-flow/adapters/codex.ts:533changes runtime behavior, and the first## Code Review Rulesitem requires an end-to-end / real-CLI verification record in the PR description beyond unit tests and type checks. Please add a real-CLIsession migraterecord to the PR description. - [P3 nit]
messagewithrole === 'developer'still triggersflushToolImages(). Atsrc/session-flow/adapters/codex.ts:534,flushToolImages()runs whenptype === 'message', beforeif (role === 'developer') continue;at line 538. If Codex emits a developerresponse_itembetween two tool outputs of the same round, the first output's images will still be flushed before the second output arrives. Checking(ptype === 'message' && payload.role !== 'developer')(or flushing inside each handled branch) avoids that.
Local verification (macOS)
- Merges cleanly with
origin/main(2aa8a8ad),npx tsc --noEmitis clean, andsession-cmd.test.ts+claude-tool-result-images.test.tspass. - Built the CLI (
npm run build) and ranteamai session migrate 019e0000-1111-7222-8333-666666666667 -s codex -t claude-code --cwd /work/app --jsonon a rollout containingc1(image output), an ignoredweb_search_call, andc2(text output). The migrated Claude Code transcript wrote 4 messages in the expected order:[["user",["text"]],["assistant",["tool_use","tool_use"]],["user",["tool_result","tool_result"]],["user",["image"]]].
They are skipped, like web_search_call, so they no longer flush the round's images before its last tool output.
|
Both done in df1e5d6. The description now has a real |
No other confident findings in the specified diff. I did not run, build, or install anything. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
This re-reviews df1e5d6 against the Request changes of f51ebc3. Both findings are resolved.
The description has a real teamai session migrate 019e0000-1111-7222-8333-666666666667 -s codex -t claude-code --cwd /work/app --json record. We ran that command on this head. Exit 0. The written session is user[text] assistant[tool_use,tool_use] user[tool_result,tool_result] user[image]. Both tool results stay in one user message, and the image follows them. Fidelity on this transcript is 90.0%. The CI comment that still calls the record missing was fetched before this description edit.
A developer message no longer flushes the round. src/session-flow/adapters/codex.ts:534 excludes role === 'developer' from startsMessage.
#1263 also edits src/session-flow/adapters/codex.ts, only findCodexCli. This PR owns buildMessages.
Summary
Follow-up to #1254, from SaulMoro's review there. The Codex reader holds the images a tool returned until the round's tool results are done, but it ended the round on any
response_itemthat isn't a tool output, including types it ignores likeweb_search_call. If one of those fell between two outputs of the same round, the next output was appended to the image message (user[tool_result],user[image, tool_result]), the mixed shape #1254 avoids for codebuddy/workbuddy.The round now ends only on
function_call,custom_tool_call,reasoningand non-developermessageitems. Developer messages are skipped, so they no longer end it either.Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest run: 11270 passed; the same 5 tests fail on main without this change (cursor-bubble-range, cursor-user-images x2, submodule-checkout x2)session-cmd.test.ts(call c1, call c2, output c1 with an image, then aweb_search_callor a developer message, then output c2); both cases fail on main and pass hereteamai session migrate 019e0000-1111-7222-8333-666666666667 -s codex -t claude-code --cwd /work/app --json, withHOMEin a scratch dir and the CLI built from each commit. The rollout has calls c1 (view_image) and c2 (shell), c1's output with a 1x1 PNG, then aweb_search_callor a developer message, then c2's output and a final assistant message. Message shapes in the written Claude Code session:Fidelity is 91.4% in all six runs (
shellandview_imagehave no Claude Code tool).Related Issues
#1254
Notes for Reviewers
Codex isn't known to write a rollout in this order, so this only closes the gap.