GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: mid-turn steer (X9) and ephemeral /btw side chat (X10) by zy1233 · Pull Request #157 · zy1233/zycode

Conversation

@zy1233

@zy1233 zy1233 commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the Pre-Refactor specification (docs/specs/2026-11-26-pre-refactor-steer-and-btw-design.md) across the Python harness/agent, VS Code extension, and Rust TUI, registering ACP extensions X9 (pi/session/steer) and X10 (pi/session/btw, pi/session/btw_cancel) in docs/specs/2026-11-05-acp-extension-registry.md.

What Changed

  1. ACP Extension Registry & Spec (docs/specs/)

    • Registered X9 (pi/session/steer, _pi/queue_update, user_message_chunk._meta["pi/steered"]) and X10 (pi/session/btw, pi/session/btw_cancel, _pi/btw_update) with InitializeResponse._meta["pi/capabilities"] = { steer: true, btw: true }.
    • Satisfies all 5 admission rules (capability negotiation, graceful degradation, pi-acp-lib wire types, zero JSONL v3 schema changes).
  2. Python Harness & ACP Agent (packages/pi-agent-harness/, packages/pi-agent-cli/)

    • AgentHarness: Added lock-free read-only snapshot_context_for_btw() (BtwContextSnapshot) and in-memory _steer_ids tracking without altering JSONL v3 UserMessage serialization.
    • Mid-turn Steering (X9):
      • Routes pi/session/steer while busy without interrupting in-flight tools; returns { queued: false, reason: "idle" | "waiting_for_trust" | "waiting_for_barriers" } cleanly on races.
      • Calls AutoSession.note_user_message(...) only on actual injection (message_start), never on enqueue or cancelled steers (Invariant S2).
      • Emits live user_message_chunk with _meta["pi/steered"] = true on message_end and _pi/queue_update(clearedByAbort=true, clearedSteerIds=...) on abort.
    • Ephemeral Side Chat /btw (X10):
      • Added pi_agent_cli/btw.py (repair_dangling_tool_calls, flatten_tool_history_for_btw, build_btw_context, run_btw with tools=[], rogue toolcall_* ignored, bounded multi-turn history, independent BtwAbortController, max 2 concurrent per session).
      • Added [btw] config parsing (model, thinking = "off" | "inherit", timeout_seconds) in config.py and documented in agent.example.toml.
      • Advertises /btw via available_commands_update.
      • Leaves main session JSONL v3 byte-for-byte untouched (and blank deferred sessions unwritten on disk).
  3. VS Code Extension (vscode/)

    • Added parsePiCapabilities, steerSession, askBtw, cancelBtw, and _pi/queue_update / _pi/btw_update handlers in acp-connection.ts.
    • Wired ChatController & ChatViewProvider for mid-turn steering (with idle fallback and abort draft restore) and /btw side chat (streaming, multi-turn history, independent cancel, graceful fallback on older agents).
    • Updated webview (main.ts, chat.css) with busy-state Steer submission, pending-steer queue bar, Steered user message badge, and floating BTW · Side chat panel (Escape dismisses BTW before cancelling main turn).
  4. Rust TUI (tui/)

    • Added typed wire definitions in pi-acp-lib/src/extensions/steer.rs and btw.rs.
    • Wired pi-pager: PiCapabilities from initialize, live steered UserMessageChunk handling in tracker.rs (not dropped by skip_next_user_echo), pi/queue_update & pi/btw_update handling in acp_handler, busy prompt steering & /btw dispatch in dispatch/prompt.rs, Effect::{SteerSession, SendBtw, CancelBtw}, and cancel-on-dismiss in dismiss_btw_panel.

Verification

  • Python Lint & Format: ruff check . && ruff format --check . — All checks passed (364 files formatted)
  • Python Unit, Integration & Stdio Wire Tests:
    • pytest packages/pi-agent-cli/tests/test_steer_and_btw.py -v — 13 passed
    • pytest packages/pi-agent-harness/tests packages/pi-agent-cli/tests -q — 4474 passed, 5 skipped
    • pytest pi_agent_core/tests -q — 710 passed, 20 skipped
  • VS Code Extension: cd vscode && npm run check (tsc + eslint + vitest) — 30 test files / 542 tests passed (including test/steer-and-btw.test.ts)
  • Rust TUI & Real Rust↔Python Stdio E2E:
    • cargo test -p pi-acp-lib — 72 unit tests + 1 golden wire test passed
    • cargo check -p pi-pager-bin --tests && cargo check -p pi-pager --tests — 0 errors, 0 warnings
    • PI_E2E_PYTHON=.venv/bin/python PI_E2E_REQUIRED=1 cargo test -p pi-pager --test python_agent_e2e — 18/18 passed (including steer_and_btw_work_over_real_stdio_pipes)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
zy1233 added 4 commits November 26, 2026 10:39
@zy1233
docs: register X9 steer and X10 btw ACP extensions and spec
6267987
@zy1233
feat(agent): implement mid-turn steer (X9) and ephemeral /btw side ch…
1b98d2d
…at (X10)
@zy1233
feat(vscode): add mid-turn steer and ephemeral /btw side-chat UI
be3c206
@zy1233
feat(tui): wire pi/session/steer and pi/session/btw over ACP
2523de6
@cursor

cursor Bot commented Nov 26, 2026

Copy link
Copy Markdown

Review result: REQUEST CHANGES (2 blocking, 7 non-blocking)

Reviewed head: 2523de6a44e729fb656876ac9007c00b10e920da (feat/steer-and-btw, base main). The head did not move during the review.

Checks

Run on Linux (Python 3.12, uv venv as in AGENTS.md):

Check Result
ruff check . and ruff format --check . pass
pytest packages/pi-agent-cli/tests/test_steer_and_btw.py 13 passed
pytest packages/pi-agent-harness packages/pi-agent-cli (full) 4474 passed, 5 skipped
cd vscode && npm ci && npm run check pass (542 passed, 17 skipped)
cargo test -p pi-acp-lib extensions 48 passed (includes the new steer and btw tests)
Two repro tests I wrote (not in the PR) both confirm a defect: finding 1 and finding 3

Read from CI (gh pr checks 157), all pass on this head: Ruff, pytest 3.11/3.12/3.13, pytest Windows and macOS, cargo nextest (Linux), Gates + cargo check, python_agent_e2e, VS Code check and linux-x64 VSIX smoke test, agent binaries on 5 platforms.

Not run: pi-pager Rust tests and the TUI build (I read the CI result instead); local Windows pytest (CI Windows is green); a real LLM or real provider; a real VS Code window or a browser run of the webview; scripts/tui_pty/. The UI findings below come from reading the code, not from running the UI.

Blocking

1. A steer can stay in steer_queue after the run ends, and it is injected into a later, unrelated prompt.
packages/pi-agent-cli/pi_agent_cli/agent.py:755-775, packages/pi-agent-harness/pi_agent_harness/agent_harness.py:1756-1758, pi_agent_core/agent_loop.py:264-268.
_handle_steer accepts a steer when harness.phase != "idle". The loop reads the steer queue only at a turn boundary. If the run ends in another way (stream error or aborted stop, max_turns, should_stop_after_turn, or the short time between the last queue read and phase = "idle"), nothing reads or clears the queue. The agent already answered queued: true.
Repro (I ran it): the first LLM call is pending, steer returns queued: true, the stream ends with error. After the turn: phase == "idle", len(steer_queue) == 1. The next, unrelated session/prompt then runs with the old steer text as an extra user message, and the client gets a user_message_chunk with pi/steered. The old instruction reaches the model with no new user action. VS Code and the TUI also clear their pending badge at turn end (chat-controller.ts:1225, prompt.rs agent.pending_steers.clear()), so the user sees nothing about it.
Fix: when run_agent_loop returns (in the finally at agent_harness.py:1756), take what is left in steer_queue. Clear it, pop the _steer_ids, and send queue_update with clearedByAbort: true and clearedSteerIds (or a new field such as undelivered) so the clients put the text back in the draft. Alternative: move the leftovers to next_turn_queue and tell the client. Add a test for the error-stop path and for a steer that arrives after session/cancel.

2. /btw is advertised as a slash command to every ACP client, but only clients that implement X10 run it as a side chat.
packages/pi-agent-cli/pi_agent_cli/agent.py:1736-1747.
_advertise_commands adds btw ("without polluting the main chat") for all clients. Admission rule 5 in the registry says the item must be harmless for a third-party client. For Zed or any other standard client, /btw question is a normal session/prompt: it runs a full main turn with tools and writes to the session JSONL. The command text says the opposite. The registry also claims "harmless" for X10.
Fix: advertise btw only to a client that opts in (for example clientCapabilities._meta["pi/capabilities"], which the VS Code extension and zypi can send), or do not advertise it (both clients already handle /btw by themselves). If the command stays, make prompt() answer a literal /btw ... text with a notice and run no turn. Add a test.

Non-blocking

3. The /btw limit of 2 and the duplicate-btwId check can be bypassed. agent.py:816-827, 872.
The count and the key in self._btw_tasks check run before await harness.snapshot_context_for_btw(). The task is stored only after that await. When the snapshot yields (no cached system prompt: a new chat, or after a model/thinking/resource change), parallel requests all pass. Repro (I ran it): 6 parallel /btw on a fresh session, all 6 start streaming; 2 requests with the same btwId both run, and the first one's finally removes the second one's entry, so btw_cancel cannot find it. Fix: reserve the slot (a placeholder entry) before the first await, and release it in finally. The test test_btw_cancel_and_concurrency_limit uses await asyncio.sleep(0.05) (test_steer_and_btw.py:654) to wait for b2; this can fail on a slow Windows runner. Wait on an event instead.

4. The waiting_for_barriers reason is wired to the wrong state, and VS Code does not fall back on idle while still busy. agent.py:755-760, agent.py:548, vscode/src/core/chat-controller.ts:1067.
_prompts_in_flight is increased in _run_prompt, after the agent-level trust wait and barrier wait in prompt() (agent.py:520). During that wait the phase is idle and the counter is 0, so the answer is idle, not waiting_for_barriers. The reason is never given for the wait that the spec names. Fix: count the prompt at the start of prompt(). Also, the VS Code fallback runs only when status === "ready". Agent phase becomes idle before the prompt response reaches the client, so in this short time and during the barrier wait the user gets "Could not steer right now (idle)" and the text goes back to the draft. S3 asks for an automatic fallback. Fix: if the reason is idle and the status is still busy, wait for the turn end and then send the prompt (the TUI already does this with enqueue_prompt and maybe_drain_queue). Test both reasons.

5. Follow-up /btw questions can fail for good once the history is more than 32 KB. vscode/src/core/chat-controller.ts:1102, tui/crates/codegen/pi-pager/src/app/acp_handler/mod.rs:607, btw.py parse_btw_history.
Both clients limit only the number of entries (20). The agent rejects more than 32 KB with invalid_params. A few long answers make every later follow-up in the same panel fail until the panel is closed. Fix: trim the oldest turns by UTF-8 bytes in both clients (or drop the oldest turns in parse_btw_history instead of raising). Add a test.

6. Restore of the draft can lose text (S5). tui/.../acp_handler/mod.rs:529, vscode/src/core/chat-controller.ts:1225.
The TUI puts the cleared steer back only when the prompt box is empty; otherwise the text is dropped. VS Code clears pendingSteers with no restore when a turn ends with a stop reason other than cancelled. Fix: in the TUI, prepend to the draft as VS Code does; in VS Code, restore the unconsumed texts at turn end.

7. /btw webview panel: stuck-looking and accessibility problems. vscode/src/webview/main.ts:832-840, 2444.
renderBtwPanel replaces all children on every delta. The "Thinking" <details> closes, keyboard focus on Stop and Copy is lost, and the panel scrolls to the bottom each time (the user cannot read an earlier part while the answer streams). The streamed answer has no aria-live region. While the panel is open, Esc in the main input closes the panel first, so Esc cannot stop a busy turn. Fix: update only the changed turn (keep the nodes), keep scrollTop when the user is not at the bottom, add aria-live="polite" on the answer, and let Esc close the panel only when focus is inside it.

8. Settings and data-flow documentation. packages/pi-agent-cli/agent.example.toml:172, agent.py:835-841, config.py:880.
The example says timeout_seconds = 60 and "1 to 300". The code default is 120 and the range is 5 to 600. /btw sends the full session context (system prompt, user text, assistant text, tool results cut to 4000 characters) to [btw].model, which can be another provider and key. Nothing in the example, the registry or packages/pi-agent-cli/AGENTS.md says this. An unknown [btw].model id silently uses the session model ([auto] model records a note for the same case). Fix: correct the example, add one sentence about the data flow to the registry entry and to packages/pi-agent-cli/AGENTS.md (it also lacks btw.py in the module table and notes for X9 and X10), and add a config note for an unknown id.

9. Missing tests that matter.

  • Harness level (the spec table lists them): steer(steer_id=...) mapping and cleanup, snapshot_context_for_btw in phase == "turn". There is no harness test in the PR.
  • Agent: steer with waiting_for_trust and the barrier wait; invalid params (empty prompt, unknown session); steer with an image; error-stop and steer-after-cancel (finding 1); /btw timeout; [btw].model override (which model and key are used); btw_cancel for an unknown id; duplicate btwId; /btw while trust is pending.
  • VS Code (steer-and-btw.test.ts): queued:false idle fallback, method-not-found fallback, restore at turn end, history size limit, close during streaming.
  • TUI: only one E2E test (idle steer and one /btw). There is no test of a steer during a turn, abort restore, or /btw while busy, and no pi-pager unit test. The spec table asks for them.
  • When a steer is typed while the agent is busy, VS Code sends any text (also /model or an extension command) as a plain steer message. The TUI runs slash commands first. This is from code reading; please add a test and decide the behavior.

Checked and fine

  • S1: the loop reads steers only after the tool batch and turn_end (agent_loop.py:315); the test holds a running tool and checks injection after it.
  • S2: auto.note_user_message is called only at message_start of a steered message (agent.py:1319-1324); the test shows a cleared steer is not noted and an injected steer is.
  • S4: only the steered message is sent live with pi/steered; the order after session/load matches the JSONL (tested).
  • B1: JSONL bytes are the same before and after /btw during a busy turn; a blank deferred session stays without a file. _steer_ids is memory only; UserMessage has no new field, so session JSONL v3 is unchanged.
  • B2: snapshot_context_for_btw reads only committed in-memory entries (jsonl_storage.py records an entry after the write), so the lock-free read is consistent.
  • B3: tools=[], no before_tool_call, no permission request, tool-call events are ignored; tool history is flattened to text so Anthropic and gateways get no 400. B4: dangling calls get a synthetic result (tested).
  • B5: close_session and _release_session cancel running /btw tasks; timeout and cancel both abort the stream signal; btw_cancel is idempotent.
  • Auto and permissions: /btw has no tool path, so no mode is weaker; the system prompt is built with the live ProjectTrust, so no new git run for an untrusted project.
  • Wire: Python, TypeScript and Rust shapes agree (method names, camelCase keys, kind values, optional fields). python_agent_e2e.rs proves the Rust client against the real agent. Capability parsing is the same in all three, and an agent without the capability keeps the old behavior in VS Code (tested) and in the TUI (old queue).
  • Webview: user and model text is set with textContent or the existing markdown renderer; no raw HTML from the agent.
  • Registry entries X9 and X10 match the code; Rust types are in pi-acp-lib.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zy1233 added 3 commits November 26, 2026 13:56
@zy1233
fix: clear undelivered steers on turn end and gate /btw command on cl…
41f6b8f
…ient opt-in
@zy1233
fix(tui): remove residue word from client_capabilities_meta doc comment
b538f18
@zy1233
fix: address PR #157 review items 3-9 for steer and /btw
c3f929c
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

Re-review result (delta): APPROVE (0 blocking, 5 non-blocking)

Reviewed head: c3f929cc62280579615b2b28e6684b6e265d427e (feat/steer-and-btw). Previous review: 2523de6a44e729fb656876ac9007c00b10e920da. The head did not move during this review. Scope: the three new commits 41f6b8f, b538f18, c3f929c.

Both earlier blocking findings are fixed. The five items below are non-blocking. Items 1 and 2 are small gaps left from earlier findings 4 and 6.

Checks

Run on Linux (Python 3.12, uv venv):

Check Result
ruff check . and ruff format --check . pass
pytest packages/pi-agent-harness packages/pi-agent-cli (full) 4484 passed, 5 skipped
cd vscode && npm ci && npm run check pass (the second run, with no other load)
vitest test/webview.test.ts test/steer-and-btw.test.ts 81 passed
cargo test -p pi-acp-lib extensions 48 passed
cargo test -p pi-pager --lib steer_and_btw (new acp_handler/tests/steer_and_btw.rs) 3 passed
My earlier repro of finding 1 (steer, then stream error) now: steer_queue is empty after the turn, the next prompt does not carry the old steer
New repro (see item 1) confirms the reason waiting_for_barriers at the turn end

Read from CI (gh pr checks), all pass on this head: Ruff, pytest 3.11/3.12/3.13, pytest Windows and macOS, cargo nextest, python_agent_e2e, VS Code check and linux-x64 VSIX smoke test, agent binaries.

Note: in my first npm run check, the test webview: ... reports failure state cleanly when clipboard access is denied failed once. At that time I ran pytest at the same time (high CPU load). The test uses a 50 ms timer. It passed 4 times alone and in the full run without load. It is not caused by this PR.

Not run: python_agent_e2e.rs locally (I read the CI result: pass); local Windows pytest (CI Windows is green); a real LLM or provider; a real VS Code window; scripts/tui_pty/. UI statements below come from reading the code and the tests.

Status of the 9 earlier findings

# Earlier finding Status Evidence
1 Steer stays in steer_queue after the run ends (blocking) Fixed agent_harness.py:1373-1390 (_clear_undelivered_steers), called in the finally of _execute_turn (:1786) and in _run_turn (:1829, :1836, :1841). Every end path passes through _execute_turn: stream error, max_turns, stop hook, abort. agent.py:1375-1390 (on_event, queue_update branch) sends queue_update with clearedByAbort: true and clearedSteerIds before the prompt response. Test: test_steer_cleared_when_turn_ends_with_error_and_not_leaked_to_next_prompt (test_steer_and_btw.py:474). See items 3 and 5 for two gaps.
1 (client side) The text of the user must not vanish Fixed for the agent-driven cases VS Code: onQueueUpdate restores the text (chat-controller.ts:1830-1845) and finishTurn restores what is left (:1278-1330); no double restore, because pendingSteers is empty after the first. TUI: acp_handler/mod.rs:529-538 now prepends to a non-empty draft (test queue_update_cleared_by_abort_prepends_to_non_empty_prompt_draft). Steer after session/cancel: reason: "aborting" (agent.py:786-791, agent_harness.py:1870; test test_steer_rejected_after_cancel_while_turn_unwinding). See item 2.
2 /btw advertised to every client (blocking) Fixed agent.py:171-177, :1792 advertise btw only when clientCapabilities._meta["pi/capabilities"].btw is true (I checked the parse with a real ClientCapabilities object: opt-in True, no meta False, None False). zypi (acp/mod.rs:317-328) and VS Code (acp-connection.ts:194-197) send it. A typed /btw ... over session/prompt gets a notice, runs no turn, writes no JSONL (agent.py:546-560; test test_literal_btw_prompt_returns_notice_without_turn_or_jsonl). The registry X10 text now says the same, so "harmless" (rule 5) is true again.
3 /btw limit and duplicate id bypass Fixed The slot is reserved before the first await (agent.py:868); the None placeholder is handled in the cancel loops. Test test_btw_slot_reserved_before_snapshot_yields_for_limit_and_duplicate_id.
4 waiting_for_barriers wiring and VS Code idle fallback Partly fixed The counter now starts at the start of prompt() (agent.py:531), so the trust and barrier wait give waiting_for_*. VS Code now queues an idle fallback while busy (chat-controller.ts:1125-1140). But see item 1: the real agent does not send idle in that window.
5 /btw history above 32 KB Fixed VS Code buildTrimmedBtwHistory (chat-controller.ts:101-124), TUI trim_btw_history (acp_handler/mod.rs:553-572). Tests in steer-and-btw.test.ts (fake agent big-btw) and trim_btw_history_enforces_32kib_utf8_byte_budget.
6 Draft restore loses text Mostly fixed See the 1 (client side) row. Gap: item 2.
7 /btw panel: stuck UI and accessibility Mostly fixed renderBtwPanel now patches nodes and keeps them (main.ts:807-915), keeps scrollTop when the user is not at the bottom, adds aria-live="polite". Not fixed: Esc in the main input still closes the panel first (item 4).
8 Docs and settings Fixed agent.example.toml (120 s, 5 to 600, data-flow note), registry X9 and X10, packages/pi-agent-cli/AGENTS.md (X9, X10, btw.py), and a config note for an unknown [btw].model (config.py:369-374, :636-646).
9 Missing tests Mostly fixed New: 2 harness tests, 9 agent-level tests, VS Code tests, 3 pager tests, one python_agent_e2e test (steer, abort restore, /btw while busy). Still missing: see item 5.

Blocking

None.

Non-blocking

1. At the turn end, the real agent answers waiting_for_barriers, not idle, so the S3 fallback in the clients is not reached.
packages/pi-agent-cli/pi_agent_cli/agent.py:793-796, vscode/src/core/chat-controller.ts:1125-1140, tui/crates/codegen/pi-pager/src/app/dispatch/task_result.rs:374, vscode/test/fake-agent.mjs:310.
prompt() holds the counter until the prompt response is sent. The harness sets phase = "idle" at agent_end (agent_harness.py:1531), before that. A steer in this window gets idle + counter > 0 = waiting_for_barriers. Repro (I ran it): a subscriber blocks on the settled event; pi/session/steer returns {"queued": false, "reason": "waiting_for_barriers"} with phase == "idle". Both clients handle only idle as "send as a normal prompt". For waiting_for_barriers VS Code shows "Could not steer right now (waiting_for_barriers)" and restores the draft (the text is kept, but the user must send it again). The VS Code test passes only because the fake agent sends idle.
Fix: make the agent report idle when the run has ended (for example a per-session flag that is set before harness.prompt and cleared at agent_end), and keep waiting_for_barriers for the time before the run starts. Or let both clients treat waiting_for_barriers like idle while the status is busy. If you keep the VS Code queue, send all queued fallbacks (today shift() sends one per turn end, chat-controller.ts:1327, and the result of send is ignored). Add a test with the real agent.

2. The TUI drops the steer text when the steer is rejected and the draft is not empty.
tui/crates/codegen/pi-pager/src/app/dispatch/task_result.rs:380-396.
In the Ok(resp) (not queued, reason not idle) and Err branches the text goes back only if agent.prompt.text().trim().is_empty(). Otherwise only a toast shows the reason, and the text is lost. This is the same defect that was fixed for queue_update in acp_handler/mod.rs:529. Reachable with aborting or waiting_for_barriers (item 1) when the user already typed new text. Fix: use the same prepend as in handle_queue_update_notification. Add a test.

3. After a failed queue update during a drain, a stale steer can still stay in the queue.
packages/pi-agent-harness/pi_agent_harness/agent_harness.py:1483-1486, :1786, :1836, :1841.
When _emit_queue_update raises in _drain_queue, the messages go back to steer_queue and _queue_drain_rolled_back is set. Then the three clear calls are skipped. The run ends with an error, and the steer stays in the queue (and in _steer_ids). The next unrelated prompt injects it. This is the original finding 1 in a rare path. I see no reason to skip the clear: the run is over. Fix: always clear at the run end. Add a test (a subscriber that raises on queue_update).

4. Esc in the main input closes the /btw panel before it cancels a busy turn.
vscode/src/webview/main.ts:2521-2525.
This is the last part of the earlier finding 7. With the panel open and a busy turn, the first Esc closes the panel and a second Esc is needed. Fix: close the panel on Esc only when focus is inside the panel (the handler at main.ts:2301 already does this for btwInput).

5. Tests and registry text do not match what the registry claims.
docs/specs/2026-11-05-acp-extension-registry.md (X9 "Effect"), packages/pi-agent-cli/AGENTS.md, test_steer_and_btw.py:474.
The text says leftover steers are cleared on "stream error, max_turns, stop hook, or abort", but only the stream-error path and the cancel path have a test. Add one test each for max_turns and should_stop_after_turn (they are cheap at the harness level), and one for item 3. The same text says the steers are cleared "before the session returns to idle". The code clears them after phase is idle (agent_harness.py:1531 runs before :1786); a steer in between is refused (item 1), so nothing is lost, but the sentence is not exact. Say "before prompt() returns".

Checked and fine

  • New commits do not change the event contract, the Auto path (note_user_message still runs only at message_start), project trust, or session JSONL v3 (QueueUpdateEvent.undeliveredSteer is memory only; _steer_ids is memory only).
  • prompt() counter moved to the start: the busy check (> 1) and the cleanup in finally are correct; no leak on the early returns.
  • begin_abort() and abort(_from_begin=True): session/cancel now marks the harness as aborting synchronously, aborts the run controller at once, and abort() releases the depth in finally. A new run that starts while an abort is in progress is aborted as well (_execute_turn, agent_harness.py:1745). I found no case where a prompt after a finished cancel is refused. I could not make a race with slow notifications appear in a test.
  • steer() refuses when closed, idle, or aborting; the reason mapping at agent.py:786-812 covers aborting in the late invalid_state path too.
  • _handle_btw: the placeholder entry has task is None and all readers (_cancel_btw_tasks, _handle_btw_cancel) check it; finally pops the key on every path, also when controller.signal.aborted is true after the snapshot.
  • [btw].model unknown note: the earlier auto variable bug is fixed (config.py:635, it now uses config.auto), so the note does not drop other [auto] notes.
  • VS Code: the client-side slash-command guard while busy (chat-controller.ts:1031-1038) does not catch paths like /etc/hosts ... (the regex needs a space or end after the name). buildTrimmedBtwHistory counts UTF-8 bytes like the agent.
  • Clients without pi/capabilities (Zed and others): no /btw command, no behavior change in session/prompt, except the notice for a literal /btw text.
  • Rust: pi-acp-lib types are unchanged; client_capabilities_meta test updated.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zy1233 and others added 6 commits November 27, 2026 02:11
@zy1233
docs: include zycode refactor architecture and roadmap spec
88c486d
@cursoragent
fix(harness): clear undelivered steers when a drain rolled back
6b0e878
The rolled-back flag skipped the clear at run end, so a steer whose queue
update failed stayed in steer_queue and leaked into the next prompt. Always
clear at run end; a failed notification there no longer masks the run result.
@cursoragent
test(harness): cover steer clear on max_turns and should_stop_after_turn
c14d785
Add harness tests for the two run-end paths that the registry names but no
test held, and say in the X9 text that leftover steers are cleared before
prompt() returns (phase is already idle at that point).
@cursoragent
fix(acp): answer idle to a steer after the run ended and send every f…
907f521
…allback

A steer between agent_end and the prompt response was answered
waiting_for_barriers, so the clients' idle fallback was never reached. Track
the end of the run per session: waiting_for_barriers stays for a prompt whose
run has not started. VS Code now sends all queued fallbacks as one prompt and
puts the text back in the draft if the send does not start.
@cursoragent
fix(tui): keep rejected steer text in front of the draft
3f49097
A steer that the agent refused (aborting, waiting_for_barriers) or that
failed was put back in the prompt box only when the box was empty, so text
typed in the meantime made it vanish. Share the prepend of the queue_update
handler.
@cursoragent
fix(vscode): close the /btw panel on Escape only from inside the panel
2a58a0c
Escape in the main input closed the panel before it cancelled a busy turn,
so cancel needed a second key press. The panel now handles its own Escape.
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

Re-review result (delta 2): APPROVE (0 blocking, 3 non-blocking)

Reviewed head: 2a58a0c207b8f9864ede02c915c8d315b9435ac7 (feat/steer-and-btw). Previous review: c3f929cc62280579615b2b28e6684b6e265d427e (APPROVE). The head did not move during this review. Scope: 88c486d (docs only), then 6b0e878, c14d785, 907f521, 3f49097, 2a58a0c. I did not write these commits.

All 5 earlier non-blocking items are fixed. The 3 items below are new and small. One CI job is red because of a flaky test (see "CI").

Checks

Run on Linux on the live head (after the rebase on 88c486d):

Check Result
ruff check . and ruff format --check . pass
pytest packages/pi-agent-harness packages/pi-agent-cli (full) 4487 passed, 5 skipped
cd vscode && npm run check pass
cargo test -p pi-acp-lib extensions 48 passed
cargo test -p pi-pager --lib steer_and_btw 5 passed (3 old, 2 new)
python_agent_e2e (cargo nextest run -p pi-pager --test python_agent_e2e, PI_E2E_PYTHON = the repo .venv Python, PI_E2E_REQUIRED=1) 19 passed
Mutation check A: I disabled _clear_undelivered_steers (temporary edit, restored) the 2 new harness tests, the rollback test and test_steer_cleared_when_turn_ends_with_error_... all fail
Mutation check B: I made agent.py:804 ignore _run_over (temporary edit, restored) test_steer_after_run_end_before_prompt_returns_is_idle_not_waiting_for_barriers fails

Not run: local Windows and macOS (CI is green for both); a real LLM; a real VS Code window; scripts/tui_pty/; the VSIX smoke test (CI skipped it, see below). The UI statements come from reading the code and the tests.

CI

I waited until all jobs finished. Result for this head: all jobs pass (Ruff, pytest 3.11/3.12/3.13, Windows, macOS x2, cargo nextest, python_agent_e2e, Gates + cargo check, agent binaries on 5 platforms), with one exception:

  • Type check, lint, unit tests failed. Failed test: webview: code blocks, copy interactions, and IME guard > reports failure state cleanly when clipboard access is denied (vscode/test/webview.test.ts:951-964). Log line: AssertionError: expected { ok: true, hasFailed: false, …(1) } to match object { ok: true, hasFailed: true, …(1) } (label was Copy, expected Copy failed). The webview file took 59.7 s on that runner. Cause: the test reads the result after a fixed 50 ms timer; on a loaded runner the async copy failure is not yet shown. The PR does not touch this test (git diff main..2a58a0c adds only the new Escape test in the same file). I saw the same failure once on my machine at the previous head while another heavy job ran; it passed 4 times alone and in two full runs without load. The earlier 5 runs of this workflow on this PR were green. I judge it a flake, not caused by this PR. I cannot re-run the job; please re-run it. Note: the job Start the linux-x64 agent from its VSIX (VSIX smoke test) depends on this job, so CI skipped it on this head.
  • Fix for the test (not for this PR): wait for the data-failed attribute with a poll and a limit, not a fixed 50 ms timer.

Status of the 5 earlier items

# Item Status Evidence
1 Turn-end race answered waiting_for_barriers Fixed agent.py:1373 sets _run_over at agent_end; agent.py:797-806 answers waiting_for_barriers only while a prompt is in flight and the run has not ended; the flag is cleared at prompt() start (:535), at each _run_prompt loop turn (:590), when the last prompt returns (:575), and on session release (:503). VS Code now sends all fallbacks as one prompt (chat-controller.ts:1325-1345). Test: test_steer_after_run_end_before_prompt_returns_is_idle_not_waiting_for_barriers (also checks that a second prompt in its barrier wait still gets waiting_for_barriers), and steer-and-btw.test.ts "sends every idle-fallback steer, in order, as one prompt". See item 3.
2 TUI dropped the steer text on rejection Fixed restore_into_draft (acp_handler/mod.rs:497) is used by handle_queue_update_notification (:541) and by both rejection branches (task_result.rs:387, :394). Tests rejected_steer_is_prepended_to_a_non_empty_draft_and_never_dropped (aborting, waiting_for_barriers, Err) and rejected_steer_fills_an_empty_draft.
3 Stale steer after a failed drain Fixed _queue_drain_rolled_back is removed. _clear_undelivered_steers always runs (agent_harness.py:1786, and the two except branches in _run_turn). The rollback test now asserts an empty queue, empty _steer_ids, and that the next prompt does not carry the steer.
4 Esc closed the /btw panel before the cancel Fixed, with one side effect main.ts:2298 (panel handler), main input main.ts:2521 (cancel only). Test in webview.test.ts (main Esc gives cancel; panel Esc gives btwClose). See item 1.
5 Tests and registry wording Fixed New harness tests for max_turns and should_stop_after_turn (test_harness_agent.py); both fail with the clear disabled (mutation check A). Registry X9 and packages/pi-agent-cli/AGENTS.md now say "before prompt() returns", which matches the code (agent_harness.py:1531 idle, then :1786 clear, then return). The registry also documents the new idle / waiting_for_barriers rule.

Blocking

None.

Non-blocking

1. With the /btw panel open and the agent idle, the keyboard cannot close the panel from the main input.
vscode/src/webview/main.ts:2298-2303, :2521-2525.
Before, Esc in the main input closed the panel. Now the panel closes only when focus is inside it. The panel input is never focused on open (btwInput.focus is not called anywhere), so after the user types /btw question in the main input, focus stays there. When the agent is idle, Esc then does nothing; the user must use the mouse (the close button) or Tab into the panel. When the agent is busy, Esc cancels the turn (correct, this was the goal). Fix: in the main input handler, if the status is busy, cancel; else if the panel is open, close it. Or focus the panel input when a new /btw turn starts. Add one idle test.

2. The roadmap text in 88c486d says things that the code and the registry contradict.
docs/specs/2026-11-25-zycode-refactor-and-roadmap.md:77, :503, :588 (Auto note at enqueue); :108 (/btw advertised to all clients); :120 (kind values); :106 (snapshot of the running turn); :65-69 (current gaps). See "About 88c486d" below for the full list. This is a design draft and the owner decides, but the Auto line is a security statement that is false for the code (note_user_message runs at message_start, never at enqueue; registry X9, S2 of the steer design spec). A future implementer of pi-rust or the conformance suite would copy the wrong rule. Fix: change the 3 Auto lines to "at injection (message_start)", fix the wire names and the /btw advertisement (opt-in) to match registry X9 and X10, or add a line "the wire details are in the registry; this text is the 2026-11-25 draft".

3. The idle window is tested in two halves; no test runs the VS Code client against the real agent.
vscode/test/fake-agent.mjs:310 (steer-idle-race), packages/pi-agent-cli/tests/test_steer_and_btw.py (new test).
The Python test proves that the real agent answers idle in the window. The VS Code test proves the client sends one prompt after idle, but the fake agent forces the idle answer (busySessions.delete). The contract between the two is the string idle only, and it is documented in the registry, so the risk is low. Small details in the same code: on a failed send, the draft is restored with \n joins (chat-controller.ts:1342) but the prompt is sent with \n\n joins (:1338), so the restored text differs from what the user typed. Fix: use the same separator in both, and (optional) add a case to python_agent_e2e.rs that steers in the idle window.

About 88c486d (observations for the owner)

I read all 607 lines. It is a design draft (the header says "design draft, no code change"). It adds no code and no workflow change, so it cannot break CI (ci.yml skips docs-only changes).

  • Contradicts the code, the registry, or AGENTS.md:
    • Auto note at enqueue: lines 77, 503, 588. Code, registry X9 and the steer design spec S2: at injection only. This is the only item that touches an invariant (Auto fail-closed, S2).
    • /btw "registered in available_commands_update" (line 108): the code and registry X10 advertise it only to clients that opt in (admission rule 5).
    • _pi/btw_update kind: "thought"|"text" (line 120); the wire is thought_delta / text_delta. The steer request has no steerId and the reasons list lacks aborting and waiting_for_trust / waiting_for_barriers (lines 71-80).
    • Line 106: the snapshot includes "the text of the running turn". My first review found that snapshot_context_for_btw reads only committed entries.
    • Lines 61-69 ("current gaps", with line numbers like agent.py:536-537 and chat-controller.ts:1080) describe the state before this PR; the PR closes all four gaps, and the line numbers no longer match.
    • Line 324 says "all 9 invariants" and lists 8, 9, 9b, 9c; AGENTS.md has 1 to 9 and 9b to 9d.
  • Facts that match: versions (zycode-agent 1.1.0, VS Code 1.12.0), release.yml token flow and the pi-python release title (release.yml:214, :273), agent-assets.json and RELEASING.md still name zy1233/pi-python, web/src/data/site.ts:4, docs/PLAN/PLAN-RUST-AGENT-RUNTIME-REMOVAL.md exists. I did not check the line counts, binary sizes, or external registry settings (Open VSX, Marketplace, Cloudflare).
  • Language: the file is Chinese. It is not Simplified Technical English. The registry and the code docs are English; the new steer design spec (2026-11-26-...) is Chinese too. Decide whether specs under docs/specs/ must follow the STE rule.
  • Claims about features that do not exist: zycode-daemon, pi-rust, tests/conformance/, ~/.zycode, Tauri desktop, mobile, and the repo rename are all future work and are marked as plan. None is stated as shipped. They must not be copied to README.md or web/ before they exist (AGENTS.md: the site must equal the README "Status").
  • Other: the file has calendar estimates (for example "2-3 weeks"); the project rule for cloud agents says not to give them. The file is a roadmap of the whole product and has no link to it from docs/DESIGN.md or the registry, apart from the steer design spec. It is unrelated to the scope of this PR ("steer and btw"); it could be its own PR.

Checked and fine

  • _run_over races: a steer between agent_end and the prompt response gets idle (tested); a steer after session/cancel gets aborting first (is_aborting is checked before); a second prompt at its barrier wait gets waiting_for_barriers (tested). Early returns (trust wait, barrier wait, cancelled), errors (harness.prompt raising), and the busy retry loop all go through the finally at agent.py:572-575, or the loop reset at :590, so the flag does not leak. A run that no prompt started (extension or workflow turn) sets the flag once; the next prompt() clears it, and _release_session removes it. The cost is one str per session.
  • _clear_undelivered_steers now logs and ignores a failing queue_update (agent_harness.py:1387-1389). It does not change the run result: the queue is already clean, the finally still removes _steer_ids, and the error of the run (or its result) is not replaced. The only effect of a lost notification is that a client does not get the restore signal for that run. VS Code still restores the text at the turn end; the TUI does not. This needs the notification channel to fail, and then the connection is gone. A real run error is not hidden, because _emit_run_failure runs before the finally.
  • The drain failure (_drain_queue) still raises and still puts the messages back; only the end-of-run clear changed. The rolled-back message is now cleared at the run end and the client is told (clearedByAbort).
  • VS Code fallback: send() returns false only when the turn did not start (it awaits the whole turn otherwise), so the notice and the draft restore in sendIdleFallbacks run only on a real failure. Mentions are path tokens without text offsets, so joining the texts does not move them; mentions and images keep the order typed. A cancelled or non-ready turn restores all drafts and sends nothing. pendingIdleFallbacks is cleared at close, exit and reset.
  • restore_into_draft has one definition and one behavior in both TUI paths; the existing queue_update test still passes.
  • The Esc panel handler ignores IME composition (isComposing, keyCode 229) and moves focus to the main input; btwInput no longer has its own Esc branch, so there is no double btwClose.
  • Registry X9 and packages/pi-agent-cli/AGENTS.md match the code for the reason values, the clear rule and the new wording. X10 is unchanged and still true.
  • The 5 fix commits do not change the event contract, the Auto path, project trust, session JSONL v3, or the wire shapes; pi-acp-lib types are unchanged.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursoragent and others added 4 commits November 27, 2026 02:49
@cursoragent
fix(vscode): let Escape in the main input close an idle /btw panel
1420830
Cancel still wins while the turn is busy; with the agent idle, Escape in the
main input now closes the open panel, so the keyboard can reach it.
@cursoragent
fix(vscode): restore queued fallbacks with the separator of the send
340c902
The queued steers were sent joined with a blank line but put back in the
input joined with a single newline, so the restored text differed from what
the user typed. Use one join for both.
@zy1233
docs: align roadmap and steer/btw spec with implemented semantics
6b2e9e1
@zy1233
docs: list Invariants 1-9 and 9b-9d accurately in roadmap
a9d2021
@zy1233
zy1233 merged commit ec49e28 into main Nov 27, 2026
24 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@zy1233
zy1233 deleted the feat/steer-and-btw branch November 27, 2026 03:28
@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

Re-review result (delta 3): APPROVE (0 blocking, 3 non-blocking)

Reviewed head: a9d20215e0a669417e4bf73ad06998047f8b30a3 (feat/steer-and-btw). Previous review: 2a58a0c207b8f9864ede02c915c8d315b9435ac7 (delta 2, APPROVE). The head did not move during this review. Scope: 1420830 and 340c902 (fix worker, vscode/ only), 6b2e9e1 and a9d2021 (owner, docs only).

Both fixes for my delta 2 items 1 and 3 are correct. The 3 findings below are wrong or misleading lines in the docs commits. None of them is in code.

Checks

Check Result
cd vscode && npm run check at a9d2021 (typecheck, lint, vitest) pass: 552 passed, 17 skipped (569 total)
Mutation A (temporary edit, restored): remove the idle Esc block from vscode/src/webview/main.ts, rebuild Escape in the main input closes an open /btw panel when the agent is idle fails
Mutation B (temporary edit, restored): put back the old restore join ("\n") at the two restore sites, keep the send join restores the idle-fallback text with the same separator as the send ... fails; the other 13 tests in the file pass
git diff --name-only 2a58a0c..a9d2021 for *.py and *.rs 0 files. The earlier Python, cargo and python_agent_e2e results (delta 2: pytest 4487 passed, pi-acp-lib 48, pi-pager steer_and_btw 5, e2e 19) still apply to this head
Identity check on the 4 commits (author, committer, message) 0 matches for the mail provider you named (I did not print any address)
CI of this head 21 pass, 3 skipped (Publish, Attach to the release, Release build baseline, as expected), 0 fail. The VSIX smoke test passed.

Not run again: ruff, pytest, cargo and e2e (no .py or .rs file changed since 2a58a0c); Windows and macOS locally (CI is green); a real VS Code window.

Blocking

None.

Non-blocking

1. The roadmap says the history limit is "20 turns". The code limit is 10 turns (20 messages).
docs/specs/2026-11-25-zycode-refactor-and-roadmap.md:98 ("20 轮与 32 KiB UTF-8 字节双重裁剪") and :118 ("服务端硬上限 20 轮 / 32 KiB UTF-8").
Code: packages/pi-agent-cli/pi_agent_cli/btw.py:38 BTW_MAX_HISTORY_TURNS = 10, and :101 rejects more than BTW_MAX_HISTORY_TURNS * 2 messages. VS Code uses 10 turns (chat-controller.ts:97). The TUI uses 20 entries (acp_handler/mod.rs:556), which is the same limit. The sibling spec says "10 轮 / 32 KB" (2026-11-26-pre-refactor-steer-and-btw-design.md:162), so the two specs now disagree. Fix: write "10 轮(20 条消息)" in both lines. The 32 KiB UTF-8 value is correct.

2. The VS Code test count "548" is wrong, and its table row mixes two baselines.
docs/specs/2026-11-25-zycode-refactor-and-roadmap.md:21 (the vscode/ row).
At this head npm run check gives 552 passed, 17 skipped. On main (06e62c7) the same row had 534 tests. 548 is neither value. The same row also gives "TypeScript 11,110 lines": this is the exact count of main (I counted vscode/src at 06e62c7: 11,110); at this head it is 12,037. The header calls the row "baseline: current main", but the first sentence now says the PR is implemented. The module count "23" is correct at both. Fix: use one baseline. Either keep the main numbers (534 tests, 11,110 lines) and say "measured at 06e62c7", or update them to the head (552 passed, 12,037 lines), or remove the counts, because they will drift again. The Python row ("35,101 lines") and the Rust row ("958,555 lines") have the same question; my own count at the head is 36,203 and 990,087 (my method may differ from yours). The crate count "80" is correct.

3. "Invariant S2" is not an AGENTS.md invariant.
docs/specs/2026-11-25-zycode-refactor-and-roadmap.md §6 risk table, first row ("(Invariant S2)"); the same sentence's Auto rule is correct.
AGENTS.md has Invariants 1 to 9 and 9b to 9d. S2 is item S2 of the steer design spec (2026-11-26-pre-refactor-steer-and-btw-design.md:27). A reader who looks for "Invariant S2" in AGENTS.md finds nothing. Fix: write "S2 of the steer design spec".

Status of my delta 2 items

# Item Status Evidence
1 Esc cannot close an open /btw panel from the main input when idle Fixed vscode/src/webview/main.ts:2521-2537: busy gives cancel; else an open panel gives btwClose; else history restore. Order is as you specified. The panel handler (:2298) is unchanged. closeBtw also cancels the requests still running (chat-controller.ts:1228-1239). New test fails without the block (mutation A).
3 Send and restore used different separators Fixed joinIdleFallbackTexts (chat-controller.ts:134) is used at the send (:1341), at the cancelled/not-ready restore (:1332) and at the failed-send restore (:1347). The new test checks that send gets "first fallback\n\nsecond fallback" and that restoreDraft has the same text; it fails with the old join (mutation B).

Checked and fine

  • The Escape order, the IME guard and the menu priority are unchanged for the other keys; the new block does not run while a menu is open (the menu branch returns first). A second Esc after the panel closes goes to the history restore, as before.
  • sendIdleFallbacks still sends the joined text with the mentions and images in the typed order, and the notice plus the restore run only when send returns false (it did not start the turn).
  • Auto note at injection only: the roadmap now says note_user_message is never called at enqueue and is called at message_start (agent.py, on_event; registry X9; steer spec S2). The old claim "at enqueue" is gone from the three places I flagged in delta 2.
  • Steer reasons idle | aborting | waiting_for_trust | waiting_for_barriers equal registry X9 and agent.py; the sibling spec line (...design.md:100) now has aborting too. steerId, clearedByAbort, clearedSteerIds, pi/queue_update params, _meta["pi/steered"] and _meta["pi/steerId"] equal the registry.
  • The harness description (begin_abort(), is_aborting, QueueUpdateEvent.undeliveredSteer, in-memory steer_id map, JSONL v3 unchanged) equals agent_harness.py. harness.steer(text, images, steer_id=steer_id) equals agent.py:814.
  • /btw: advertised only to clients that send clientCapabilities._meta["pi/capabilities"].btw = true (agent.py:1792); a literal /btw ... over session/prompt gets a notice, end_turn, no LLM call, no JSONL. thought_delta / text_delta / done / error, error, stopReason, pi/session/btw_cancel (idempotent) equal registry X10.
  • Numbers: 4,000 characters for tool results (btw.py:42), 2 concurrent per session (btw.py:40), the slot is reserved before the first await (agent.py:868), timeout_seconds default 120 s and range 5 to 600 s (config.py:245-247), thinking is "off" or "inherit" (config.py:243), unknown [btw].model records a note and falls back (config.py:369, :636), 32 KiB UTF-8 in VS Code and TUI.
  • Paths: pi-acp-lib/src/extensions/steer.rs and btw.rs exist. The TUI runs the slash registry before the steer dispatch (prompt.rs:378 before :591), as the roadmap says. VS Code blocks /model and agent commands such as /auto-log as a steer and restores the draft (chat-controller.ts:1031-1038).
  • Invariants line: "1 to 9 and 9b to 9d" with the 9b, 9c and 9d names equals AGENTS.md.
  • X1–X10 in the TUI row: the registry now lists X1 to X10. 4,400+ tests: the full pytest at the live head had 4487 passed. Versions (zycode-agent 1.1.0, VS Code 1.12.0), the 23 core modules and the 80 crates are correct.
  • The status line and the Phase 5.2 text say the work is in PR feat: mid-turn steer (X9) and ephemeral /btw side chat (X10) #157 and that the release comes after the merge; this is consistent with an open PR.
  • No Python or Rust file, workflow or wire shape changed in these 4 commits.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cursor

cursor Bot commented Nov 27, 2026

Copy link
Copy Markdown

Re-review result (delta 3): APPROVE (0 blocking, 3 non-blocking)

This is a post-merge check of ec49e28 (squash of #157 on main). The merged head is a9d20215e0a669417e4bf73ad06998047f8b30a3, the head that I reviewed. It repeats my earlier delta 3 comment (#157 (comment)) with the post-merge status of each finding and the corrected line numbers. Scope: the four commits 1420830, 340c902 (vscode/ only) and 6b2e9e1, a9d2021 (docs only).

No finding affects users of main. All 3 findings are in docs only. No code needs a change.

Checks

Check Result
cd vscode && npm run check at a9d2021 pass: 552 passed, 17 skipped (569 total). Done before the merge. The merged tree is the same (you checked tree and patch-id)
Mutation A (temporary edit, restored): remove the idle Esc block from vscode/src/webview/main.ts Escape in the main input closes an open /btw panel when the agent is idle fails
Mutation B (temporary edit, restored): old restore join ("\n") at the restore sites only restores the idle-fallback text with the same separator as the send ... fails; the other 13 tests in the file pass
*.py and *.rs files changed since 2a58a0c 0. Earlier results (delta 2: pytest 4487 passed, pi-acp-lib 48, pi-pager steer_and_btw 5, python_agent_e2e 19) apply
Identity check on the four commits (author, committer, message) 0 matches for the mail provider you named (no address printed)
CI of the head before the merge 21 pass, 3 skipped (Publish, Attach to the release, Release build baseline), 0 fail; VSIX smoke test passed
main after the merge ec49e28; I re-read the finding lines on origin/main: all 3 are still there

Not run again: ruff, pytest, cargo and e2e (no Python or Rust file changed since 2a58a0c); Windows and macOS locally; a real VS Code window. I did not re-check the squash itself (you did).

Blocking

None.

Non-blocking (all docs only; no effect on users of main)

1. The roadmap says the history limit is "20 turns". The code limit is 10 turns (20 messages). Docs only.
docs/specs/2026-11-25-zycode-refactor-and-roadmap.md:98 and :118 (still present on main).
Code on main: packages/pi-agent-cli/pi_agent_cli/btw.py:38 (BTW_MAX_HISTORY_TURNS = 10) and :101 (rejects more than BTW_MAX_HISTORY_TURNS * 2 messages); VS Code chat-controller.ts:97 (MAX_BTW_HISTORY_TURNS = 10). The sibling spec says "10 轮 / 32 KB" (2026-11-26-pre-refactor-steer-and-btw-design.md:162). Behaviour is correct: the client trims to 10 turns, the agent accepts 10 turns. Only the text is wrong. Fix: write "10 轮(20 条消息)" in both lines.

2. The VS Code test count "548" is wrong, and the table row mixes two baselines. Docs only.
docs/specs/2026-11-25-zycode-refactor-and-roadmap.md:23 (the vscode/ row; the line number on main is 23).
Live count is 552 passed, 17 skipped. main before the PR had 534. "11,110 lines" is the count before the PR; on main now it is 12,037 (my count of vscode/src/**/*.ts). The Python and Rust line counts in the neighbouring rows are also from before the PR (my counts now: 36,203 and 990,087; my method may differ). The counts of core modules (23) and crates (80) are correct. Fix: use one baseline and name it, or remove the counts.

3. "Invariant S2" in the roadmap risk table is the steer spec's S2, not an AGENTS.md invariant. Docs only, minor.
docs/specs/2026-11-25-zycode-refactor-and-roadmap.md:588. AGENTS.md has Invariants 1 to 9 and 9b to 9d. The steer spec uses the same words ("不变量 S2", ...design.md:258), so the text is consistent inside the specs. Fix (optional): write "S2 of the steer design spec".

Corrections to my earlier comment (line numbers only; the findings are unchanged)

My earlier comment gave a few wrong line numbers. Correct values on main: /btw advertised to opt-in clients only at agent.py:1804 (not 1792); the /btw slot limit at agent.py:870 (not 868); the new idle Esc block in vscode/src/webview/main.ts is at about :2527-2531 (the btwClose send is at :2529), not :2521-2537; the vscode/ roadmap row is line 23. The code lines chat-controller.ts:134, :1332, :1341, :1347 and btw.py:38, :101 in my comments are correct.

Status of my delta 2 items (on main)

# Item Status
1 Esc from the main input did not close an open /btw panel when idle Fixed: busy gives cancel, then an open panel gives btwClose, then history restore; closeBtw also cancels requests that still run (chat-controller.ts:1228-1239). New test fails without the block (mutation A)
3 Send and restore used different separators for idle-fallback text Fixed: joinIdleFallbackTexts is the one join for the send and for both restore paths. New test fails with the old join (mutation B)

Checked and fine

  • The Auto note: note_user_message is called at injection (message_start) only, never at enqueue (S2); the roadmap text and the steer spec agree with the code.
  • Steer reject reasons idle | aborting | waiting_for_trust | waiting_for_barriers; field and wire names steerId, clearedSteerIds, clearedByAbort, thought_delta / text_delta, pi/btw_update, pi/session/btw_cancel equal registry X9 and X10.
  • /btw is advertised only to clients that opt in; a literal /btw over session/prompt gets a notice and no LLM call.
  • Numbers: 4,000 characters for tool results, 2 concurrent per session, 32 KiB UTF-8, timeout_seconds default 120 s with range 5 to 600 s, [btw].thinking is "off" or "inherit".
  • Rust paths pi-acp-lib/src/extensions/steer.rs and btw.rs exist; the TUI runs the slash registry before the steer dispatch.
  • The invariants list in the roadmap (1 to 9, 9b to 9d) equals AGENTS.md.
  • No Python or Rust file, workflow or wire shape changed in the four commits.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zy1233 added a commit that referenced this pull request Nov 27, 2026
@zy1233
fix(harness): report steers the model never saw, hold steer messages,…
b73298c
… scope cancel to its prompt

Three faults in the steer and cancel code of #157, found by an architecture audit.

C1 - A steer was lost without a report. The agent loop takes the steers out of
the queue at the end of a turn. When max_turns or a stream error then ended the
run before the loop injected them, the harness did not report them (it looked
only at steer_queue), so the client got no clearedSteerIds. Each steer now has
an entry with a state (pending, announced, cleared). message_start sets
"announced", abort() sets "cleared", and a run that ends reports every
"pending" steer in the order of the calls of steer().

C2 - The map of steers was keyed by id(message) and held no reference to the
message, so CPython could give the id of a freed steer to a later message. The
entry now holds the message, steer_id_for() and is_steered_message() test that
it is the same object, and the agent passes a message to Auto only when its role
is "user" (invariant 9b).

C3 - begin_abort() raised a counter, and a prompt ended as aborted while the
counter was above zero. A prompt that came after a cancel, while the abort() of
that cancel was still sending notifications, ended as aborted. That abort() also
waited for the next run to end, so is_aborting stayed true for all of it and
steers were refused. A prompt now notes an abort epoch when it begins and ends
as aborted only for a cancel that comes after that. Each busy period has its own
idle event, and abort() waits only for the one that it saw when it began.

Each fault has a regression test that fails on the code before this change. The
registry entry of pi/session/steer and the changelog say what the contract is.
zy1233 added a commit that referenced this pull request Nov 27, 2026
@zy1233
chore(vscode): release 1.14.0 with agent 1.2.0
1d70cb1
The extension moves from 1.12.0 to 1.14.0 (stable). It bundles agent
1.2.0 (it was 1.1.0). A user of 1.12.0 gets it as an update.

- vscode/package.json and package-lock.json: version 1.14.0,
  zycodeAgentVersion 1.2.0.
- vscode/agent-assets.json: tag v1.2.0, the six Python pins, and the
  size and sha256 of the five agent archives. The values come from the
  GitHub Release v1.2.0. The packaging step checks each sha256 again
  when it downloads the archive.
- vscode/CHANGELOG.md and README.md: Steer, the /btw side chat, skills
  in the / menu, and the agent 1.2.0 changes that a chat user sees.
- docs/specs/2026-11-04-vscode-extension-design.md and AGENTS.md: record
  the new pin and the two features.
- CHANGELOG.md: add the entry for mid-turn steer and /btw to [1.2.0]. It
  was missing when 1.2.0 was tagged (#157).

Test fix: the scenario steer-idle-race of the fake agent ended the turn
after a fixed 60 ms. When the two steers of a test took longer than
that (a slow or busy machine), the turn ended first. The text then went
out as a normal prompt, and two tests failed: S3 and "restores the
idle-fallback text". Both failed in local runs of npm run check. The
scenario now keeps the turn open until the agent has answered the wanted
number of steers with "idle" (steer-idle-race:<n>). The restore test
also sets its spy before the turn starts.

Checked: with a 120 ms pause between the two steers, S3 failed before
this change and passes after it. npm run check: 550 passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@zy1233 @cursoragent
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.