Skip to content

fix(acp): identify a todo_list result by its cached call name - #11922

Merged
bolichen97 merged 1 commit into
mainfrom
fix/todo-snapshot-tool-identity
Sep 19, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/todo-snapshot-tool-identity

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

An agent's task list never shows up. The task panel above the chat composer stays
empty for a whole session, and the crew log has no plan/updated entry for any
todo_list call.

Observed live on 2026-09-18 (gateway 1ae8f6ee48, kiro-cli 2.22.1,
KIROCREW_CREW_LOG=1): two todo_list calls in one session, create then
complete. The log carries tool/called and tool/completed for both (seq
277/278 and 346/347) and zero plan/updated. No warning anywhere, because
nothing was dropped downstream: the event was never produced.

Why it matters

Every todo_list call is silent, on every session, for both consumers at once. A
user watching the panel sees an agent that never plans; a reader of the crew log
sees a session with no plan in it. The tool call itself renders normally, so
nothing looks broken.

What changed (motivation -> approach -> change)

Where it died Why Change
the parse the result frame was asked for a name it does not carry read the name the call frame cached for the same call id
the provider copy todo was not in the copied field list forward it, and drop the false allowlist entry
a subagent's list a child's result frame is untagged like every result frame carry the call id, and drop a child's

kiro-cli splits one tool call over two frames. The tool_call frame carries the
identity in _meta.kiro.toolName; the tool_call_update frame carries the
result in rawOutput and no _meta at all. The captured corpus shows
exactly that: in test/fixtures/acp_frames/kiro/session.jsonl the one
tool_call frame has _meta.kiro.toolName, and both tool_call_update frames
have no _meta key.

parse_todo_snapshot in src/kiro_crew/acp/_dispatch.py read _meta from the
result frame, the only frame it sees, so it answered "" and dropped the
snapshot. It now falls back to the name the preceding tool_call cached under
this call id, read through scoped_tool_cache_key so the entry stays bound to
the session that wrote it. A frame that does assert a name is still believed as
it stands.

Two more drops sat behind that one, so fixing the parse alone changed nothing a
user could see. AcpProvider._to_llm_event in src/kiro_crew/providers/acp.py
rebuilds each event from an explicit field list and todo was not on it, so the
snapshot arrived at chat_runner as None and cleared the panel instead of
filling it. A structural guard exists for exactly that class, and it was
disarmed by an allowlist entry whose stated reason (that chat_runner does not
read the field) was false.

The third is the one this PR's own premise creates. A native subagent's
tool_call is flat-mirrored with _meta.kiro.agentSubtaskId and parsed for its
caches under the PARENT scope, but its result frame carries no _meta, so it has
no subtask tag either and falls through to the parent's own parse. The new
fallback would resolve it there and hand a child's task list to the parent as the
parent's plan. So the todo event now carries its call id, and
src/kiro_crew/acp/session_handle.py records the call id of every tagged native
child and drops a todo event belonging to one. Ownership is a standing fact, not
a token spent on first use: one tool_call can be followed by several
tool_call_update frames, and the per-turn clear beside the sibling per-call
caches is what bounds the record.

.github/black-baseline.txt loses one line, because the reformatted test file is
now black-clean and the gate requires graduated entries pruned.

Backwards compatibility

Compatible: the two new parse_todo_snapshot parameters are optional and default
to no cache, the todo event gains a field rather than losing one, and the
provider copy forwards one more field. The parse only widens what is recognised.
The one event now dropped is a native child's todo result, which no build has
ever emitted as a parent event.

Tests

test/test_todo_list_surface.py is rewritten onto the real two-frame shape; its
hand-built frame put _meta on the result, a shape no kiro-cli sends, which is
why the file stayed green while the parse was broken for every real call.
TestTwoFrameDispatch feeds the real tool_call then tool_call_update through
parse_session_update with one dispatcher's caches and asserts exactly one
EVENT_TODO_UPDATE carrying the task text, under a cache_scope as well as
without one; a result frame whose call frame the dispatcher never saw must stay
unidentified. The cache is read for this call id only and only under the scoped
key. A frame asserting fs_read stays a non-match even with todo_list cached.
Every prior intent is kept: title prose alone never identifies the tool, an empty
list is a snapshot rather than a non-match, task text is capped and
credential-redacted.

test/test_acp_provider.py adds test_to_llm_event_preserves_todo_snapshot and
empties the intentionally-dropped allowlist, so the existing parity guard now
covers every field.

test/test_kas_subagent_progress.py adds
test_child_todo_result_cannot_replace_parent_todo: a tagged child tool_call
then its untagged result emits no EVENT_TODO_UPDATE, a repeat of that result
frame emits none either, and the parent's own two frames still emit exactly one
with the parent's tasks. That last assertion is what stops the guard from
silently reverting the fix.

test/acp_frame_replay_harness.py passes the name cache the way production does,
so test_acp_frame_replay.py covers the change over the captured corpus.

Mutation, on head f823392eda, one fix at a time:

  • drop the cached-name fallback: 13 tests red, TestTwoFrameDispatch::test_call_then_result_emits_todo_update with assert 0 == 1
  • drop todo=e.todo: test_to_llm_event_preserves_todo_snapshot red with assert None == {'description': 'Repair provider boundary', ...}
  • drop the child-ownership record: test_child_todo_result_cannot_replace_parent_todo red with assert [AcpEvent(...)] == []
  • make the ownership record one-shot again: the same test red on the repeat frame

All restored: 178 passed across the five files.

Manual verification

N/A -- the dispatch tests replay the wire order and frame shapes a live session
sends, and the frame shape is read off the captured corpus rather than asserted:
test/fixtures/acp_frames/kiro/session.jsonl has _meta on its tool_call
frame and none on either tool_call_update.

Related Issues

Fixes #11915

Pattern harvest

Rule candidate: review-prompt
Pattern: an identity is read from a terminal frame that only its opening frame
carries, and the miss reads as "not my tool" rather than as an error -- including
the second-order form where a field-parity allowlist keeps excusing the drop on a
justification that has since become false.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

@chenmingwei23
chenmingwei23 requested review from a team and hoang-phan98 September 19, 2026 00:43
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 19, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Intent: Make a live todo_list call reach its two consumers again -- the dashboard task panel and the crew log plan/updated entry -- by identifying the result frame from the name its own tool_call frame cached, since kiro-cli puts _meta on the call frame alone.

Not a goal: any change to the crew log emitter or to dashboard/chat_runner.py; any new identity source beyond the cache the dispatcher already fills; any rework of how todo_list payloads are normalised.

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of f823392eda48fbccdd143b7d452b901632f95a0f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the child-ownership record only needs the KAS gate — a kiro-backend frame carrying agentSubtaskId would reach the fallback with no drop guard.

[DESIGN-REVIEWED] f823392

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of f823392eda48fbccdd143b7d452b901632f95a0f — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify the child-ownership guard's KAS-only scope: no other backend flat-mirrors child tool frames whose cached name the new fallback would now resolve.

Not justified as shipped

  • Item 5 — rides along: the black-baseline prune is not the fix; it is the gate-mandated companion of the reformatted test file.

What this change ships

Inventory (6 items) — 5 justified

Intent: FIX — make an agent's todo_list results reach the task panel and the crew log, which every live call misses today (fixes #11915; the base fixture test/fixtures/acp_frames/kiro/session.jsonl confirms result frames carry no _meta).

  1. A live agent's task list now fills the panel and logs plan/updated — justified
  2. The provider stream forwards the todo snapshot; the allowlist entry excusing the drop is deleted — justified
  3. A subagent's todo result can no longer replace the parent's plan — justified
  4. Todo events carry their tool call id (one consumer, the child filter, non-generalized) — justified
  5. One line pruned from .github/black-baseline.txt — rides along
  6. The todo tests replay the real two-frame wire shape instead of an invented single frame — justified

Pin deletions are declared with checkable evidence: the removed allowlist reason ("chat_runner does not inspect it") is contradicted on base by src/kiro_crew/dashboard/chat_runner.py:12826, and the removed test fixture shape by the captured corpus. Sibling count: _kiro_tool_name has exactly one production call site (src/kiro_crew/acp/_dispatch.py:2283, the fixed one); no unfixed siblings. event.todo consumer count: 1 (chat_runner.py:12826).

[FIRST-PRINCIPLES-REVIEWED] f823392

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

The change is a coherent, well-scoped bug fix with matching tests. I traced the child-id set write/read scoping, the filter loop's interaction with the stat branches (a todo_update event matches none of them, so skipping is inert), the two-frame parse fallback, and the _to_llm_event forwarding. No grounded defect survives falsification, and I found no new one to ground at the 80+ bar.

No findings.

[OPUS-REVIEWED] f823392

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable f823392eda48fbccdd143b7d452b901632f95a0f: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 5.6 flagged blocking issues on f823392eda48fbccdd143b7d452b901632f95a0f; Opus 4.8 adjudication downgraded every one of them to advisory. Adjudication downgraded all 1 blocking finding(s) to advisory: the remedy each one requires is disproportionate to the harm it prevents. Read them as advice, not as merge conditions.

This comment is updated in place on each push.

Review details

BLOCKING -- src/kiro_crew/acp/session_handle.py:4795 -- child call-ID retention has no count bound

self._native_child_tool_call_ids.add(scoped_tool_cache_key(...))
Distinct KAS child tool calls -> _handle_update retains every ID until turn reset -> gateway memory grows without a bound.
Anchor: a-bound-bounds-every-field-it-retains
Fix: Bound ID length and set count at insertion, count/log overflow, and fail closed for unrecorded child results.
[BLOCK-MERGE-DOWNGRADED] f823392
[GPT-REVIEWED] f823392

Adjudication (Opus 4.8) — is blocking on each finding proportionate?

F1 — I opened session_handle.py:4795 (the .add) and traced its lifecycle.

  • The set is added to only on the KAS backend for child tool frames (session_handle.py:4787–4795), and is .clear()ed on every turn reset (session_handle.py:1226), right beside the sibling per-call caches (_tool_call_inputs, _tool_call_raw_params, etc.) that already retain far larger per-call data with the identical per-turn lifecycle.
  • So growth is bounded by the number of distinct child tool calls in a single turn, and self-corrects on the next turn reset (session_handle.py:1226) — recovery path named. It is not "without a bound"; it is bounded exactly as the co-located caches are, and holds only ID strings, a strictly smaller footprint than what those caches already hold in the same window.
  • Harm rung: LOW — a per-turn-bounded, self-clearing in-memory set. The proposed fix (per-insertion length+count caps, overflow counting/logging, and a new fail-closed contract for unrecorded child results on the hot _handle_update path) adds new state, new branches and a new ordering invariant whose permanent maintenance load clearly exceeds the harm prevented.

[ADJUDICATION] f823392 total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/acp/session_handle.py:4795 reason=disproportionate-remedy
[GPT-ADJUDICATED] f823392

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f823392eda48fbccdd143b7d452b901632f95a0f: <one-sentence reason>

@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 Sep 19, 2026
kiro-cli puts _meta.kiro.toolName on the tool_call frame alone. The
tool_call_update frame that carries rawOutput has no _meta at all, so
parse_todo_snapshot asked the result frame for an identity it never
holds and dropped every live todo_list snapshot.

Fall back to the name the preceding tool_call cached under this call id,
read through scoped_tool_cache_key so the entry stays origin-bound. A
frame that does assert an identity is still believed as it stands.

Two more drops sat on the same path. AcpProvider._to_llm_event rebuilt
the event without todo, so the snapshot died at the provider boundary
and chat_runner cleared the panel instead of filling it; the parity
allowlist excused that with a reason that was false. And because the
result frame carries no _meta, a native subagent's own todo result has
no agentSubtaskId either, so it fell through to the parent-scope parse
and the new fallback let a child's list overwrite the parent's plan.
The todo event now carries its call id and the handle drops one whose
call id belongs to a tagged native child.

Fixes #11915
@chenmingwei23
chenmingwei23 force-pushed the fix/todo-snapshot-tool-identity branch from eda93c4 to f823392 Compare September 19, 2026 01:33
@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 Sep 19, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the todo event now carries its call id, and the handle drops one whose call id belongs to a tagged native child; ownership is recorded per call id and cleared per turn.

  • span=119f3295ea64 child todo snapshots overwrite the parent plan -- fixed in f823392eda.

Verified reachable, and this PR's own premise is the proof, so not a false
positive. A tagged native child's tool_call is parsed for its caches under
the PARENT scope at session_handle.py:4791-4801, and because a result frame
carries no _meta at all it has no agentSubtaskId either, so it falls through
to the parent's own parse at :4814 where the new fallback resolves it.
Fixed as prescribed: _dispatch.py sets tool_call_id on the
EVENT_TODO_UPDATE it emits, and session_handle.py records the call id of
every tagged native child and drops a todo event belonging to one.
Ownership is a standing fact, not a token spent on first use: one tool_call
can be followed by several tool_call_update frames, so the record is not
consumed on match; the per-turn clear beside the sibling per-call caches bounds
it. test_child_todo_result_cannot_replace_parent_todo pins both the child
drop and the repeat frame, and asserts the PARENT's own two frames still emit
exactly one snapshot so the guard cannot silently revert the fix.
Mutation: removing the ownership record reds it with assert [AcpEvent(...)] == []; making the record one-shot reds it on the repeat frame.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none added for this item; no shared helper introduced.

  • span=694520c7d006 a single resolve_tool_name helper would stop a fourth consumer re-shipping this bug -- rebutted as disproportional for this PR, not as wrong.

The observation is correct: the permission event, the crew-log emitter and this
parse each recover a result frame's name from the call-frame cache.
It is disproportional here for a concrete reason, not a preference. The third
consumer lives in src/kiro_crew/crew_log/emit.py, and PR #11907 is actively
renaming that package; a shared helper now would have to edit a module moving
underneath it and would put this fix behind that merge. A fourth consumer is
hypothetical, and the three that exist are each already pinned by their own
test.
The helper is also a refactor of two call sites this PR does not otherwise
touch, so it would widen a data-loss fix into a cross-package extraction with
no failing case of its own.
Captured locally so it is re-judged on a clock rather than dropped. It is the
right shape once the rename lands and belongs in its own change, where the
permission path and the emitter can be moved together and reviewed as one.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/acp/session_handle.py, src/kiro_crew/acp/types.py, src/kiro_crew/acp/client.py, src/kiro_crew/acp/runtime.py, src/kiro_crew/acp/session_provider.py and .github/black-baseline.txt since this head went green (a170442 -> 7fe765f); CI re-running.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: _native_child_tool_call_ids, a per-call-id record of tagged native-child tool calls, cleared per turn beside the seven sibling per-call caches.

  • span=19934bb5ba3d child call-ID retention has no count bound -- rebutted as disproportional, and a count bound here would be a correctness regression.

The record is keyed by tool call id, not by child session, and it is cleared in
the same statement block as _tool_call_inputs,
_tool_call_input_redacted, _tool_call_is_shell, _tool_call_raw_params,
_tool_call_diff_path, _tool_call_mcp_server and _tool_call_tool_name
(session_handle.py:1218-1225). None of those seven carries a count bound
either, and every frame that grows this set grew all seven, because the tagged
child branch runs the shared parser for exactly those cache side effects
(:4791-4801). A set of short strings cannot be the binding constraint beside
seven dicts holding redacted command bytes for the same ids.
Bounding only this member would also reopen the data-loss hole it exists to
close: an evicted entry makes the child's next result frame indistinguishable
from the parent's, which is finding 119f3295ea64 again. An eviction policy on a
correctness guard trades a memory concern for a wrong outcome.
If per-turn per-call retention is a real class it is real for all eight members
and belongs in one change that bounds them together, not in a data-loss fix
that touches one.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none; the prune removes one line from .github/black-baseline.txt and adds nothing.

  • span=b4bc24185323 Item 5 rides along: the black-baseline prune is not the fix -- rebutted: the gate refuses the PR without it, so it is not separable.

Correct that the prune is not the fix, but it is not optional either, so it
cannot be split out. Reformatting test/test_todo_list_surface.py made it
black-clean, and scripts/check_black_formatting.py then exits 1 on this diff
with "1 baselined file(s) are now black-clean. Remove them so the baseline
keeps shrinking", naming that file. The gate is in the profile's blocking set,
so a PR that reformats a baselined file and leaves the entry is red.
Landing it separately is not available: the entry only becomes prunable once
the reformat exists, and the reformat is in this diff. A follow-up PR would
have to carry a red commit in between.
The body names it for that reason rather than folding it into the fix
narrative, and it is one deletion in a generated ratchet file, which only ever
tightens.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved after verification: PR Readiness success on this head, no active change requests or unresolved threads, mergeable against current main.

@bolichen97
bolichen97 merged commit 8acbbf3 into main Sep 19, 2026
86 checks passed
@bolichen97
bolichen97 deleted the fix/todo-snapshot-tool-identity branch September 19, 2026 05:02
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 19, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…tdev#11922)

kiro-cli puts _meta.kiro.toolName on the tool_call frame alone. The
tool_call_update frame that carries rawOutput has no _meta at all, so
parse_todo_snapshot asked the result frame for an identity it never
holds and dropped every live todo_list snapshot.

Fall back to the name the preceding tool_call cached under this call id,
read through scoped_tool_cache_key so the entry stays origin-bound. A
frame that does assert an identity is still believed as it stands.

Two more drops sat on the same path. AcpProvider._to_llm_event rebuilt
the event without todo, so the snapshot died at the provider boundary
and chat_runner cleared the panel instead of filling it; the parity
allowlist excused that with a reason that was false. And because the
result frame carries no _meta, a native subagent's own todo result has
no agentSubtaskId either, so it fell through to the parent-scope parse
and the new fallback let a child's list overwrite the parent's plan.
The todo event now carries its call id and the handle drops one whose
call id belongs to a tagged native child.

Fixes kirodotdev#11915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants