Skip to content

fix(subagent): print spawn list rows without terminal controls - #20361

Merged
bolichen97 merged 1 commit into
mainfrom
fix/spawn-list-terminal-safe-16698
Oct 14, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/spawn-list-terminal-safe-16698

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: kirocrew spawn list prints a subagent's id and task as plain text, so a task can never move the operator's cursor, retitle the window or fake a row.

A spawn's task is written by an agent. spawn list printed it raw. An ESC, CSI or OSC sequence in it reached the operator's terminal live, and a newline in it started a line that looked like a real row. The same gap was fixed on release/0.8.0 during the #16388 backport; main never got it.

Why it matters

Anyone who runs kirocrew spawn list reads text a model wrote. A hostile or confused task could clear the screen, rewrite the title, or print a fake ✅ ... done row. The fix only makes output stricter.

Not a goal

  • No change to what the gateway stores or returns for a spawn. Only the terminal print is cleaned.
  • No change to the queued wait text. queued_wait_text is built by the CLI from fixed reasons, not from agent text.
  • No new sanitizer. This reuses safe_terminal_line, the helper the other CLI error lines already use.

What changed (motivation → approach → change)

Symptom: spawn list printed q['id'], q.get('task'), a['id'] and a.get('task') raw. Cause: the two row loops build their f-strings straight from the gateway JSON. Change, in src/kiro_crew/cli_commands.py: one small helper, _spawn_row_text, passes the id and the task through safe_terminal_line before the 60-character cut, and both the queued and the running loop call it.

The second half of #16698 asked for a behaviour pin on the trusted wait identity at the main handle's ToolCallState construction. The code there was already right (mcp_server_name is set only when mcp_identity_trusted); only the pin was missing, so this PR adds the test and no source change for it.

Backwards compatibility

Compatible: a normal id and task print exactly as before. Only control bytes are dropped, and a newline in a task prints as the visible \x0a.

Removes nothing: no flag, key or output field goes away.

Tests

  • test/test_cli.py::TestSpawnCliAuth::test_spawn_list_queued_row_prints_no_terminal_controls: a queued row with ESC, OSC, BEL and a newline-forged row prints on one line with no control byte. Red on main, green here.
  • test/test_cli.py::TestSpawnCliAuth::test_spawn_list_running_row_prints_no_terminal_controls: the same for a running row. Red on main, green here.
  • test/test_acp_liveness.py::test_main_dispatch_names_the_server_only_from_a_trusted_identity: a trusted tool-call event names its server on the in-flight call; an untrusted one gets an empty name. Already true on main, so green on both; it fails if the if ev.mcp_identity_trusted guard is dropped.

Manual verification

N/A — unit coverage sufficient. The change is a pure string transform on two print calls, and the tests drive _spawn end to end with a canned gateway answer.

Screenshots / video

N/A — no UI change.

Related Issues

Closes #16698

Pattern harvest

Rule candidate: review-prompt
Pattern: a CLI list that prints agent-authored fields without safe_terminal_line.

Checklist

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 14, 2026 15:46
@bolichen97
bolichen97 requested a review from mbriones98 October 14, 2026 15:46
@bolichen97
bolichen97 enabled auto-merge (squash) October 14, 2026 15:46
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 7babfe850fa3e4ca275d38410434a32c5c70581d touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7babfe850fa3e4ca275d38410434a32c5c70581d — 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

Check that operators can still read the \x0a escape that safe_terminal_line now prints in place of a newline in a task.

What this change ships

Inventory (4 items) — 4 justified

Intent: let an operator read kirocrew spawn list without agent-written text taking over their terminal. This is a FIX.

  1. Queued rows print the spawn id and task with terminal controls removed — justified
  2. Running rows print the spawn id and task with terminal controls removed — justified
  3. A newline in a task now shows as visible \x0a on the same line, instead of starting a new line — justified
  4. New test for the trusted wait-identity value at the main handle (the second half of fix(subagent): forward-port the 0.8 spawn list sanitization and trusted wait identity pin to main #16698) — justified

[FIRST-PRINCIPLES-REVIEWED] 7babfe8

Description read

[DESCRIPTION-READ] 6b4a1272ce6f7cf10c79f2a642e359eace14441fe66f7feee20d463c3107c3cb

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 7babfe8

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

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

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that cutting the task at 60 characters after safe_terminal_line cannot split an escaped \x.. sequence in a way that confuses an operator.

[DESIGN-REVIEWED] 7babfe8

Description read

[DESCRIPTION-READ] 4d3aec14f52af3e8acee81c05adb29ac10a51d91cfb185ecc9bc38a4c2980af1

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7babfe850fa3e4ca275d38410434a32c5c70581d and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7babfe8

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

@bolichen97

Copy link
Copy Markdown
Contributor Author

agent: answer to the Design punchline on reason_detail (printed raw through queued_wait_text).

  • reason_detail is gate-written, not agent-authored

rebutted: checked every writer. The gate builds reason_detail from fixed sentences and numbers (MEMORY_PRESSURE_DETAIL, low memory: {avail_gb:.1f} GB available, need {min_mem:.1f} GB ..., the unknown-usage note) in subagent_manager/admission/gate.py.
The queued-row read path takes it from the deferred event's reason that the same gate wrote (taskq_bridge._defer_details). No spawn argument (task, agent, app) is interpolated into it.
The id and task fields are the agent-authored ones, and this PR now cleans both. Widening to reason_detail would be new hardening for a field no agent writes, so it is out of the frozen goal.

@bolichen97
bolichen97 force-pushed the fix/spawn-list-terminal-safe-16698 branch from 5c3b5c0 to 7babfe8 Compare October 14, 2026 16:52
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/test_acp_liveness.py and 7 neighbouring files since this head went green (989a43d -> ec99d90); CI re-running.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 14, 2026

@mbriones98 mbriones98 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.

Checks green and readiness passed at 7babfe8; no behavior change.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: spawn list rows pass the agent-authored id and task through the existing terminal-line sanitizer, with tests for escape sequences and forged rows.

@bolichen97
bolichen97 merged commit e11d59d into main Oct 14, 2026
102 of 103 checks passed
@bolichen97
bolichen97 deleted the fix/spawn-list-terminal-safe-16698 branch October 14, 2026 18:09
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(subagent): forward-port the 0.8 spawn list sanitization and trusted wait identity pin to main

3 participants