Repository navigation
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check one claim before merge: that claude-agent-acp 0.71.0 is the first version to honour What this change shipsInventory (8 items) — 8 justifiedIntent: when someone edits a message on the Claude backend, the model keeps everything it had up to that message, tool results included. The title says
[FIRST-PRINCIPLES-REVIEWED] 4afa26a Description read[DESCRIPTION-READ] 68950ef65d6ce945910bfe7a23ae2f66d65c9ceefde775f1715395a8a4fbc85f That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The fork point travels in claude-agent-acp's private Watch
Suggestions
[DESIGN-REVIEWED] 4afa26a Description read[DESCRIPTION-READ] 053df42a90c97441e7509640de43950fa04776e30adc143f607e144627ae388e 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 |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
d55d078 to
4140eda
Compare
|
The one red lane here, Backend Tests (Windows) (2), failed on Failing job: https://github.com/kirodotdev/KiroCrew/actions/runs/38025192715/job/114135649762 |
4140eda to
025dc2e
Compare
Edit + Send on the claude backend discarded the native session and primed a fresh one with the text replay, which carries no tool calls or tool results and stops at 80k characters. The claude adapter can fork a stored session up to a given assistant message, so the rewind now arms that fork at the retained prefix's last assistant message and the next cold start restores the fork like any resume. Anything that keeps the fork from running falls back to the replay. Closes kirodotdev#18298
025dc2e to
4afa26a
Compare
|
Thank you @rinbn for this fix and for the careful live adapter measurements. To get it through CI with repository secrets, it now lives in a same-repo replacement, #19871. That PR keeps your commit and authorship, rebased onto current |
Problem / Motivation
Goal: Editing a message on the Claude backend keeps the conversation the model had up to that message, tool results included, instead of shrinking it to a text replay.
Edit + Send (
POST /api/chat/slots/{slot}/rewind) on a Claude-backed session throws the native Claude Code conversation away. The replacement turn starts a new native session whose only view of the retained history is the text session replay: user and assistant text, at most 80k characters, no tool calls and no tool results. After an edit the model no longer knows anything it had only seen in tool output, such as file contents and command results, and on a long session most of the context is gone. Nothing tells the user.Why it matters
Every dashboard user on the Claude backend who edits a message loses context silently, and the loss grows with the session: a session holding a few hundred thousand tokens comes back with at most 80k characters of text, even when the edit is to the latest message and that message was stopped before any reply. The answers that follow are then built on a model that has forgotten the tool output earlier turns relied on.
Not a goal
edit-resend. The dashboard no longer calls it; it keeps today's discard and replay.session/fork, but not the fork-point key this uses.What changed (motivation → approach → change)
After this change, editing a message on the Claude backend leaves the model with its native conversation up to that message, tool calls and results included, instead of a text replay of at most 80k characters.
The rewind discarded the native session because that is the only boundary kiro-cli offers. claude-agent-acp can do better: it implements
session/forkwith a fork point, which calls the Agent SDK'sforkSession(sessionId, { upToMessageId }). That copies the stored transcript up to and including one assistant message into a new session and leaves the source untouched. So on Claude the rewind now forks instead:messageIdasAcpEvent.message_id(acp/types.py), read on both the direct-client and shared-runtime paths (acp/client.py,acp/_dispatch.py) and copied throughproviders/acp.py. Each assistant segment row stores it asmeta.native_message_id(dashboard/chat_runner.py,dashboard/state.py).dashboard/chat_rewind.py) takes the retained prefix's last assistant row, skipping runtime notices and wire-only rows (thedoneevery finished turn leaves in the live window), and storesnative_fork = {sid, message_id}on the session-map entry (session_map.py). Any write or clear of the entry'ssiddrops it, so a reset issued before the next turn wins.session_allocation.py) treats a pending fork like a resume: it stays off the warm pool, keeps the stored cwd, and refuses to run on a speculative start. It hands the fork to the Claude client and drops it from the map. A temporary or incognito session, which never restores native history, drops it without forking. The client sendssession/fork, then runssession/loadon the fork, so the turn takes the ordinary resumed path with no replay._meta.jetbrains.air.forkkey, and a fork that ignored it would copy the edited-away suffix too. So the client forks only for a backend in the newACP_BACKENDS_FORK_AT_MESSAGEset (claude;agent_sdk/backends.py, re-exported byacp_backends.py, classified off-card inagent_sdk/backend_cards.pyand listed inharness-onboarding.md), at or aboveCLAUDE_ACP_FORK_POINT_MIN_VERSION(0.71.0), and only when the handshake advertisedsessionCapabilities.fork. 0.70.0 advertises fork and copies the whole session; 0.71.0 cuts at the point (both measured, see Manual verification). The floor is checked with the existing_adapter_version_at_least.session/newplus replay, as before. The adapter answers-32602for an unknown fork point.Recorded frames from every adapter already carry
messageId, so the frame-replay snapshots gainmessage_idlines and nothing else.Backwards compatibility
Compatible: every new field (
AcpEvent.message_id, rowmeta.native_message_id, session-mapnative_fork) is optional and empty by default, and a row or entry without one takes today's replay path.Removes nothing: the change adds fields and a path that falls back to the existing behavior; no field, key, endpoint or check is removed or tightened.
Tests
test/test_rewind_native_fork.py:parse_message_idreads a chunk's id and rejects missing, non-string and over-long ones.native_forkthrough disk, and drops it onset, onclear_sid(even with no sid), and onclear_native_fork.session/forkwith the fork point and thensession/loadon the fork. Each of these starts fresh instead: a missing capability, an adapter below 0.71.0, a failed fork, and a non-Claude backend (DeepSeek advertising fork)._native_fork_pointover compaction, recycle and session-reload notices, a wire-onlydonerow, a trailing tool row, a trailing user row, a row with no id, and an empty prefix.donerow, which is the live window a finished turn leaves. It does not arm when the edited message is the first one.Other test changes:
test/fixtures/acp_frames/**/*.expected.jsonwere regenerated withscripts/update_acp_frame_snapshots.py; the only change is the addedmessage_idlines.test_post_compaction_continuation.pynow pins the notice flag on the forwarded chunk with a regex, so the extra keyword argument on thatyieldno longer breaks it.Manual verification
End to end on this build. A dev gateway from this branch (
KIROCREW_PROFILE=standalone, an emptyKIROCREW_HOMEwith onlyagent.acp_backend: claude, claude-agent-acp 0.87.0), driven through the dashboard API. Edit + Send went throughPOST /api/chat/slots/{slot}/rewindwith{ts, content}, the same call the UI makes.secret.txt… reply with exactly one word: done". The file saysZEBRA-4417. The reply wasdone, and the row carriedmeta.native_message_id.noted.at_message_index: 4, because the live window held turn 1'sdonerow.a=ZEBRA-4417; b=UNKNOWN. The text replay could not have produced (a): turn 1's only assistant text is "done".sidfrom0515ca67…to4c930cb0…, kept0515ca67…asdiscarded_sid, and droppednative_fork.tool_resultand no MAGENTA. The original transcript still holds turn 2, unchanged.[SESSION RESUMED …]header (9,147 chars), with no[SESSION CONTEXTreplay block. So the fork is not followed by a second, text copy of the history.The adapter, directly over ACP, outside Kiro Crew. Each probe used the same S1: turn 1 read
secret.txtwith the Read tool (contentZEBRA-9182, reply only "done"), turn 2 said "my favorite color is MAGENTA". S1 was then forked at turn 1'smessageIdand both sessions were asked without tools.forka=ZEBRA-9182; b=MAGENTAa=ZEBRA-9182; b=UNKNOWNa=ZEBRA-9182; b=UNKNOWNOn every version S1 itself answered
a=ZEBRA-9182; b=MAGENTA, and its transcript was unchanged by the fork. An unknown fork point on 0.87.0 returned-32602 Invalid params: Fork point message ... was not found. Grepping the published npm tarballs agrees with the table:_meta.jetbrains.air.forkfirst appears in 0.71.0 (dist/fork-session.js); 0.70.0 and earlier have only a whole-session fork. That is whereCLAUDE_ACP_FORK_POINT_MIN_VERSIONcomes from.Related Issues
Closes #18298
Related: #14512, #8067, #5395.
Pattern harvest
Not generalizable: the loss came from one endpoint using the only boundary kiro-cli offers on every backend, not from a code shape that recurs elsewhere.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)