Repository navigation
fix(chat): send held steer text before the next tool call - #32826
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix happens where the order breaks: held text now goes out at the tool call that would have jumped ahead of it. The one change in what gets kept is declared as a trade-off. Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: after a quiet end with a steer pending, the saved reply keeps text and tool rows in the order the model produced them. FIX.
[FIRST-PRINCIPLES-REVIEWED] e5db15d Description read[DESCRIPTION-READ] 498df3108603062160745105d1e1db2afc5e473d98777084184550d3bc224f99 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the flush before each tool call fixes the ordering where it goes wrong, and the one trade-off (text kept when the steer is requeued) is stated and can be reverted. Notes
[DESIGN-REVIEWED] e5db15d Description read[DESCRIPTION-READ] b31623a84c5fe8720c968437eeae6a96848ba8e63779c8f363eb6f5ff75a2946 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
11d1a0e to
9b3b2e1
Compare
|
span=db37e66c9e96
|
|
span=6dd7854a8bdf
|
After a quiet end, text that arrives while a person's steer is pending is held until the backend echoes the steer's consumption (codex does that only at the terminal). Tool rows after that text rendered live, so the released text was replayed after all of them and the saved transcript was out of order. The text held so far now goes out just before the next tool call, so the transcript keeps the model's order and every tool event still runs live. Text written before a tool call is the model's work, so it is kept even if the echo never comes; only text with no tool call after it stays held and is dropped then. Refs #32396
9b3b2e1 to
e5db15d
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (5 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: held steer text is released before the next tool call so the transcript keeps model order. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/session.md.
After a quiet end, text that arrives while a person's steer is pending is held until the backend echoes the steer's consumption (codex does that only at the terminal). Tool rows after that text rendered live, so the released text was replayed after all of them and the saved transcript was out of order. The text held so far now goes out just before the next tool call, so the transcript keeps the model's order and every tool event still runs live. Text written before a tool call is the model's work, so it is kept even if the echo never comes; only text with no tool call after it stays held and is dropped then. Refs #32396 (cherry picked from commit 9777445)
Problem / Motivation
Goal: After a quiet end, a reply held for a person's pending steer keeps its text and tool rows in the order the model produced them.
#32396 holds text that arrives after a
nothing_to_doquiet end while a person's steer is pending, and releases it when the backend echoes the steer's consumption. Codex sends that echo only at the terminal. Tool calls after the held text still rendered live, so at the end the held text was replayed after all of them: text, tool, text was shown and saved as tool, then one merged text row.Found by Opus on the 0.12.1 port #32653; the same code is on main.
Why it matters
The saved transcript reads in the wrong order: the reply's opening line lands after the tools it introduced, and two text segments merge into one row. Later turns read that order back as context.
Not a goal
What changed (motivation → approach → change)
Symptom: with a steer pending after a quiet end, text, tool, text ends as tool, merged text.
Cause: held text was released only at the steer's echo, while the tool rows after it rendered at once.
Change:
chat_runner._run_chat: before a tool call renders,_release_held_text(turn, before_tool=True)sends the text held so far. Every tool event still runs live, as on main._release_held_texttakesbefore_tool, and lifts the drop only for its own replay, so later text is held again until the next tool call or the echo.docs/system-specs/modules/session.mdand theturn_entrycomment say so.Known trade-off. Text the model writes before a tool call is its work in practice, not the backend's placeholder (which ends the turn with no tool call), so it goes out with that call even if the echo never comes. In the rare turn whose steer is never echoed and is requeued, the text written before a tool call is kept: a narrow return of #32396's case. Text with no tool call after it is still held and dropped, so #32396's placeholder case is unchanged.
Holding the tool events behind the text instead (an earlier head of this PR) was dropped: it delays live bookkeeping (repeat-loop steering, the coding ledger, PreToolUse hooks, question cards) and loses the rows of tools that ran when the turn is stopped or the process dies. Re-inserting held text at its old position needs a new transcript insert path; both are larger than this fix.
Backwards compatibility
Compatible: with no held text nothing changes. A pending steer's text is now shown before its tool call instead of at the echo; the text after the last tool call behaves as before.
Removes nothing.
Tests
test_nothing_to_do_directive.py::test_a_reply_to_a_steer_keeps_its_text_and_tool_rows_in_order, text, tool, text after a quiet end with a pending steer:[before_reply](kiro-cli echoes first) and[at_terminal](codex):Let me look., thereadtool row,Found it., in that order.[none](cancelled, no echo):Let me look.and thereadtool row are kept,Found it.is dropped.[at_terminal]and[none]go red with the flush before the tool call removed.test_text_held_for_a_requeued_steer_is_dropped(fix: drop post-quiet-end text held for a steer the turn requeues #32396's placeholder case, no tool call) still passes unchanged.test_nothing_to_do_directive.py(all 53), thetest_*steer*.pyfiles,test_chat_runner_composition*.pyandtest_chat_runner_coverage*.py: 1903 passed. The 2 failures, intest_folder_steering_provider_dedup.py, fail the same way on main.Manual verification
Not run against a live codex backend; the event order is driven through the turn runner in the tests above.
Related Issues
Follow-up to #32396; found on its release port #32653.
Sibling sweep
Swept: git grep -n "_held_after_terminal" -- src/
Siblings: none --
_on_text_chunkis the only writer of held text and_release_held_textits only reader; a tool call is the one event that renders a row between two text segmentsPattern harvest
Not generalizable: the flush is specific to the post-quiet-end steer path.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.