|
| 1 | +# wp2 — make the blocked-on-user state expressible |
| 2 | + |
| 3 | +One change, in the injected contract, carried on every surface that describes |
| 4 | +when to complete. It removes the contradiction that made continuing to work the |
| 5 | +model's only endorsed move. No adapter enforcement is added, because no |
| 6 | +non-heuristic signal exists to enforce on. |
| 7 | + |
| 8 | +## A blocking question is a valid final answer |
| 9 | + |
| 10 | +The pause state rides the channel that already terminates correctly. A |
| 11 | +completion answer yields `final_answer` and `done(endTurn: true)` |
| 12 | +**regardless of what the answer says** — verified in `kiro.ts` at the |
| 13 | +completion terminal. So a question delivered there ends the turn today, with no |
| 14 | +new event type, no new phase, and no change to `endTurn` semantics for real |
| 15 | +tools. |
| 16 | + |
| 17 | +`KIRO_COMPLETION_INSTRUCTIONS` therefore gains one clause: when the model needs |
| 18 | +a decision from the user before it can continue, that question IS its final |
| 19 | +answer — deliver it through the completion tool and stop, instead of writing the |
| 20 | +question as prose and then answering itself. |
| 21 | + |
| 22 | +The completion tool's own schema carries the same clause. That description is the |
| 23 | +surface the model reads while CHOOSING a tool, and it admitted only "fully |
| 24 | +complete"; a model holding a blocking question reads the tool as unavailable and |
| 25 | +keeps working, which is the defect. Round one changed only the terminality half of |
| 26 | +this description and left the eligibility half narrow, which is part of why prose |
| 27 | +alone did not move the outcome. The `answer` property description is widened the |
| 28 | +same way, since it is what tells the model what may go in the field. |
| 29 | + |
| 30 | +This is deliberately NOT conditioned on an ask tool being present. An earlier |
| 31 | +draft keyed it on `request_user_input` appearing in the emitted catalog, which |
| 32 | +would have named a tool that is absent from most turns and contradicted the |
| 33 | +nudge's rule that instruction-only names are not callable (the failure mode |
| 34 | +`0325a5afd` fixed for the catalog nudge). The completion tool is always present |
| 35 | +when this instruction is emitted — that is the condition under which the |
| 36 | +instruction exists at all — so the clause can never name something uncallable. |
| 37 | + |
| 38 | +`KIRO_COMPLETION_RETRY_MESSAGE` currently ends with *"Do not ask the user for |
| 39 | +another task or emit another progress-only message."* In context that forbids |
| 40 | +soliciting NEW work, but it reads as a blanket ban on asking, and it is the one |
| 41 | +instruction the model sees at exactly the moment it failed to complete. It is |
| 42 | +narrowed to keep forbidding a request for another task while making a blocking |
| 43 | +question an explicitly acceptable final answer. |
| 44 | + |
| 45 | +Both sites are compared by constant, never by inline literal |
| 46 | +(`currentUim.content !== KIRO_COMPLETION_RETRY_MESSAGE`), and both pinning |
| 47 | +tests assert against the constant, so editing the text cannot desynchronize the |
| 48 | +equality checks that keep the bounded retry from stacking. |
| 49 | + |
| 50 | +This depends on model compliance and is labeled as such. It is the reason this |
| 51 | +unit does not promise impossibility: the tests prove the contract is delivered, |
| 52 | +not that the model obeys it. |
| 53 | + |
| 54 | +## Ask-tool isolation: considered and dropped |
| 55 | + |
| 56 | +An earlier draft added a `flushOpen` invariant: once a turn emitted the ask |
| 57 | +tool, a later real tool call from the same inference would fail closed. It is not |
| 58 | +being implemented, for three independent reasons. |
| 59 | + |
| 60 | +It is unreachable. Measured across 644 Kiro rollouts: 8 `request_user_input` |
| 61 | +calls, and the ask-then-another-real-tool shape occurs **0** times. |
| 62 | + |
| 63 | +It cannot be keyed safely. `nameMap` aliases every REQUESTED tool before |
| 64 | +admission, and admission can omit tools, so `nameMap` membership does not prove |
| 65 | +a tool was emitted. Doing it correctly means threading an explicit emitted-ask |
| 66 | +identity through `buildRequest`, the fallback state, and `parseKiroStream`. |
| 67 | + |
| 68 | +It can false-positive. `OcxTool` carries no "asks the user" marker, and the |
| 69 | +parser reduces ordinary function tools to the same generic shape, so an unrelated |
| 70 | +bare function named `request_user_input` is indistinguishable from Codex's ask |
| 71 | +tool. Claiming it "cannot affect any ordinary tool" was an overclaim. |
| 72 | + |
| 73 | +Three costs and a measured zero benefit. The previous unit already shipped and |
| 74 | +then reverted a guard for an unreachable path; this one declines it before the |
| 75 | +commit instead of after. |
| 76 | + |
| 77 | +## What is NOT changed, and why |
| 78 | + |
| 79 | +No prose-shape gate. No length threshold. No discard of staged commentary. The |
| 80 | +measurement in `000_research.md` shows the 4 defect cases (1329-1938 chars) and |
| 81 | +the 22 legitimate ones (608-3141) overlap completely, so every such rule is a |
| 82 | +coin flip on whether the user sees their agent's work. |
| 83 | + |
| 84 | +No change to `src/router.ts`, `src/server/lifecycle.ts`, or |
| 85 | +`src/server/responses/core.ts`: the Lab core boundary is unrelated and |
| 86 | +`tests/core-lab-boundary.test.ts` guards it. No change to the shared |
| 87 | +`tool-catalog-nudge` sentence or its pinned test. |
| 88 | + |
| 89 | +## Tests |
| 90 | + |
| 91 | +**Red-first, contract shape:** every emitted completion contract carries the |
| 92 | +pause clause, and the retry message permits a blocking question as a final |
| 93 | +answer. Driven red against the current strings before the edit. |
| 94 | + |
| 95 | +**Non-regression, the 22:** staged progress prose followed by `exec` still |
| 96 | +yields the prose as `commentary` and `done(endTurn: false)` with the tool call |
| 97 | +relayed, byte-identical to today, parameterized across the measured lengths |
| 98 | +608 / 1329 / 1454 / 1938 / 3141. This is the test that protects the user's |
| 99 | +"회귀없도록" requirement, and it must pass unchanged both before and after the |
| 100 | +diff. |
| 101 | + |
| 102 | +## Budget truncation: measured unreachable, pinned by test |
| 103 | + |
| 104 | +The completion contract is charged last against |
| 105 | +`MAX_KIRO_INJECTED_INSTRUCTION_CHARS` (16384), so in principle a large enough |
| 106 | +injected context could slice the pause clause mid-sentence. Measured against a |
| 107 | +hostile catalog (80 requested tools, 64-character names, 6000-character |
| 108 | +descriptions): |
| 109 | + |
| 110 | +| Charged item | Chars | |
| 111 | +| --- | --- | |
| 112 | +| Omission notice | 922 | |
| 113 | +| Catalog nudge | 2432 | |
| 114 | +| Total before the contract | 3354 | |
| 115 | +| Headroom | 13030 | |
| 116 | +| Contract | 696 | |
| 117 | + |
| 118 | +Both charged inputs are structurally capped — the notice names at most 12 tools, |
| 119 | +the nudge is bounded by the 48-tool and 64-character limits — and the caller's |
| 120 | +system prompt is not charged to this budget at all. So no reachable input |
| 121 | +approaches the slice boundary. |
| 122 | + |
| 123 | +A reservation guard is therefore dead code, and the previous unit already proved |
| 124 | +its test would be vacuous: it passed with the guard removed. Instead this unit |
| 125 | +pins the property that makes truncation unreachable, at BOTH hostile extremes, |
| 126 | +asserting the contract arrives COMPLETE including its closing pause clause: |
| 127 | + |
| 128 | +- **Largest nudge:** `MAX_KIRO_TOOL_COUNT` admitted tools with unique 64-character |
| 129 | + names and one-character descriptions. Every admitted tool is named in the nudge, |
| 130 | + so this maximizes the charged nudge. Nothing is omitted, which the test asserts |
| 131 | + so it cannot pass while silently charging less than it claims. |
| 132 | +- **Notice plus nudge:** oversized descriptions on twice the tool limit, which |
| 133 | + forces admission to omit and charges the omission notice on top of the nudge. |
| 134 | + The test asserts the notice is actually present for the same reason. |
| 135 | + |
| 136 | +The 6000-character-description shape alone would not have been enough: it reduces |
| 137 | +the admitted count and therefore shrinks the nudge, so it never probes the |
| 138 | +largest charged input. Both tests fail if a future change lets the notice or the |
| 139 | +nudge grow without bound. A reservation's test could not detect its own removal. |
| 140 | + |
| 141 | +## Verification |
| 142 | + |
| 143 | +`bun run typecheck`, the focused Kiro suites, and `bun run privacy:scan`. The |
| 144 | +full local suite is excluded by explicit user instruction; CI covers it. |
0 commit comments