Repository navigation
ADFA-7147 AI-Core: let "Always Allow" cover a contributed tool declared read-only #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,15 +57,26 @@ class ContributedToolHandler( | |
| * A source's own `requiresApproval = false` would return from | ||
| * `ToolApprovalManager.ensureApproved` before [allowsSessionApproval] below is ever consulted, | ||
| * so a provider could opt out of the only control there is by asking. The declaration is kept | ||
| * on [ContributedTool] for a host-side allowlist to honour one day; nothing honours it now. | ||
| * on [ContributedTool] for a host-side allowlist to honour one day (ADFA-7147); nothing | ||
| * honours it now. | ||
| */ | ||
| override val requiresApproval: Boolean = true | ||
|
|
||
| /** | ||
| * Never blanket-approved: a contributed tool runs outside the agent's path containment, so the | ||
| * approval dialog is the only control there is. | ||
| * True only for a tool its provider declared read-only (ADFA-7147). A contributed tool runs | ||
| * outside the agent's path containment, so the dialog is the only control there is: one that | ||
| * may change something is confirmed on every call. For a read-only one the user may answer | ||
| * "Always Allow", which still takes one explicit approval per tool per session. The | ||
| * declaration is the provider's own claim, so it can widen nothing beyond that one choice. | ||
| */ | ||
| override val allowsSessionApproval: Boolean = false | ||
| override val allowsSessionApproval: Boolean get() = readOnly | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMPORTANT: "Always Allow" now rests on a read-only claim the user is never shown and nothing in the host checks.
This is the reversal the ticket says AI-Core's owner decides, so it needs that decision on record before merge. If it goes ahead, have the dialog say the tool is declared read-only by the plugin, and tell the user the grant covers every argument. |
||
|
|
||
| /** | ||
| * The provider and the tool's own name, which is what the dialog showed when the user said | ||
| * "Always Allow". [toolName] alone could hand the grant to another plugin's tool that takes | ||
| * the name over after the sources change. | ||
| */ | ||
| override val sessionApprovalKey: String = "contributed:${tool.providerId}:${tool.name}" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MINOR: the grant key is provider and tool name only, so it does not cover what the user approved (description, schema, read-only flag). The user taps Always Allow on Fold a hash of description and parameters schema into the key, so a changed tool asks again. The comment above ( |
||
|
|
||
| /** The contributing plugin's id, for provenance in logs and the settings screen. */ | ||
| val providerId: String get() = tool.providerId | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MINOR: a session grant outlives the chat session, and the dialog tooltip promises otherwise.
The defect is partly outside this diff:
clearSessionApprovals()(line 225) has no caller anywhere inplugins/AI-Core, andChatViewModel.createNewSession,switchToSessionandimportSessionnever clear it. So "Always Allow" lasts for the wholeChatViewModel, across every chat in the project. The tooltip text inAiCorePlugin.kt(~line 644) says the grant is "by tool name only" and "forgotten when the session ends", which no longer matches for contributed tools (keyed by provider and tool) and is not true for chats. Built-ins already behave this way, so it is MINOR, but this PR newly extends the lifetime to plugin-run tools, and the README and PR description both say "per session".Either call
clearSessionApprovals()when the chat session changes, or word the README and tooltip as "until the IDE closes this chat panel".