Repository navigation
Conversation
8e2c334 to
8cd6bf7
Compare
8cd6bf7 to
cf559e1
Compare
On the claude backend a turn Claude Code starts on its own now shows on time (kirodotdev#30092), but as ordinary rows in the previous user turn's group: nothing says the agent spoke unprompted, and its tool rows read as part of the earlier answer. Only its assistant rows were marked, so a turn that ran tools and wrote no reply was not marked at all. The turn's first row, whatever its role, now carries meta.origin {kind: agent, turn_start: true}. The turn owes that meta to its slot when it opens its stream, and the next durable row append writes takes it; a turn that wrote no row drops it when its stream closes. The chat page grouper and the pane's ChatMessageList start the agent turn's own group at that row, and TurnBlock heads the group with a "Started by the agent" label above its tool rows and its reply. Regenerate's refusal now also covers a turn that wrote only tool rows. Kiro and the other backends write no such row. Refs kirodotdev#17566
kirodotdev#38313's request-wait test predates turn_start; the reply is that turn's only row, so it carries the opener origin.
cf559e1 to
ecb761d
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the turn's first row is marked through the slot's one Notes
[DESIGN-REVIEWED] ecb761d Description read[DESCRIPTION-READ] 3a165a09c3452a088e4e63e759ee6bdef28ab7010286f4764738bf7ead86fab2 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 |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS This lane has no blind read: a first-time reader has not seen the "Started by the agent" label, which the committed screenshots (dark and light, reply turn and tool-only turn) do show. Pushing the branch to this repository runs the blind read. Notes
[UX-REVIEWED] ecb761d Description read[DESCRIPTION-READ] ec855f269a954d0b9749608a64d670afbba44ef1dea6e7f8b5e664d83afbad85 That sha256 names everything this verdict read: the PR description, plus the 9 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 Every item traces back to the accepted Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: on the claude backend, a turn the agent starts on its own reads as its own labelled group, not as more rows of the previous answer. ADDITION, covered by the RFC (§ "only visible addition" label, Phase 2 frame).
[FIRST-PRINCIPLES-REVIEWED] ecb761d Description read[DESCRIPTION-READ] 41659957504b96b03138ff2bb8882a5ad27a4995ca706546683277f2e75cf284 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — 🔴 changes requested (blocking)Reviewed Adjudication upheld 1 of 1 blocking finding(s); those must be resolved before merging. BLOCKING -- src/kiro_crew/dashboard/state_parts/slot_transcript.py:332 -- Permission-first turns lose their boundary on refresh and resume
[BLOCK-MERGE] ecb761d Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 stays blocking: the harm is moderate and the real fix is about one line.
|
A permission or elicitation card is transient: it is never saved and a refresh rebuilds its meta, so a card-first turn lost its boundary on refresh and resume. The opener now skips _TRANSIENT_ROLES.
|
Rebased onto main (conflicts in the RFC status line and the |
|
Status on head ec67f87: every CI and Build job passes. PR Readiness stays pending because Issue Gate and the fork AI-review lanes (GPT 6.1, Opus 5.5, Design, UX, First Principles, Security Scope, Internal Content Scan) never started on this head; their PR comments still show the older head ecb761d. A maintainer needs to retrigger those lanes on ec67f87 so the GPT fix (opener skips transient rows) is re-reviewed. |
Problem / Motivation
Goal: On the claude backend, a turn Claude Code starts on its own shows in the chat as its own group headed by "Started by the agent", instead of as more rows of the previous user turn.
Since #30092, a turn Claude Code starts on its own shows up on time: a
run_in_backgroundcommand finishes and the model answers, or a background or Workflow agent asks for a permission. But it renders as ordinary rows. The chat page and the chat pane group its tool rows and its reply with the user turn before it, so nothing tells the reader that the agent spoke unprompted, and the agent's tool calls read as part of the earlier answer. #30092 left the RFC's label out of scope. It also marked only the agent's assistant rows (meta.origin = {"kind": "agent"}), so a turn that ran tools and wrote no reply carried no mark the transcript could find.Why it matters
Anyone on the claude backend who starts background work reads the result in the wrong place. The agent's follow-up looks like more of the answer they already read, the tool rows it ran look like steps of that earlier answer, and nothing on screen says the agent acted without being asked. A turn that only ran a tool (for example, started the next background job) is the hardest case: it has no reply to point at.
Not a goal
reasonon the row. The transport reads it and does not hand it to the dashboard; exposing it is a transport change, left out here.claude, and any session the dashboard chat does not run (channel sessions, cron sessions, sub-agents). They write no such row, as on main.agent.agent_started_turnsalready turns the whole feature off.What changed (motivation → approach → change)
Design record: the RFC's section 3 and Phase 2 exit criteria (
docs/request-for-change/rfc-agent-started-turns.md, statuspartial). This builds on #30092's implementation.meta.origin = {"kind": "agent", "turn_start": true}. The transcript needs to know where the agent's turn starts, because the turn has no prompt row to open it, and the first row is the one row every turn that shows anything has. A tool-only turn has no assistant row and no footer row (turn_statsgoes on the reply row), so neither of those could carry the mark. The first row also arrives first, so the group and its label show while the turn is still running, not only at its end. The assistant rows keep feat(chat): show claude agent-started turns and their permission cards #30092's{"kind": "agent"}.slot._owed_turn_opener = agent_turn_opener_meta, inchat_runner.py). The slot'sappend(state_parts/slot_transcript.py) puts it on the next durable row it writes, after any segment cut a permission request owes (so the cut's text row is the first), and never on a user row or a wire-only row (chunk,streaming,done). A turn that wrote no row drops the owed meta when its stream closes (agent_started._close_agent_turn_stream), so the next unrelated row is never taken for the agent's. The row is persisted with the meta like any other, so a reload and a resumed session group it the same way. User turns and every other backend never set it.groupDisplayItems(the chat page) and app-sdkChatMessageList(the pane) start a new turn group at a row that opens an agent-started turn, flush the turn before it there, and mark the groupagentStarted. A marked group always wraps as a turn, a lone reply included, so it is always headed. The group runs to the next prompt row or the next agent turn's first row. The chat page shows permission requests in the approval bar rather than as rows, so when the opener is a permission row it opens the group at the next row it shows. The pane never lets a grouped reasoning or permission run span the start of an agent turn.TurnBlockdraws "Started by the agent" (a bot icon, muted text, a tooltip saying the agent answered on its own) as the first row of a marked turn, above its fold toggle, its tool rows and its reply. Theme tokens only, so light and dark both follow the theme. The two strings are inen.manual.json, all 11 translated catalogs and the regenerated pseudolocale.is_agent_started_rowreads any marked row, so Regenerate'sagent_started_replyrefusal now also covers a turn that wrote only tool rows after the newest user row, which a re-run would otherwise delete.claude-code-provider.md("A turn Claude Code starts on its own") describes the opener and the grouping;learn-cron-dashboard.md's owner row lists the new meta; the RFC's status note no longer says the label is unbuilt.Known limits, each by design or out of reach for the transcript:
Backwards compatibility
Breaking: Regenerate is refused with
agent_started_replywhen the rows after the newest user row include a turn the agent started that wrote only tool rows. Main accepted that request and the re-run deleted those rows. Writer sweep on origin/main @ b764e20:is_agent_started_rowhas one caller,chat_regenerate.py's refusal check;chat_runner.pyonly re-exports it. No other code reads a row'smeta.originas an agent mark.Reader: src/kiro_crew/dashboard/chat_regenerate.py:api_chat_slot_regenerate -- entry: chat --
test_regenerate_refuses_a_span_holding_a_reply_the_agent_started(new tool-only case)Tests
test/test_dashboard_agent_started_turn.py(backend, through_run_chat(_agent_started=True)):test_a_turn_of_only_tool_rows_is_marked_on_its_first_row: a turn that ran one tool and wrote no reply carries the opener on its tool row, in memory and in the saved transcript, and a row written after the turn carries none.test_only_the_turns_first_row_opens_it_and_its_reply_is_in_the_resume_replay: text, tool, text: only the first row carriesturn_start, the later reply keeps{"kind": "agent"}, the saved transcript keeps the opener, and the reply is in the session replay a resumed session gets.test_a_turn_that_wrote_no_row_leaves_no_opener_for_a_later_row: an empty turn drops the owed meta.test_the_first_durable_row_the_turn_writes_takes_the_opener: wire-only and user rows are skipped, and the row a permission's segment cut writes takes the opener before the permission row.test_regenerate_refuses_a_span_holding_a_reply_the_agent_startedgains a tool-only case.website/src/test/TurnBlock.agentStarted.test.tsx: in the chat page's grouping andTurnBlock, and in the pane'sChatMessageList, the order is label, tool-call toggle, tool row, reply, with the fold closed and open and exactly one label; a tool-only turn and a lone reply are headed too; a prompted turn draws no label.website/src/test/groupDisplayItems.test.ts: the agent turn's own group from its first row to the next prompt; a tool-only turn and a lone reply wrap; the rows before the opener stay with their turn even when that turn left no footer; a second agent turn starts at its own first row; a permission opener hands over to the next shown row; an agent reply with no opener groups as before; the running agent turn is the trailing turn.Each new backend test fails with its part of the fix removed (not setting the owed meta: 4 tests;
appendignoring it: 5; not dropping it at the turn's end: 1). WithTurnBlock's label removed, 6 of the 7 rendering tests fail; with the grouper never opening an agent turn, 9 tests fail.Results: the backend files around the change pass, 1,670 tests in 45 files at
-n 4(agent-started turn, state-parts facade and dashboard state, chat slot, transcript ordering and readers, permission cut, regenerate, approval, composition contract, slot readers, timeout consistency, bindings); the frontend setscripts/run_scoped_tests.py --surface frontendrelates to the diff passes, 14,259 tests in 519 files. After the last rebase onto main the agent-started turn, facade, composition and slot-reader suites (201 tests) and the two frontend files (62 tests) were run again and pass, as do tsc andi18n:check. flake8, isort, black (touched files),check_harness_parity.py, the black and subprocess-encoding ratchets,check_file_line_cap.py,docs-lint.sh, eslint,lint:i18n,lint:theme-colors,lint:phantom-classesandlint:restyle-ratchetpass. mypy reports two errors, both inapps/routes_registry.py, which this PR does not touch and main carries.Manual verification
The browser-harness frames below come from
website/scripts/capture-17566-agent-started-reply.mjs, which serveswebsite/capture/agent-started-reply.html(the chat pane with the real stylesheet, theme tokens and catalogs) from an in-process vite server on 127.0.0.1 and checks each frame: every "after" and "tool-only" frame draws exactly one label, above the turn's tool-call toggle; every "before" frame draws none. All six frames passed.Not run against a live claude-agent-acp in this PR: the marking is written by the same
appendevery row goes through, which the backend tests drive through the real runner.Screenshots / video
The chat pane with the same conversation: a background command, the turn the agent starts when it finishes, then "status?". After: the agent's turn is its own group, headed by "Started by the agent", then its "1 tool call" row and its reply. Before (main): the same rows with no label, under the earlier turn.
A turn that wrote only a tool row is headed the same way:
Tool-only dark, and before (main)
The images are committed under
temp-screenshots/17566-agent-started-reply/because this is a fork PR, which cannot use--attach.Related Issues
Part of #17566
Builds on #30092, which shows the turn; this adds the RFC's label and the turn's own group.
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.