Skip to content

fix(chat): send held steer text before the next tool call - #32826

Merged
buluoray merged 1 commit into
mainfrom
crew/slack/fix-held-steer-order
Nov 8, 2026
Merged

buluoray merged 1 commit into
mainfrom
crew/slack/fix-held-steer-order

Conversation

@buluoray

@buluoray buluoray commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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_do quiet 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_text takes before_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.md and the turn_entry comment 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., the read tool row, Found it., in that order.
    • [none] (cancelled, no echo): Let me look. and the read tool 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), the test_*steer*.py files, test_chat_runner_composition*.py and test_chat_runner_coverage*.py: 1903 passed. The 2 failures, in test_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_chunk is the only writer of held text and _release_held_text its only reader; a tool call is the one event that renders a row between two text segments

Pattern harvest

Not generalizable: the flush is specific to the post-quiet-end steer path.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 8, 2026 01:22
@buluoray
buluoray requested a review from Zedmor November 8, 2026 01:22
@buluoray
buluoray enabled auto-merge (squash) November 8, 2026 01:22
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision e5db15dc5bd4ac946d269e89cd13f129618f8694 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e5db15dc5bd4ac946d269e89cd13f129618f8694 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 2 — inherited: until now, held text was dropped whenever the steer was requeued. The change rests only on the description's unverified claim that "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)". Nothing pins that claim: the new [none] case asserts the new behaviour instead of showing that a placeholder never comes before a tool call.

What this change ships

Inventory (5 items) — 4 justified

Intent: after a quiet end with a steer pending, the saved reply keeps text and tool rows in the order the model produced them. FIX.

  1. Held text now shows before the next tool row, not merged after every tool at the echo — justified
  2. Text written before a tool call is now kept when the steer is never echoed and is requeued — inherited
  3. When the echo comes, text after the last tool call stays held until it, as before — justified
  4. _release_held_text gains a before_tool flag and _on_text_chunk a released flag; each has one caller — justified
  5. The session spec and the turn_entry comment describe the flush before a tool call — justified

[FIRST-PRINCIPLES-REVIEWED] e5db15d

Description read

[DESCRIPTION-READ] 498df3108603062160745105d1e1db2afc5e473d98777084184550d3bc224f99

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of e5db15dc5bd4ac946d269e89cd13f129618f8694 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • When a steer is never echoed and is requeued, the text written before a tool call is now kept, and the requeued turn answers the same steer again. That can give two partial answers in the transcript. Tool rows were already kept live in this case on main, so the change is consistent with main and easy to revert, but a later turn reading the transcript sees both answers.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed e5db15dc5bd4ac946d269e89cd13f129618f8694 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e5db15d

Verdict parsed from the review's SHA-scoped output markers for commit e5db15dc5bd4ac946d269e89cd13f129618f8694.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e5db15dc5bd4ac946d269e89cd13f129618f8694 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of e5db15dc5bd4ac946d269e89cd13f129618f8694 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e5db15d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e5db15dc5bd4ac946d269e89cd13f129618f8694 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@buluoray buluoray changed the title fix(chat): keep tool rows in order behind text held for a steer fix(chat): send held steer text before the next tool call Nov 8, 2026
@buluoray
buluoray force-pushed the crew/slack/fix-held-steer-order branch from 11d1a0e to 9b3b2e1 Compare November 8, 2026 01:47
@buluoray

buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

span=db37e66c9e96

  • Drain held tool events on exceptional exits

fixed in 9b3b2e1 by removing the cause: tool events are no longer held at all. Every tool call, update and result runs live as on main, so a cancel or an error exit has nothing held to drain. The text held for the pending steer now goes out just before the next tool call (_release_held_text(turn, before_tool=True)), which keeps the transcript in the model's order.
Pinned by test_a_reply_to_a_steer_keeps_its_text_and_tool_rows_in_order[before_reply|at_terminal|none]; the known trade-off (text before a tool call is kept when the steer is never echoed) is stated in the PR body.

@buluoray

buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

span=6dd7854a8bdf

  • Held tool events delay live bookkeeping and are lost on Stop or a crash

fixed in 9b3b2e1 by dropping the hold: tool events run live again exactly as on main, so the repeat-loop detector, the pending-tool and coding ledgers, PreToolUse hooks and question cards act when the call arrives, and a Stop or process death loses no tool row. Order is kept the other way round: the text held for the pending steer goes out just before the next tool call (_release_held_text(turn, before_tool=True)).
Pinned by test_a_reply_to_a_steer_keeps_its_text_and_tool_rows_in_order[before_reply|at_terminal|none]. Splitting the tool handlers into state and render halves was considered and not taken: it is a large change to a busy path for an ordering bug.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 8, 2026
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
@buluoray
buluoray force-pushed the crew/slack/fix-held-steer-order branch from 9b3b2e1 to e5db15d Compare November 8, 2026 02:16
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 8, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@buluoray
buluoray merged commit 9777445 into main Nov 8, 2026
98 of 99 checks passed
@buluoray
buluoray deleted the crew/slack/fix-held-steer-order branch November 8, 2026 03:09
buluoray added a commit that referenced this pull request Nov 8, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants