Repository navigation
feat(kas): reject a tool with a reason, and trust a file write by path - #33031
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The reason is sent only on KAS's one-time Deny, and the file grant is keyed on the hex of the path from the harness's own frames, so it cannot cover more than one file. Notes
[DESIGN-REVIEWED] ea1cae7 Description read[DESCRIPTION-READ] fb77bd160cea2edfc38a9ea2718e04877d8c0ebda26dd8dbab80ce46699a2446 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Both additions trace to the migration rows in #32975, neither duplicates an existing mechanism, and no default changes. A person gets each only by choosing it on a card. Not checked: that KAS reads What this change shipsInventory (7 items) — 6 justifiedIntent: on KAS, let a person tell the agent why they rejected a tool call, and let them trust a file-write tool for one exact file. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] ea1cae7 Description read[DESCRIPTION-READ] 4bb19f3aac8d882501f08566fe23e53b3f432a29597def0bf94c9fcacff288f7 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)UX-level review of UX-Verdict: PASS cannot evaluate: missing a screenshot of the file-write card's new "Trust" choice and of the "Trusted file not applied" notice. They are half of this PR's goal, and no supplied image shows either. Evidence gaps
Notes
[UX-REVIEWED] ea1cae7 Description read[DESCRIPTION-READ] 5b4b503fef4d282dd3cb9d8c8248f365db9fbef59eec8e40cdd8d85fc02c3c7a That sha256 names everything this verdict read: the PR description, plus the 5 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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
c6b1ae1 to
1607f47
Compare
|
self-added: yes
|
1607f47 to
a639465
Compare
|
self-added: yes
|
d2475fd to
8cdc56c
Compare
On KAS, a one-time Deny can carry the person's reason as _meta.kiro.rejectionReason, which KAS hands to the model. The card shows a reason box only where the backend reads one. File-write built-ins (fs_write, fs_append, str_replace, delete_file) can be trusted for one exact absolute path, kept in Crew's grant store; anything Crew cannot match exactly keeps asking. Part of #32975
8cdc56c to
ea1cae7
Compare
|
UX note (verdict PASS, advisory): the file-write card has no new button. It uses the existing "Trust this command" choice, and its label now reads |
bolichen97
left a comment
There was a problem hiding this comment.
Approving at ea1cae7. All checks pass, there are no change requests, and the branch is mergeable.
What I checked:
- Reject with a reason. The reason is optional and goes only with a one-shot rejection of the slot's own native card, and only to a backend whose request takes one (
takes_rejection_reason). Neither a host auto-decline nor a deny-rule override card carries one.rejection_reason_textdrops control characters, trims, and caps the reason at 1000 characters. A bad value is refused with a 400 before any side effect, not cut, so the model never reads half a reason. The reason is bound to the exact future it answered, and it is taken on every path out, so a reused request id cannot inherit it. - Trust a file write by path. This is a new, narrower grant: one write tool (
fs_write,fs_append,str_replace,delete_file) on one absolute, normalized file. Relative paths,.., two paths and a capped scan get no grant and keep asking. Reads are left out, with ashortcut:comment giving the reason. The key is hex-encoded, so no fnmatch character reaches the matcher. A path that now leads through a link is declined and asks again, both when it is offered and when it is honoured. - Everything here only adds options. A call that asked on main still asks unless the person picks the new grant. No regex.
Problem / Motivation
Goal: On KAS, a person can tell the agent why they rejected a tool call, and can trust a file-write tool for one exact file instead of the whole tool.
On the KAS backend a rejection reaches the model as a bare "rejected": the reject menu has no place for a reason, and
reject_toolsends none, though KAS reads_meta.kiro.rejectionReasonon a one-time Deny and hands it to the model. File writes (fs_write,fs_append,str_replace,delete_file) offer no grant scoped to the file, so a person either trusts the whole tool or approves every write. Rows P1-26 and P1-25 of the kiro-cli -> KAS migration (#32975).Why it matters
Without a reason the model often retries the same call, and the person has to type a second message to steer it. Without a file-scoped grant, repeated edits to one file mean either a prompt per write or a grant far wider than the person meant.
Not a goal
_meta.kiro.consent.resource.globorgrep(see the shortcut note intrust_patterns.py).What changed (motivation → approach → change)
Reject with a reason. KAS reads a reason only on its one-time Deny. When a KAS request offers one, the card gets a reason box in the reject menu. The text is cleaned (control characters dropped, trimmed) and refused, not cut, past 1,000 characters. The slot-approve route keeps it until the waiting turn reads it. The turn passes it on only for the person's own rejection, never for a host auto-decline. Both
reject_toolsites send it as_meta.kiro.rejectionReasonon KAS only.Trust a file write by path. A file-write card can offer "always" for this tool on this one file. The grant is kept in Crew's own grant store and binds the tool name to the hex of the path, so no glob character in the path can widen it. It is offered only when the tool name and arguments come from the harness's own frames, the arguments name exactly one absolute, normal path, and no link stands at or above it. A grant whose path later leads through a link is not applied: the call asks again and the card says why. Anything Crew cannot match exactly keeps asking, as main does. A deny-rule override card shows no reason box, because its rejection is the rule's own refusal.
Where:
src/kiro_crew/rejection_reason.py, so the dashboard route and the ACP layer share it.acp/types.py(_metabuilder, event flags),acp/_dispatch_parts/permission_requests.py,acp/client_permissions.py,acp/session_handle_permissions.py,acp/session_provider.py,providers/acp.py,providers/acp_turns.py.dashboard/chat_api/slot_approval.py,dashboard/state_parts/chat_slot.py,dashboard/state_parts/slot_turns.py,dashboard/chat_turn/permission_prompt.py,dashboard/chat_turn/deny_chokepoints.py.trust_patterns.py,dashboard/chat_turn/tool_approval.py,dashboard/chat_turn/permission_prompt.py.components/RejectDropdown.tsx,components/ChatInput.tsx,components/chat-input/approval.ts, and one new string (reason_placeholder) in each locale, e.g.website/src/i18n/locales/en.manual.json.Backwards compatibility
Compatible:
reject_tooltakesreasonas an optional keyword; a call without it sends the same frame as before. The new card field and route field are optional, and a card without them behaves as today.Removes nothing: the diff only adds an optional reason and a new, narrower grant kind; no key, route, grant or test is removed.
Tests
test/test_kas_reject_reason_and_path_trust.py(new):reject_toolsites send the reason on KAS only, and none without a deny option;.., two paths, an MCP tool, or untrusted params; a link at or above the path withholds the grant;test/test_deny_session_override.py: a deny-rule override card offers no reason box, since its rejection is the rule's own refusal.website/src/test/ChatInput.approval.test.tsx: the reject menu shows the box only when the card takes a reason, sends the trimmed text with the native one-shot reject, and a replacement card row reusing the same approval id starts with an empty box.website/src/test/RejectDropdown.reason.test.tsx(new): the box is reachable by keyboard (ArrowUp from the first choice, ArrowDown back), typed letters stay in the box, Escape still closes the menu, and closing the menu drops the text.The three binding tests carry the new
reject_toolsignature digest.Manual verification
N/A — unit coverage of both routes and both transports; the KAS end of the frame is read from KAS's
permission-options.ts.Screenshots / video
Reject menu on a KAS card, which takes a reason:
Reject menu on any other card (unchanged from main):
The file-path grant reuses the existing "Trust this command" choice, whose label now shows the tool and the file (
fs_write /abs/path).Related Issues
Part of #32975
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)