Skip to content

feat(kas): reject a tool with a reason, and trust a file write by path - #33031

Merged
bolichen97 merged 1 commit into
mainfrom
fix/kas-n8b-approvals
Nov 8, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/kas-n8b-approvals

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

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_tool sends none, though KAS reads _meta.kiro.rejectionReason on 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

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_tool sites send it as _meta.kiro.rejectionReason on 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:

  • Reason rule: new src/kiro_crew/rejection_reason.py, so the dashboard route and the ACP layer share it.
  • Sending it: acp/types.py (_meta builder, 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.
  • Keeping and passing it: 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.
  • File grant: trust_patterns.py, dashboard/chat_turn/tool_approval.py, dashboard/chat_turn/permission_prompt.py.
  • Card: 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_tool takes reason as 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):

  • the reason is cleaned and refused past the cap; only a KAS request with a one-time Deny takes one;
  • both reject_tool sites send the reason on KAS only, and none without a deny option;
  • the slot-approve route keeps the reason for the turn and refuses one it cannot send;
  • a turn sends the person's reason only where the request takes one;
  • a file grant covers that tool on that file only; no grant for a relative path, .., two paths, an MCP tool, or untrusted params; a link at or above the path withholds the grant;
  • the card offers the file grant, and a grant approves that file and asks for another.

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_tool signature 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 with the reason box

Reject menu on any other card (unchanged from main):

Reject menu without the reason box

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

  • 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

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 8, 2026 08:27
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of ea1cae7209418692f48079304f62138649c788b8 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The link check (path_trust_unresolved) runs before KAS writes the file, so a link swapped in after the check still gets the write. Say in the trust_patterns.py shortcut note that this check narrows the risk but does not close it.
  • "Manual verification: N/A" leans on reading KAS's permission-options.ts. One live KAS reject with a reason, showing the model reads _meta.kiro.rejectionReason, would prove the wire end that unit tests can't.

[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 .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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of ea1cae7209418692f48079304f62138649c788b8 — 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 does not.

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 _meta.kiro.rejectionReason only on a one-time Deny (KAS permission-options.ts is not in this repo).

What this change ships

Inventory (7 items) — 6 justified

Intent: 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.

  1. The reject menu on a KAS card that offers a one-time Deny now has a reason box — justified
  2. The typed reason reaches the model as _meta.kiro.rejectionReason, only on KAS and only when the person rejected it themselves — justified
  3. A reason that is not text or is over 1,000 characters is refused (400), not cut — justified
  4. File-write cards (fs_write, fs_append, str_replace, delete_file) now offer "always" for this tool on this one absolute file, and the label shows the tool and path — justified
  5. A file grant whose path now leads through a link is not applied: the call asks again and the card says why — justified
  6. A deny-rule override card shows no reason box — justified
  7. The _override_offer lookup moved earlier in permission_prompt.py — rides along

[FIRST-PRINCIPLES-REVIEWED] ea1cae7

Description read

[DESCRIPTION-READ] 4bb19f3aac8d882501f08566fe23e53b3f432a29597def0bf94c9fcacff288f7

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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of ea1cae7209418692f48079304f62138649c788b8 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • File-path trust choice. The diff gives the existing "Trust this command" choice a new scope and label for fs_write/fs_append/str_replace/delete_file (# The card's label IS the grant's scope: the tool and the whole path.). The screenshot list has only shot-01 and shot-02, and both show just the reject menu. To close the gap, attach a screenshot of a file-write card with its trust choices open.
  • Link-withheld notice. New text in permission_prompt.py: "🛡️ Trusted file not applied — the path now leads through a link, which the grant does not cover. Approve this change explicitly." No screenshot shows it. To close the gap, attach a screenshot of a card showing this notice.
  • Empty reason box. The box's only label is its placeholder, "Why? The agent reads this (optional)". shot-01 shows the box already filled, so the placeholder never appears, and the blind reader said: "The text box has no label and no send button, so I don't know what it's for." To close the gap, attach a screenshot of the reject menu with the box empty.

Notes

  • The label fs_write /abs/path puts an internal tool id in front of the user. Use a task word instead, e.g. "Trust edits to /abs/path".
  • The reader couldn't tell whether the typed reason goes with "Reject once", "Reject all" or both, though the code sends it with either. Add a short hint under the box such as "Sent with whichever you pick".

[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 .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 Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ea1cae7

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ea1cae7209418692f48079304f62138649c788b8 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] ea1cae7

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable ea1cae7209418692f48079304f62138649c788b8 false-positive: <reason, 20 to 500 characters>

@iamwhatever
iamwhatever force-pushed the fix/kas-n8b-approvals branch from c6b1ae1 to 1607f47 Compare November 8, 2026 08:46
@iamwhatever

iamwhatever commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: test fixtures only; no production change

  • span=0ccf2b84436b Make the path-trust fixtures portable to Windows

fixed in 1607f47: the positive path-trust assertions build native absolute paths from os.path.realpath(tmp_path), and the expected label uses the same path, so the normal-form check passes on Windows and macOS.
fixed in 1607f47: the link fixture uses make_dir_link (an unprivileged junction on Windows) instead of a bare os.symlink.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@iamwhatever
iamwhatever force-pushed the fix/kas-n8b-approvals branch from 1607f47 to a639465 Compare November 8, 2026 11:03
@iamwhatever

iamwhatever commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: test harness only; no production change

  • span=0ccf2b84436b Bound the chat waits and always drain answerers

fixed in d2475fd: the three turn-driving tests run the chat turn through testing.wait.finished(...) inside one helper, and drain the answerer in finally.
Checked by removing the file grant: the test now fails by name in about 63 s on Linux instead of parking on the 600 s approval wait.

@iamwhatever
iamwhatever force-pushed the fix/kas-n8b-approvals branch 2 times, most recently from d2475fd to 8cdc56c Compare November 8, 2026 11:53
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
@iamwhatever
iamwhatever force-pushed the fix/kas-n8b-approvals branch from 8cdc56c to ea1cae7 Compare November 8, 2026 12:34
@iamwhatever

Copy link
Copy Markdown
Contributor Author

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 fs_write <absolute path>, so the grant's whole scope is on the button. The "Trusted file not applied" line is the existing declined-grant notice row with new text. It shows only when a link appears at or under a granted path after the grant was made. Both reuse components that main already renders, so I am not adding screenshots for them in this PR.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 8, 2026

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

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_text drops 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 a shortcut: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants