The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(agent): a tool switched off in the permissions is refused, not offered for approval
purple0584d3177c31
diff --git a/src/hooks/__tests__/a-blocked-tool-is-refused-not-offered.test.ts b/src/hooks/__tests__/a-blocked-tool-is-refused-not-offered.test.tsnew file mode 100644index 00000000..7664faf4--- /dev/null+++ b/src/hooks/__tests__/a-blocked-tool-is-refused-not-offered.test.ts@@ -0,0 +1,36 @@+/**+ * Bug hunt 01.10.2026 (A4). The Agent loop asked for approval on every level+ * that was not 'auto', and 'blocked' is not 'auto': a tool the user had+ * switched off got an approval card, and one click on Approve ran it. The+ * catalog leaves it out, but the loose parser lifts a call written as text and+ * the executor resolves it by name. The sub-agent and the Code tab already+ * refused; the main Agent loop is the one that asked.+ */+import { describe, it, expect } from 'vitest'+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'+import { resolveApprovalLevel } from '../../lib/agent-approval-policy'++const agent = readFileSync(resolve(__dirname, '../useAgentChat.ts'), 'utf8')++describe('a tool switched off in the permissions', () => {+ it('resolves to blocked, which is not auto, so the approval path alone would ask for it', () => {+ expect(resolveApprovalLevel('shell_execute', { categoryLevel: 'blocked', codexMode: null, readOnlyRun: false })).toBe('blocked')+ expect(agent).toMatch(/const needsApproval = permLevel !== 'auto' \|\| cloudShellConfirm/)+ })++ it('is filtered out and refused before any card is built', () => {+ const refuse = agent.indexOf("is switched off for this conversation in the tool permissions, so it was not run")+ const card = agent.indexOf("status: needsApproval ? 'pending_approval' : 'running'")+ expect(refuse).toBeGreaterThan(0)+ expect(refuse).toBeLessThan(card)+ const block = agent.slice(agent.lastIndexOf('{', refuse - 900) , refuse)+ expect(block).toMatch(/resolveApprovalLevel\(tc\.function\.name, \{\s+categoryLevel: toolRegistry\.getPermissionLevelWithOverrides\(tc\.function\.name, permissions, \{\}\),\s+override: overrides\[tc\.function\.name\],/)+ expect(block).toMatch(/=== 'blocked'/)+ expect(block).toMatch(/toolCalls = toolCalls\.filter\(\(tc\) => !isBlocked\(tc\)\)/)+ })++ it('a per-tool override that allows it still wins', () => {+ expect(resolveApprovalLevel('shell_execute', { categoryLevel: 'confirm', override: 'auto', codexMode: null, readOnlyRun: false })).toBe('auto')+ })+})diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.tsindex 8f90cc49..d9ea0f30 100644--- a/src/hooks/useAgentChat.ts+++ b/src/hooks/useAgentChat.ts@@ -2301,6 +2301,32 @@ export function useAgentChat() {}}+ // A tool switched off in the permissions is refused, not offered for+ // approval (bug hunt 01.10.2026, A4). The approval below asked for+ // every level that was not 'auto', 'blocked' included, so one click on+ // Approve ran a tool the user had turned off. Leaving it out of the+ // catalog is not a gate: the loose parser lifts a call written as text+ // and the executor resolves it by name. Same level, same inputs as the+ // approval, and the same refusal the Code tab gives.+ {+ const overrides = usePermissionStore.getState().perToolOverrides+ const isBlocked = (tc: ToolCall) => resolveApprovalLevel(tc.function.name, {+ categoryLevel: toolRegistry.getPermissionLevelWithOverrides(tc.function.name, permissions, {}),+ override: overrides[tc.function.name],+ codexMode: null,+ readOnlyRun: run.readOnlyShellTurn,+ }) === 'blocked'+ const refused = toolCalls.filter(isBlocked)+ if (refused.length) {+ toolCalls = toolCalls.filter((tc) => !isBlocked(tc))+ const names = [...new Set(refused.map((tc) => tc.function.name))].join(', ')+ agentMessages.push({+ role: 'user',+ content: `${names} is switched off for this conversation in the tool permissions, so it was not run. Do not call it again. Continue with the tools you have, or say what you would need.`,+ })+ }+ }+// Loop-detector, parity with Codex: narration first (the same line// re-emitted every iteration), then the batch (windowed signature// repeats + identical reads against an unchanged workspace). Steer is