Skip to content

feat(session): support kiro-cli v3 engine and Kiro workflows over ACP - #1609

Merged
chaodu-agent merged 11 commits into
mainfrom
feat/kiro-v3-support
Nov 24, 2026
Merged

chaodu-agent merged 11 commits into
mainfrom
feat/kiro-v3-support

Conversation

@chaodu-agent

@chaodu-agent chaodu-agent commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What problem does this solve?

kiro-cli 3.x has a second engine (--agent-engine=v3) that selects agents as ACP modes and adds Kiro workflows. Today openab cannot use either safely: an unknown mode silently leaves the session in the default vibe mode, workflows cannot be enabled, workflow step sessions leak text into the parent's reply, and the workflow summary that arrives after session/prompt returns ends up in the next reply.

Refs #1607

Review Contract

Goal

Let an operator run kiro-cli v3 and Kiro workflows through openab by configuration only, with all four changes from #1607 opt-in so existing v2 bots behave identically by default.

Non-goals

  • Connect, Helm charts, bot config gists, or a launcher that writes ~/.kiro/agents/*.md.
  • Answering questions a paused workflow step asks, or fixing the upstream kiro-cli issues named in docs/kiro-v3.md.
  • Applying session_new_meta or default_config_options on session/load resume.
  • Tying late text to a specific workflow, or relaying on the acp gateway platform.

Accepted Residual Risks

  • Resumed sessions (session/load) are not re-sent _meta or default_config_options. Unconfirmed whether kiro-cli v3 restores workflows and the mode itself. Recovery: end the thread so a fresh session is created.
  • The tail ends when the next prompt on the session starts, or when the connection is torn down. Text still buffered at that point, not yet posted, is discarded. Late parent text that arrives after the next prompt starts lands in the next reply, which is today's behaviour.
  • The late summary has no end-of-turn marker, so quiet time decides when it is complete. A pause longer than workflow_tail_quiet_secs can split one summary into two messages.
  • Workflow state is tracked per turn: a workflow started in one turn that is still running when the next prompt starts has its later output delivered with that prompt, not as a workflow update.
  • A run that never completes (for example an unanswered permission request upstream) costs one idle task and no lock for at most workflow_tail_max_secs, then a warning message is posted.
  • Strict checking is off by default, so a mistyped mode name is still ignored unless the operator sets strict_default_config_options = true.

Acceptance Criteria

  • With none of the new keys set, session/new params, set_config_option handling, reply streaming and prompt_done are unchanged, and the existing tests pass unmodified.
  • [agent] session_new_meta is sent as _meta in session/new and rejected at parse time when it is not a table.
  • With strict_default_config_options = true, a currentValue that differs from the request (and is not a name alias), a response that does not report the option, or an error from set_config_option, fails session creation with an error naming the option, the requested and the reported value.
  • With workflows enabled, session/update frames with a foreign params.sessionId are dropped from the reply, and permission requests from any session are still auto-answered.
  • With workflows enabled and a workflow started in the turn, late parent text is posted as a new thread message prefixed _Workflow update:_, quiet time only decides when buffered text is posted. The tail does not end on quiet. It ends on connection close, the next prompt, or workflow_tail_max_secs.
  • cargo clippy --workspace -- -D warnings (also with --features unified) and cargo test --workspace pass.

Follow-ups

  • Confirm and, if needed, send _meta and default_config_options on session/load.
  • Per-workflow delivery if kiro-cli exposes an end-of-turn marker for the wake-up turn.
  • A launcher or helper that writes the ~/.kiro/agents/<name>.md file.

At a Glance

config.toml                          openab                                kiro-cli (v3)
[agent] session_new_meta ──────────► session/new { _meta }  ─────────────► workflows on
[pool]  default_config_options ────► session/set_config_option ──────────► currentValue
        strict_default_config_options    └ compare requested vs reported, fail on mismatch
                                     session/prompt ◄── reply returns early
                                     session/update (sessionId = step) ──► dropped
                                     session/update (late, parent) ──────► tail task ─► thread

Prior Art & Industry Research

Not researched against OpenClaw or Hermes Agent for this PR. The behaviour is derived from a protocol probe of kiro-cli 3.3.0 documented in #1607 (frame order, _meta placement, silent mode fallback, late unsolicited chunks). The design choices below follow from that evidence.

Proposed Solution

All four changes are opt-in.

  1. [agent] session_new_meta (table, default none). Sent verbatim as _meta in session/new, for example { kiro = { settings = { workflows = { enabled = true } } } }. kiro-cli 3.3.0 only honours it in session/new, not in initialize. Not sent on session/load.
  2. [pool] strict_default_config_options (default false). After each session/set_config_option the returned currentValue is compared with the requested value. Rules when enabled: a response with no option of that id fails session creation, because nothing confirms the value, a value that matches by option display name is accepted (alias), anything else fails session creation and kills the agent process, and an error from the call fails too. In strict mode the legacy slash-command fallback is not used, so only a value the agent reports counts. See "Why this approach".
  3. Session filter (enabled together with workflows). While workflows are enabled, a session/update frame is kept only when params.sessionId is the served session's string id. A frame whose sessionId is missing, null, non-string or a different string is dropped. Other methods and responses are never dropped. Permission requests are answered by request id before any filtering, so step sessions still get their auto-approval.
  4. Late workflow output (enabled together with workflows). session/prompt returns before the workflow ends, and the final text arrives later as unsolicited agent_message_chunk frames of the parent session. If a _kiro/workflow/run_start for this session was seen during the turn, the turn keeps the notify receiver and hands it to a detached tail task right after the prompt response. The tail drains frames at once but posts nothing until the original reply is delivered.
    • Delivery: new messages in the same thread, text only, prefixed _Workflow update:_ and split to the platform message limit. One flush posts at most 16 platform messages. When the text needs more, the first 15 are posted and the 16th says this flush was cut at 16 platform messages and the rest of this flush was not sent; later output is still relayed. The earlier reply is not edited, and reactions are not touched. Not used on platform acp.
    • Bound: workflow_tail_quiet_secs (default 20) flushes buffered text after that long without output and posts text after a pause whether or not a run is open. Quiet time does not end the tail. workflow_tail_max_secs (default 900, 0 disables the relay) is a hard cap measured from the prompt response (not from reply delivery). Buffered text is capped at 256 KiB (later text is dropped and the post ends with a truncation note, so the text stays a contiguous prefix). The relay queue holds at most 1024 frames; overflow drops the newest frame and marks the next post truncated. One flush has a 30 s budget in total, so a stalled platform call cannot hold the task. If the platform is slower than that, the flush stops and the truncation note may not be posted. At the cap any buffered text is flushed and, if a run is still open, a warning says further output is not relayed.
    • Next prompt: the tail holds no connection lock and no in-flight flag. The next session_prompt replaces the subscriber, which cancels the tail. A cancelled tail discards its buffered, unposted text and posts nothing more. The next turn's reply waits for the cancelled tail to finish, with no timeout. Connection teardown (reset, idle cleanup, eviction, shutdown) cancels the tail the same way. A tail is armed only after a turn without error in which a workflow started for this session.
    • Opt-in: only when session_new_meta enables kiro.settings.workflows.enabled. A normal turn takes the unchanged prompt_done() path.

Docs: new docs/kiro-v3.md (args ["acp","--agent-engine=v3"], default_config_options = { mode = "<agent>" }, ~/.kiro/agents/<name>.md, empty mcp.json, about 0.5 GB per kiro-cli process, security notes), plus docs/kiro.md, docs/config-reference.md and config.toml.example.

Why this approach?

Item 2 is opt-in, not strict by default, because a strict default would break working configs. agy-acp answers success with a different currentValue when it normalizes a requested model name, and its own test asserts that. The repo shows no set_config_option behaviour for the other backends, so alias normalization there cannot be ruled out. kiro v2 reports modes under the option id agent, so a mode key finds no option: non-strict mode ignores it and strict mode fails on it. The v3 docs tell operators to turn it on.

The tail is a detached task that owns the receiver instead of a change to the reader loop or the connection mutex. That leaves the notify channel type, the lock order and every existing path as they are, and a hung workflow cannot block the next user message.

Alternatives Considered

  • Strict check by default: breaks alias-normalizing agents (see above).
  • Editing the original reply with the late text: the reply may already be final and edits do not notify users.
  • Holding the connection lock until the workflow ends: blocks the thread's next message for up to the cap.
  • Filtering by session id for every agent: an agent that echoes ids differently would lose output, so it is tied to the workflows switch.

Validation

Run on macOS (aarch64) with cargo, on the remote macOS build host, against 5011eab (the current head). Results as recorded in the commit message of 5011eab:

  • cargo clippy --workspace -- -D warnings clean
  • cargo clippy --workspace --features unified -- -D warnings clean
  • cargo test -p openab-core: 758 passed, 1 failed (secrets::tests::resolve_exec_nonzero_exit, which fails on macOS without these changes because it runs /bin/false, which only exists at /usr/bin/false there). CI on Linux runs it.
  • cargo test -p openab-core -- --include-ignored: same result.
  • Lifecycle and workflow_tail tests, 3 repeats: 44 passed each run.
  • GitHub CI on 5011eab: all required checks pass, including CI / check, which now runs the 13 lifecycle tests.
  • Touched hunks are rustfmt-clean. main is not fully cargo fmt clean, so unrelated files were not reformatted.

New tests:

  • Config: defaults, table parse, non-table rejection, meta_enables_workflows (string "true" is false), pool defaults and explicit values, validation of quiet = 0.
  • Relay queue: bounded queue overflow with a stalled delivery (queue_overflow_while_delivery_is_stalled_is_bounded_and_marked), no out-of-order text after a cut (text_after_a_cut_is_not_appended_out_of_order), late summary after a quiet gap (summary_after_a_quiet_gap_is_delivered), thought and tool frames keep one message (thought_and_tool_frames_keep_a_summary_in_one_message).
  • session/new params: legacy shape has no _meta; with meta it carries the workflows switch; an sh mock agent accepts session/new only when _meta is present.
  • Item 2 (pure and pool): equal, different, missing option, empty list, alias by name, kiro v2 agent option; pool with the sh mock agent: mismatch ignored by default, strict mismatch fails, strict match passes, no currentValue keeps legacy behaviour, strict error response fails, non-strict error only warns.
  • Item 3: is_foreign_session_update for same, different, missing and non-string ids, other methods and responses; a duplex reader-loop test shows a permission request from another session is still answered.
  • Item 4: run_tail with paused time: delivery after run complete and quiet, step-session text dropped, replaced subscriber cancels the tail without posting its buffer, and teardown cancels it too, run that never completes warns at the cap, text during an open run flushes and the tail continues, idle tail ends with no output, closed channel ends; TurnWorkflowState arms only for its own session.

End-to-end against kiro-cli 3.3.0 through the Rust code: not run for this PR. The protocol facts the code relies on (_meta in session/new, silent vibe fallback, frame order, late unsolicited chunks, per-session permission requests) come from the earlier probe recorded in #1607, not from a new run of this branch.

Testing (updated)

Pure logic stays inline (config parsing, _meta params, option comparison, frame classification, tail state machine with paused time, including buffer cap, gate, cap from prompt response and stalled delivery). Scenarios that spawn a mock agent subprocess or use the filesystem run in the default test job (13 tests, see below), including strict-mode failure despite a successful slash fallback and the subscriber swap through AcpConnection::session_prompt. clippy (also --features unified) is clean; the full workspace test run passes except secrets::tests::resolve_exec_nonzero_exit, which also fails on macOS without this change.

Lifecycle tests in CI (review F2)

The 13 lifecycle tests (workflow_meta_tests in acp/connection.rs, config_option_tests in acp/pool.rs) no longer carry #[ignore], so they run in the required CI / check job inside the existing cargo test --workspace step. The alternative was a separate --include-ignored job. Removing the attribute was chosen because the tests are unix-only, use a local sh mock agent and tempdirs, need no network, and passed three repeats. A failing lifecycle test fails that step and so the check job.

Late workflow tail cancel (review F1)

The next prompt on a session cancels the previous workflow tail, and so does connection teardown (reset, idle cleanup, eviction, shutdown). A cancelled tail discards buffered, unposted text and posts nothing afterwards. Before this change, that buffered text was flushed when the next prompt arrived. The next reply now waits for the cancelled tail with no timeout. The cancel path is documented in docs/kiro-v3.md.

chaodu-agent added a commit that referenced this pull request Nov 17, 2026
…subprocess tests to ignored

Review fixes for #1609 (Refs #1607).

- Workflow tail: starts draining right after the prompt response and posts
  only once the original reply is delivered (oneshot gate); hard cap is
  measured from the prompt response; buffer capped at 256 KiB with a
  truncation note; each post bounded to 30 s so a stalled platform call
  cannot hold the task.
- Strict default_config_options no longer uses the slash-command fallback
  (set_config_option_reported), so a locally synthesized value cannot
  confirm an option; warn when the agent does not report the option.
- Subprocess/filesystem tests are now #[ignore]d integration tests; new
  tests for buffer cap, gate, cap-from-response, stalled delivery,
  fallback-masking, and the subscriber swap through AcpConnection::session_prompt.
- Docs: wording fixes, per-turn workflow tracking limit.

Verified on macOS (macmini):
- cargo clippy --workspace [--features unified] -- -D warnings: clean
- cargo test --workspace --no-fail-fast: all pass except the pre-existing
  secrets::tests::resolve_exec_nonzero_exit (/bin/false path on macOS)
- cargo test -p openab-core --lib -- --ignored config_option_tests
  workflow_meta_tests: 11 passed
chaodu-agent added a commit that referenced this pull request Nov 18, 2026
…subprocess tests to ignored

Review fixes for #1609 (Refs #1607).

- Workflow tail: starts draining right after the prompt response and posts
  only once the original reply is delivered (oneshot gate); hard cap is
  measured from the prompt response; buffer capped at 256 KiB with a
  truncation note; each post bounded to 30 s so a stalled platform call
  cannot hold the task.
- Strict default_config_options no longer uses the slash-command fallback
  (set_config_option_reported), so a locally synthesized value cannot
  confirm an option; warn when the agent does not report the option.
- Subprocess/filesystem tests are now #[ignore]d integration tests; new
  tests for buffer cap, gate, cap-from-response, stalled delivery,
  fallback-masking, and the subscriber swap through AcpConnection::session_prompt.
- Docs: wording fixes, per-turn workflow tracking limit.

Verified on macOS (macOS (aarch64) builder):
- cargo clippy --workspace [--features unified] -- -D warnings: clean
- cargo test --workspace --no-fail-fast: all pass except the pre-existing
  secrets::tests::resolve_exec_nonzero_exit (/bin/false path on macOS)
- cargo test -p openab-core --lib -- --ignored config_option_tests
  workflow_meta_tests: 11 passed
All changes are opt-in; with the new keys unset behaviour is unchanged.

- [agent] session_new_meta: table sent verbatim as `_meta` in session/new
  (e.g. kiro.settings.workflows.enabled = true).
- [pool] strict_default_config_options (default false): after each
  session/set_config_option compare the returned currentValue with the
  requested value and fail session creation on a mismatch or error.
  Responses without that option and name aliases are accepted.
- With workflows enabled, drop session/update frames whose params.sessionId
  differs from the served session (workflow step sessions).
- With workflows enabled, keep reading after the prompt response and post
  late workflow output as a follow-up message in the thread
  ([pool] workflow_tail_quiet_secs=20, workflow_tail_max_secs=900, 0 = off).
- docs/kiro-v3.md, config reference and config.toml.example.

Refs #1607

Verified on macOS (cargo, workspace):
- cargo clippy --workspace -- -D warnings: clean
- cargo clippy --workspace --features unified -- -D warnings: clean
- cargo test --workspace --no-fail-fast: all pass, including the new tests,
  except secrets::tests::resolve_exec_nonzero_exit, which fails on macOS
  without these changes too (it execs /bin/false, which is /usr/bin/false
  there).
- Touched hunks are rustfmt-clean; the repo is not fmt-clean on main, so
  unrelated files were not reformatted.
…subprocess tests to ignored

Review fixes for #1609 (Refs #1607).

- Workflow tail: starts draining right after the prompt response and posts
  only once the original reply is delivered (oneshot gate); hard cap is
  measured from the prompt response; buffer capped at 256 KiB with a
  truncation note; each post bounded to 30 s so a stalled platform call
  cannot hold the task.
- Strict default_config_options no longer uses the slash-command fallback
  (set_config_option_reported), so a locally synthesized value cannot
  confirm an option; warn when the agent does not report the option.
- Subprocess/filesystem tests are now #[ignore]d integration tests; new
  tests for buffer cap, gate, cap-from-response, stalled delivery,
  fallback-masking, and the subscriber swap through AcpConnection::session_prompt.
- Docs: wording fixes, per-turn workflow tracking limit.

Verified on macOS (macOS (aarch64) builder):
- cargo clippy --workspace [--features unified] -- -D warnings: clean
- cargo test --workspace --no-fail-fast: all pass except the pre-existing
  secrets::tests::resolve_exec_nonzero_exit (/bin/false path on macOS)
- cargo test -p openab-core --lib -- --ignored config_option_tests
  workflow_meta_tests: 11 passed
…is pending

Review finding: the notify channel was unbounded and run_tail stopped
receiving while awaiting a platform delivery (up to 30s), so late frames
piled up outside the 256 KiB text cap. send() now selects over the
delivery future and rx, ingesting frames into the capped buffer; text
collected during a delivery is flushed afterwards. Added a flood test.

Validation (macOS (aarch64) builder): clippy --workspace and --features unified -D warnings
clean; cargo test --workspace --no-fail-fast all pass except the
pre-existing macOS secrets::resolve_exec_nonzero_exit (/bin/false);
--ignored config_option_tests workflow_meta_tests: 11 passed.
…the hard cap

- run_tail: after the delivery that crosses the hard cap, do one bounded
  final flush of frames drained during it before the "still running" note
  (review: output lost at the cap boundary). Frames arriving during that
  final flush are dropped.
- strict mode: a set_config_option reply without a result no longer falls
  back to the cached pre-switch options.
- test: text_buffered_while_a_delivery_crosses_the_hard_cap_is_flushed
  (paused time).

Validation (Linux x86_64 builder; the macOS builder was unreachable):
- cargo clippy --workspace -- -D warnings: clean
- cargo clippy --workspace --features unified -- -D warnings: clean
- cargo test --workspace --no-fail-fast: all pass (openab-core 775 passed, 11 ignored)
- cargo test -p openab-core --lib -- --ignored config_option_tests workflow_meta_tests: 11 passed
- cargo fmt --check: only my touched file is clean; other files differ on
  that toolchain's rustfmt version (pre-existing, untouched).
The tail ended at its first quiet flush when no run was open, so a
summary that arrived after more than workflow_tail_quiet_secs was
dropped. Thinking and tool frames also did not restart the quiet timer,
so a pause inside a summary split it into two messages.

- The tail now ends on channel close, at the hard cap, or when the next
  prompt replaces its subscriber. Quiet time only decides when text is
  posted.
- Any parent-session session/update restarts the quiet timer. Those
  frames are not posted.
- The 256 KiB buffer cap and the 30 s delivery timeout are unchanged.
- Tests: a summary after a 25 s gap is delivered; thought and tool
  frames keep a summary in one message; an idle tail ends at the cap
  with nothing posted; a stalled delivery no longer stops later output.
- docs/kiro-v3.md describes the behaviour as implemented.

Refs #1607

Checks run on the remote macOS build host, from an rsync of this
worktree (target and .git excluded):
- rustfmt --check --edition 2021 crates/openab-core/src/workflow_tail.rs: pass
- cargo fmt --check (workspace): fails on 666 files this change does not
  touch; root CI runs no workspace fmt, so this is pre-existing
- cargo clippy --workspace -- -D warnings: pass
- cargo clippy --workspace --features unified -- -D warnings: pass
- cargo test --workspace: 776 passed, 1 failed, 11 ignored. The failure is
  secrets::tests::resolve_exec_nonzero_exit, which also fails on the
  committed base on the same host.
- Negative check (scratch copy): with the quiet-timer refresh removed,
  thought_and_tool_frames_keep_a_summary_in_one_message fails.
Gate F1: the relay queue between the connection reader and the tail was an
unbounded channel, and the cap epilogue stopped reading it. The relay queue
is now a bounded channel of 1024 frames. A full queue drops the newest frame,
and the next flush is marked "output truncated". Foreground prompts keep the
unbounded queue. Frames still queued for the foreground receiver move to the
relay queue under the subscriber lock, so their order is kept.

The cap epilogue now reads queued frames and discards them, so the queue
keeps draining until the tail returns.

Gate F2 and R3/P2: quiet-gap splitting applies whether or not a run is open.
Once text is cut at 256 KiB, later text is dropped too, so the posted text
is a contiguous prefix before the truncation note. docs/kiro-v3.md now
describes this, the queue limit, and the parent-session traffic note (R6/N2).

Regression tests:
- queue_overflow_while_delivery_is_stalled_is_bounded_and_marked
- text_after_a_cut_is_not_appended_out_of_order
- summary_after_a_quiet_gap_is_delivered (R1, already present, unchanged)

Validation on remote macOS build host (aarch64, rust stable):
- rustfmt --check on workflow_tail.rs, acp/connection.rs, adapter.rs: pass
  (repo CI has no fmt step; 666 untouched files differ under cargo fmt)
- cargo clippy --workspace -- -D warnings: pass
- cargo clippy --workspace --features unified -- -D warnings: pass
- cargo test --workspace --no-fail-fast: 778 passed, 1 failed, 11 ignored.
  The failure is secrets::tests::resolve_exec_nonzero_exit, which the
  recorded results of earlier commits also show failing on the base.
- cargo test -p openab-core --lib -- --ignored: 11 passed, 0 failed.

Refs #1607
Gate R2/P1, decided by council (option b): a 256 KiB late flush split to
the platform limit becomes about 130 messages, and the 30 s deliver timeout
could cut it off before the truncation note. A flush now posts at most 16
platform messages. When the text needs more, the first 15 are posted and the
16th is a truncation note, so dropped output is always announced. The split
still uses each platform's message_limit. The queue bound (1024 frames) and
the 256 KiB buffer cap are unchanged.

Limits that remain: one flush has a 30 s budget in total. A slow platform can
stop it before the note is posted. Messages are sent one at a time, and rate
limiting is left to the platform client. Neither was tested against a live
platform.

Tests: flush_messages_are_capped_with_a_note_in_the_last_slot and
full_buffer_splits_into_at_most_the_cap_on_a_discord_sized_limit.

Validation on remote macOS build host:
- rustfmt --check on workflow_tail.rs, acp/connection.rs, adapter.rs: pass
- cargo clippy --workspace -- -D warnings: pass
- cargo clippy --workspace --features unified -- -D warnings: pass
- cargo test --workspace --no-fail-fast: 780 passed, 1 failed, 11 ignored.
  The failure is secrets::tests::resolve_exec_nonzero_exit, which also fails
  on the base.
- cargo test -p openab-core --lib -- --ignored: 11 passed, 0 failed.

Refs #1607
Gate F1 (Sol, blocking; Opus F1 non-blocking): TRUNCATED_NOTE said further
workflow output is not relayed, but a flush is capped at 16 messages and
later flushes are still relayed. The note now says this update stopped at
16 messages, the rest was not posted, and later output is still relayed.
docs/kiro-v3.md is updated to match.

Gate F2 (Opus, low, one line): when the channel closed while the original
reply's gate was still closed at the hard cap, run_tail flushed buffered text
before the reply. It now returns without posting, like the cap branch does.

Unit test: flush_messages_are_capped_with_a_note_in_the_last_slot asserts the
exact note text.

Validation on macmini (~/scratch/openab-kiro-v3, rsynced from this worktree):
- cargo clippy --workspace -- -D warnings: exit 0
- cargo clippy --workspace --features unified -- -D warnings: exit 0
  (manifest lint warnings only: unused clap, tracing-subscriber, and rmcp
  under unified; pre-existing, not touched)
- cargo test -p openab-core workflow_tail: 21 passed, 0 failed
Not run: cargo fmt (per task). Known pre-existing failures not touched: fmt
diff on main, secrets::tests::resolve_exec_nonzero_exit on macOS.
Gate F1 (Sol, blocking): the cap note must be flush-scoped. The note now
reads "this flush was cut at 16 platform messages and the rest of this flush
was not sent; later output is still relayed". docs/kiro-v3.md and the unit
test flush_messages_are_capped_with_a_note_in_the_last_slot assert the same
text. The PR body is updated to match.

Validation on macmini (~/scratch/openab-kiro-v3, rsynced from this worktree):
- cargo clippy --workspace -- -D warnings: exit 0
- cargo clippy --workspace --features unified -- -D warnings: exit 0
  (manifest lint warnings only, pre-existing)
- cargo test -p openab-core workflow_tail: 21 passed, 0 failed
Not run: cargo fmt. Known pre-existing failures not touched: fmt diff on main,
secrets::tests::resolve_exec_nonzero_exit on macOS.
@chaodu-agent

This comment has been minimized.

F1 strict_default_config_options: a set_config_option response that does
not list the requested option id now fails session creation (it used to
pass). verify_config_option_applied returns an error with "the agent did
not report the `<id>` option"; the non-strict path is unchanged.
Files: acp/connection.rs, acp/pool.rs.

F2 session/update filter: while workflows are enabled, a session/update
is kept only when params.sessionId is the served session's string id.
Missing, null and non-string ids are dropped. Responses and other
methods are untouched. No kiro-cli fixture omits sessionId; the repo's
ACP schema requires it on SessionNotification, so this is a code change,
not a documented exception.
Files: acp/protocol.rs (is_foreign_session_update, test), adapter.rs call
site unchanged in behaviour.

F3 tail ordering: spawn_tail returns a completion receiver stored on the
connection (conn.tail_done). The next turn waits for it right after
session_prompt, bounded by DELIVER_TIMEOUT (30 s), before posting. New
test next_reply_waits_for_the_previous_tail_final_flush.
Files: workflow_tail.rs, adapter.rs, acp/connection.rs, docs/kiro-v3.md.

F4 formatting churn: reverted rustfmt-only hunks in
warn_force_evicting_hung, with_connection, set_config_option, get_usage,
cancel, reset_session, the facade-token tests and the redaction test.
git diff origin/main -- pool.rs now contains only PR hunks.

Docs (docs/kiro-v3.md): strict-mode failure rule, sessionId rule, and the
tail-ordering rule with its 30 s bound.

Validation (macmini, worktree synced to ~/oab-verify-kiro-v3-fix2,
DEVELOPER_DIR=/Library/Developer/CommandLineTools because the Xcode
license is not accepted on macmini):
- cargo clippy --workspace -- -D warnings: pass
- cargo clippy --workspace --features unified -- -D warnings: pass
- cargo test -p openab-core --no-fail-fast: 743 passed, 1 failed
  (known: secrets::tests::resolve_exec_nonzero_exit on macOS), 13 ignored
- cargo test -p openab-core --lib config_option_tests -- --ignored: 10 passed
  (includes strict_response_without_options_fails_session_creation and
  strict_response_lacking_the_requested_option_fails_session_creation)
- named: acp::protocol::tests::foreign_session_update_detection,
  acp::connection::workflow_meta_tests::verify_rejects_missing_option_or_empty_list,
  acp::connection::workflow_meta_tests::verify_rejects_kiro_v2_agent_option_for_mode_key,
  workflow_tail::tests::next_reply_waits_for_the_previous_tail_final_flush: all pass
Known pre-existing, not changed: cargo fmt --check drift on main; the
rustfmt drift in untouched lines of the changed files.
@chaodu-agent

This comment has been minimized.

…ests in CI

F1: the next reply no longer gives up on the previous workflow tail after
DELIVER_TIMEOUT. wait_for_previous_tail (workflow_tail.rs) waits with no timeout.
The connection cancels a tail before the next prompt replaces its subscriber
(AcpConnection::session_prompt drops tail_cancel), and on teardown (dropping
the connection drops tail_cancel). A cancelled tail discards buffered text,
drops an in-flight deliver, and signals completion, so nothing posts after the
cancel and the wait cannot hang. TailControl {gate, cancel} replaces the bare
gate in run_tail and spawn_tail; adapter.rs creates the cancel channel.
docs/kiro-v3.md documents the cancel path.

Tests (workflow_tail.rs): next reply waits for a slow previous flush and is not
interleaved; teardown cancels an in-progress tail and nothing posts after the
next reply starts; a cancelled tail does not post buffered text. The connection
test next_prompt_replaces_subscriber_and_ends_the_tail now expects buffered text
to be discarded on the next prompt.

F2: removed #[ignore] from the 13 lifecycle tests (connection.rs
workflow_meta_tests, pool.rs config_option_tests). They run in the required
CI check job, in the cargo test --workspace step. They use a local sh mock agent
and tempdirs, need no network, and passed on three repeats.

Validation (macmini, rsync of this worktree):
- cargo clippy --workspace -- -D warnings: pass
- cargo clippy --workspace --features unified -- -D warnings: pass
- cargo test -p openab-core: 758 passed, 1 failed (secrets::tests::resolve_exec_nonzero_exit, pre-existing on macOS)
- cargo test -p openab-core -- --include-ignored (900 s bound): 758 passed, 1 failed (same pre-existing test)
- lifecycle and workflow_tail tests, 3 repeats: 44 passed each run
@chaodu-agent

This comment has been minimized.

@chaodu-agent

Copy link
Copy Markdown
Collaborator Author

Note

LGTM ✅ - Round 3 F1 is resolved: the PR description now matches the cancel design, lists the discarded-buffer trade-off as an accepted residual risk, and records validation for the current head. Code is unchanged from round 3, round 2 findings stay fixed, and CI is green.

What This PR Does

kiro-cli 3.x has a v3 engine that selects agents as ACP modes and runs Kiro workflows. Today openab silently stays in the default vibe mode when a mode name is unknown, cannot enable workflows, leaks workflow step-session text into the parent reply, and mis-delivers the workflow summary that arrives after session/prompt returns. This PR adds four opt-in pieces: [agent] session_new_meta, [pool] strict_default_config_options, a step-session frame filter, and a detached tail that relays late workflow output.

How It Works

  • session_new_meta is sent verbatim as _meta in session/new. Without it the request is identical to today.
  • In strict mode the pool compares the reported currentValue with the requested value (display-name aliases accepted). A missing option, a different value, or an error fails session creation.
  • With workflows enabled, a session/update is kept only when params.sessionId is the served session's string id. Permission requests are answered before any filtering.
  • Each workflow tail gets a TailControl { gate, cancel }. The connection holds the cancel sender in tail_cancel. session_prompt drops it before replacing the subscriber, and dropping the connection (reset, idle cleanup, eviction, shutdown) drops it too. A cancelled tail discards buffered text, drops any in-flight delivery, and posts nothing more. The next turn then waits on tail_done with no timeout.
  • The 13 lifecycle tests in workflow_meta_tests and config_option_tests run in the cargo test --workspace step of CI / check.

Findings

# Severity Finding Location
1 🟢 Round 3 F1 resolved: the PR description's "Next prompt" bullet, Accepted Residual Risks, and Validation section now describe the cancel design and the current head PR description
2 🟢 Round 2 F1 stays fixed: the next prompt and connection teardown cancel the tail before the subscriber is replaced, so an old tail cannot post after a newer reply starts crates/openab-core/src/acp/connection.rs:858-862, crates/openab-core/src/workflow_tail.rs:219-250
3 🟢 The untimed wait_for_previous_tail is safe: it runs only after session_prompt has dropped tail_cancel, and cancellation is polled ahead of every wait and the in-flight delivery crates/openab-core/src/adapter.rs:785-790, crates/openab-core/src/workflow_tail.rs:324-326,389-405
4 🟢 Round 2 F2 stays fixed: the lifecycle tests ran in this SHA's CI / check job (31 passing result lines across both cargo test steps, none ignored) crates/openab-core/src/acp/connection.rs, crates/openab-core/src/acp/pool.rs
5 🟢 docs/kiro-v3.md documents the cancel path and the lost-buffer consequence accurately; no dependency or auth-surface changes docs/kiro-v3.md:87-103
Finding Details

🟢 F1: PR description matches the code

Round 3 asked for three description changes with no code change. All three are in place on the unchanged head 5011eabb:

  • "Proposed Solution", item 4, "Next prompt" now says the next session_prompt cancels the tail, the buffered text is discarded, and the next reply waits with no timeout.
  • "Accepted Residual Risks" now states that text still buffered when the next prompt starts or the connection is torn down is discarded.
  • "Validation" now refers to 5011eabb and records its results, including CI.

🟢 F2: Ordering against the next reply is guaranteed

session_prompt calls self.tail_cancel.take() before it installs the new subscriber. run_tail uses a biased select with cancel first in the main loop, in the gate wait, and in send(), so a pending platform call is dropped instead of completing after the new reply. Teardown drops the sender with the AcpConnection.

🟢 F3: Untimed wait cannot hang

wait_for_previous_tail is called only after session_prompt returns, and by then the tail has been cancelled. A cancelled tail returns at its next poll and resolves tail_done. The test teardown_cancels_an_in_progress_tail_and_nothing_posts_after_the_next_reply covers a delivery that never completes.

🟢 F4: Lifecycle tests are part of the required gate

With #[ignore] removed, the tests run inside cargo test --workspace in CI / check. The job log for this SHA shows them passing in both the cargo test and cargo test (acp-mcp pool) steps.

🟢 F5: Docs and surface

docs/kiro-v3.md explains both cancel triggers and states that buffered text is lost when the user sends another message first. No dependencies, auth paths, or permission behaviour changed.

Baseline Check
  • PR opened: 2026-11-17
  • Head: 5011eabb89be094c34036b182cb8191983a5497d (unchanged since round 3); base: main; merge-base: b5f0ea8349dc28a5fbcd09cb9f07269300945c94
  • Diff stat: 14 files, +2373/-43 (workflow_tail.rs +1177, acp/connection.rs +508, acp/pool.rs +214)
  • Change since round 3: PR description only
  • Main already has: ACP sessions, default_config_options with a non-strict apply, reply streaming
  • Net-new value: v3 _meta, strict config-option check, step-session filter, late workflow relay
CI

All required checks pass on 5011eabb (39 pass, 1 skipped: operator), including check, conformance, validate, and every smoke-test image.

Reviewer Verdicts
Reviewer Verdict Notes
Reviewer A (architecture/general) LGTM Confirmed round 2 F1/F2 fixes. Non-blocking idea: a per-tail cancellation token plus an owned task handle would be easier to extend than separate tail_done / tail_cancel fields if workflow delivery gains more states.
Coordinator baseline LGTM Round 3 F1 (PR description) resolved
What's Good (🟢)
  • Every new path is opt-in, and the default v2 path is unchanged
  • Cancel-first biased selects everywhere the tail can wait, including the platform send
  • Teardown handled by ownership (dropping the connection drops the sender)
  • Tests that change behaviour assert the new contract (a cancelled tail posts nothing)
  • Docs and Review Contract state the trade-offs plainly

5. Three Reasons We Might Not Need This PR

  1. Narrow audience - every new path is opt-in and Kiro-v3-specific. Operators who do not run Kiro workflows get no value from about 2.3k added lines.
  2. Heuristic completion - without a protocol end-of-turn marker, quiet time decides when a summary is complete, so long pauses still split or detach messages. An upstream marker may make much of workflow_tail.rs unnecessary.
  3. Lossy by design - cancellation drops unposted summary text when the user replies quickly. Some operators may prefer to wait for kiro-cli to expose a proper wake-up turn before using workflows over chat.

@chaodu-agent chaodu-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note

LGTM ✅ - Round 3 F1 is resolved, round 2 findings stay fixed, and CI is green on 5011eabb.

Consolidated review: #1609 (comment)

GitHub event: COMMENT - self-review delivery only; this is not an approval.

@chaodu-agent
chaodu-agent enabled auto-merge (squash) November 20, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants