Repository navigation
fix(chat): cut the reply at a permission request only where a row lands - #23919
Conversation
1fa69f7 to
a6a934c
Compare
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. A cut that waits until a row actually lands goes after the root cause: the old code cut before knowing whether any row would follow. The change is backend-only and easy to revert. Notes
[DESIGN-REVIEWED] 8e28b19 Description read[DESCRIPTION-READ] 735954ecf9cb3f027af1c2627826657588a9fb60c4c0de8054670d461ccbab9a 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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix works at the mechanism: the cut now happens where a row actually lands, not before the decision. The author checked all four other cut sites and none has the same defect. What this change shipsInventory (5 items) — 5 justifiedIntent: a Codex reply stays one saved and displayed message even when sub-agent approvals arrive mid-stream. This is a FIX (#23918).
[FIRST-PRINCIPLES-REVIEWED] 8e28b19 Description read[DESCRIPTION-READ] c03b841b315e04d20ed2f6b78cbe3c6bec455de606ad4fc682ffd688c934206f That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
a6a934c to
d82d8ea
Compare
|
note (non-blocking): agreed, no change.
|
|
note (non-blocking): agreed, no change.
|
|
chore: d82d8ea fixes the Backend Tests (3.12, 3) red. test_a_name_a_closure_writes_is_never_held_under_its_own_name flagged _pay_permission_cut writing turn._turn_flushed_visible_text directly; it now binds the local and copies it onto the turn, the form every other phase uses. No behaviour change. The plumbing, owed-cut, segment-cut, permission-floor and composition-contract tests pass locally, 323 in all. |
d82d8ea to
84206ce
Compare
|
chore: rebased on main as 84206ce, no behaviour change. On d82d8ea the only red was Security Scope Review: its generate job's Checkout base step hung for 35 minutes and the lane posted no verdict (run 40165986368). Main had moved 61 commits in the same directories, so this rebase re-runs CI on today's base. The permission, segment-cut, plumbing, steer and composition-contract tests pass locally on the rebased head, 443 in all. |
|
note: Backend Tests (3.12, 2) is red again on 741bb44 with test_two_concurrent_releases_each_prune_their_own_view, the main flake tracked in #23965 (assigned, recorded there twice for this PR). This diff touches no skill-projection code and every other check on the head is green. No further retrigger from this side; the PR waits for the #23965 fix and is rebased onto it when it lands. |
741bb44 to
e3eb78f
Compare
|
chore: rebased onto main as e3eb78f, which now carries the #23965 fix (#24142), no behaviour change. The only red on 741bb44 was that flake in Backend Tests (3.12, 2), plus the Coverage Gate that failed because of it. The permission, segment-cut, plumbing, steer and skill-projection tests pass on the rebased head, 463 in all. |
e3eb78f to
5a7955a
Compare
|
chore: rebased onto main as 5a7955a, no behaviour change. On e3eb78f, Backend Tests (3.12, 5) failed on test_pruning_removes_from_the_seam_and_leaves_local_files_alone. That test fails 3/3 on that head and passes on main since #24191 pinned its prune clock; this PR touches no memory code. Coverage Gate failed only because shard 5 did, and the Automated Rule Check was cancelled at its 10-minute job timeout, so this push re-runs it. The permission, segment-cut, plumbing, steer and memory-file tests pass on the rebased head, 415 in all. |
5a7955a to
8e28b19
Compare
|
chore: 8e28b19 is a same-tree retrigger of 5a7955a, no code change. On that head all eight backend shards passed, but the fork GPT 6.1, Opus 5.5, Internal Content Scan and Security Scope lanes stopped at 06:03Z with 'API rate limit exceeded for installation' in their PR-resolve step (lane run 40277611077), so none produced a verdict. Main has moved in no file this PR touches. |
|
note (non-blocking): agreed, no change.
|
|
note (non-blocking): agreed, no change.
|
iamwhatever
left a comment
There was a problem hiding this comment.
Approve. Reviewed 8e28b19e17886665382f6667b9940be02963c469.
The fix goes after the cause: the permission handler used to cut the reply before knowing whether any row would follow. Now _on_permission_request arms an owed cut. append pays it before the first durable row, the interactive-card path pays it before drawing the card, a silent grant drops it, and any other flush clears it. The decision body is unchanged apart from the moved cut: every approve_tool call, hook, trust read and return value is the same, and the permission-floor pin keeps its count of 6 under the new name. The new tests cover silent grants under YOLO and session trust, plus the boundaries that must still split. AI lanes are PASS or no findings, the Design note is answered, checks are green on this head, and there are no change requests.
— crew-pr-reviewer (r127)
Problem / Motivation
Goal: A Codex reply is saved and shown as one message, even when the model's sub-agents ask for approvals while it is writing.
One assistant message from a Codex session was saved as several assistant rows with nothing between them. The splits landed mid-sentence, inside bold text and inside a diff hunk. After a reload the last row could show as the reply on its own, starting mid-word. The rows joined back together equal the model's message exactly, so no text was lost.
Why it matters
Anyone running Codex with sub-agents in a mode where Codex asks before running commands, on a YOLO or trusted chat, gets broken replies. Bold and code render wrong across the cut, and the collapsed view shows the tail of the answer without the explanation before it.
Not a goal
What changed (motivation → approach → change)
Codex sends a sub-agent's
session/request_permissionon the parent session while the parent's message is still streaming. A capture of codex-acp 2.2.2 with codex 0.164 showed three of these inside one message, each with a tool call id notool_callframe announced._on_permission_requestcut the segment before deciding the request. A grant that appends no row (YOLO, session trust, a native crew) still ended the segment, so the text after it became a new row.The cut is now owed rather than made.
_on_permission_requestarms it on the slot and runs the decision, now_decide_permission_request.slot.appendpays the cut before the first durable row that decision lands, and the interactive card gets it before it is drawn. A request answered with no row drops it, and the reply keeps streaming into the same segment. Any other segment flush, such as a send cutting the reply while the decision waits, clears the owed cut first, so the text is saved once.Backwards compatibility
Compatible: every permission request that lands a row still cuts before it, and the transcript format is unchanged.
Removes nothing: the change adds one slot field and defers an existing cut; no row, key or path is taken away.
Tests
test/test_permission_cut_owed.pystreams a synthetic message with bold text, a bare diff hunk and a JSON string, split at random points over 12 seeds, under YOLO and session trust. Up to three unannounced approval requests are interleaved, some followed by a tool-call update. Each case asserts one saved assistant row equal to the whole message, a reload window holding only that row, and one crew-log copy. Two tests keep the real boundaries: an approval card after prose and a tool call inside the reply still split the reply around their rows. A unit test checksappendpays an owed cut before a durable row and never before a chunk row. Another flushes the segment the way a send cut does while a cut is owed and checks the text is saved once, above the send's row.test_state_parts_facade.pypins the new slot field's default.test_transport_permission_floor.pyrenames the reviewed approval caller to_decide_permission_request; its sixapprove_toolcalls and their identity gate are unchanged.Proof: PROVEN test/test_permission_cut_owed.py (head 1fa69f7)
Manual verification
A live capture against codex-acp 2.2.2 over stdio with codex 0.164.0.751, multi-agent, read-only mode, confirmed the frame shape the tests replay. In codex-acp's default agent mode Codex approves commands itself and sends no permission requests, so the split does not occur there.
Related Issues
Closes #23918
Sibling sweep
Swept: git grep -n "_cut_segment(|_steer_segment_cut|_flush_segment(" -- src/kiro_crew/dashboard
Sibling: src/kiro_crew/dashboard/chat_turn/tool_rows.py -- not affected -- the tool-call cut is always followed by the tool row it appends
Sibling: src/kiro_crew/dashboard/chat_turn/stream_chunks.py -- not affected -- it cuts only after a tool group whose rows already sit between the segments
Sibling: src/kiro_crew/dashboard/responsive_chat.py -- not affected -- its cut is followed by the waiting send's user row
Sibling: src/kiro_crew/dashboard/chat_delivery.py -- not affected -- the steer cut is followed by the steer's user row
Pattern harvest
Rule candidate: review-prompt
Pattern: a display cut made before the decision that may add nothing to display
Checklist