Skip to content

feat: explain tool auto-approval - #12494

Merged
bagatao-anaconda merged 18 commits into
mainfrom
feat/explain-tool-auto-approval
Jul 24, 2026
Merged

feat: explain tool auto-approval#12494
bagatao-anaconda merged 18 commits into
mainfrom
feat/explain-tool-auto-approval

Conversation

@bagatao-anaconda

Copy link
Copy Markdown
Collaborator

Issue

Fixes the issue described here: https://docs.google.com/document/d/1GSiAEQ7DQatMxEmyTplobWtxJWHOs_4OXKtI_3nsDf8/

Context

Users often can't tell why a tool call ran without a prompt — auto-approval can come from agent defaults, global config, project config, or YOLO mode, and the last matching rule wins (not the most specific). This wastes time for users and support.

This surfaces the reason inline: expanding a tool call now shows whether it ran automatically or after your approval, and which rule allowed it — attributed to its source: agent, project config, global config, YOLO mode, or manual.

Implementation

  • The config loader tracks which scope (global vs project) last set each permission key, mirroring the existing instruction_origins pattern.
  • Permission rules are tagged with their source as the ruleset is assembled; Permission.ask now returns the deciding rule, and a Kilo-owned PermissionProvenance module classifies it (including YOLO and saved-"always" approvals).
  • The result is stored on the tool call's state.metadata, so it rides existing SSE/SDK plumbing — no schema or route changes. A carryApproval helper keeps the provenance from being clobbered by later tool metadata writes.
  • Rendered as a single line in the expanded tool row (kilo-ui BasicTool), including the extension's custom bash/todo cards.

Scope: backend (opencode) + VS Code webview. TUI/JetBrains are unchanged but the metadata is available to them for a follow-up. Project config is cached per instance and not hot-reloaded on edits (pre-existing behavior), which is now documented in the auto-approve docs.

Screenshots / Video

kilo-auto-approve

How to Test

Manual/local verification

  • (human) Ran the VS Code extension, triggered auto-approved tool calls, and confirmed the expanded row shows the correct source across agent / project config / global config / YOLO / manual approvals.

Reviewer test steps

  1. Open a project and send a prompt that runs a tool (e.g. "run echo hi").
  2. Expand the tool call in chat and confirm the "why approved" line appears with a source and matched rule.
  3. Add { "permission": { "bash": { "echo *": "allow" } } } to .kilo/kilo.json, reload the window, rerun, and confirm the line now cites the project config.
  4. Toggle auto-approve (YOLO) mode and confirm the line cites auto-approve mode; set a tool to ask, approve manually, and confirm it shows Approved by you.

Blocked checks and substitute verification

  • @kilocode/kilo-jetbrains#typecheck could not run locally (requires JDK 21; only JDK 26 installed). Not touched by this change; CI runs it on a Java 21 runner. All affected packages pass locally: bun test (new provenance.test.ts / permission-origins.test.ts + updated permission suites), opencode/ui/kilo-vscode typecheck, lint, knip, and the opencode annotation check.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

Comment thread packages/ui/src/components/tool-approval.tsx Outdated
Comment thread packages/ui/src/i18n/en.ts Outdated
Comment thread packages/opencode/src/kilocode/session/prompt.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Previous WARNING is resolved: askPermission now tags both the agent and session rulesets (PermissionProvenance.tagAgent / tagSession) before guardPermissions re-appends the agent copy for ask/plan/architect agents, so the duplicate is no longer untagged and can't be misclassified as yolo/agent. A regression test covers this exact case. The packages/uipackages/kilo-ui and packages/ui/src/i18n/en.ts → kilo webview i18n relocations requested in review comments have also been made, with full translations added across all locale files (not left as English placeholders).

Files Reviewed (incremental, 24 files)
  • packages/opencode/src/kilocode/session/prompt.ts - fixed
  • packages/opencode/src/kilocode/permission/provenance.ts
  • packages/opencode/src/config/config.ts
  • packages/opencode/test/kilocode/permission/provenance.test.ts
  • packages/opencode/test/kilocode/permission/permission-origins.test.ts
  • packages/kilo-ui/src/components/basic-tool.css
  • packages/kilo-ui/src/components/basic-tool.tsx
  • packages/kilo-ui/src/components/message-part.tsx
  • packages/kilo-ui/src/components/tool-approval.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/AssistantMessage.tsx
  • packages/kilo-vscode/webview-ui/src/i18n/*.ts (all locales)
  • packages/ui/src/components/basic-tool.css - reverted to upstream
  • packages/ui/src/components/basic-tool.tsx - reverted to upstream
  • packages/ui/src/components/tool-approval.tsx - removed
  • packages/ui/src/i18n/en.ts - keys removed
Previous Review Summary (commit 69960b1)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 69960b1)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/kilocode/session/prompt.ts 250 Provenance can be misattributed to "yolo"/"agent" for ask/plan/architect agents because guardPermissions re-appends an untagged copy of agent.permission that can shadow the tagged copy in findLast resolution
Files Reviewed (19 files)
  • .changeset/tool-auto-approval-provenance.md
  • packages/kilo-docs/pages/getting-started/settings/auto-approving-actions.md
  • packages/kilo-ui/src/components/message-part.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/AssistantMessage.tsx
  • packages/opencode/src/config/config.ts
  • packages/opencode/src/kilocode/permission/provenance.ts
  • packages/opencode/src/kilocode/session/prompt.ts - 1 issue
  • packages/opencode/src/kilocode/tui/config.ts
  • packages/opencode/src/permission/index.ts
  • packages/opencode/src/session/processor.ts
  • packages/opencode/src/session/tools.ts
  • packages/opencode/test/kilocode/permission/next.always-rules.test.ts
  • packages/opencode/test/kilocode/permission/permission-origins.test.ts
  • packages/opencode/test/kilocode/permission/provenance.test.ts
  • packages/opencode/test/kilocode/sandbox/session-tools.test.ts
  • packages/opencode/test/permission/next.test.ts
  • packages/ui/src/components/basic-tool.css
  • packages/ui/src/components/basic-tool.tsx
  • packages/ui/src/components/tool-approval.tsx
  • packages/ui/src/i18n/en.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 36 · Output: 13K · Cached: 1.1M

Review guidance: REVIEW.md from base branch main

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What happens when global and project config contribute different patterns under the same permission key?

For example, global config has:

{
  "permission": {
    "bash": {
      "git status": "allow"
    }
  }
}

And project config has:

{
  "permission": {
    "bash": {
      "npm test": "allow"
    }
  }
}

@bagatao-anaconda

Copy link
Copy Markdown
Collaborator Author

@marius-kilocode

What happens when global and project config contribute different patterns under the same permission key?

Good catch, this was actually a bug. Provenance was tracked per permission key, so both patterns landed under bash and it just reported the last scope (project) for both. So a global git status rule showed as "project config."

Fixed by tracking per key + pattern, so we'd now get something like:

{ bash: { "git status": "global", "npm test": "project" } }

for the config you described.

@marius-kilocode marius-kilocode left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@bagatao-anaconda please fix the typecheck and manually retest. Then this is good to merge.

@bagatao-anaconda
bagatao-anaconda merged commit 5b86624 into main Jul 24, 2026
32 checks passed
@bagatao-anaconda
bagatao-anaconda deleted the feat/explain-tool-auto-approval branch July 24, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants