refactor: remove redundant subagent-question-blocker hook

Replace PreToolUse hook-based question tool blocking with the existing
tools parameter approach (tools: { question: false }) which physically
removes the tool from the LLM's toolset before inference.

The hook was redundant because every session.prompt() call already passes
question: false via the tools parameter. OpenCode converts this to a
PermissionNext deny rule and deletes the tool from the toolset, preventing
the LLM from even seeing it. The hook only fired after the LLM already
called the tool, wasting tokens.

Changes:
- Remove subagent-question-blocker hook invocation from PreToolUse chain
- Remove hook registration from create-session-hooks.ts
- Delete src/hooks/subagent-question-blocker/ directory (dead code)
- Remove hook from HookNameSchema and barrel export
- Fix sync-executor.ts missing question: false in tools parameter
- Add regression tests for both the removal and the tools parameter
This commit is contained in:
YeonGyu-Kim
2026-02-13 14:55:46 +09:00
parent 1ee8f4a2d6
commit d16073aa59
12 changed files with 166 additions and 125 deletions
@@ -1,6 +1,45 @@
const { describe, test, expect, mock } = require("bun:test")
describe("sendSyncPrompt", () => {
test("passes question=false via tools parameter", async () => {
//#given
const { sendSyncPrompt } = require("./sync-prompt-sender")
let promptArgs: any
const promptAsync = mock(async (input: any) => {
promptArgs = input
return { data: {} }
})
const mockClient = {
session: {
promptAsync,
},
}
const input = {
sessionID: "test-session",
agentToUse: "sisyphus-junior",
args: {
description: "test task",
prompt: "test prompt",
run_in_background: false,
load_skills: [],
},
systemContent: undefined,
categoryModel: undefined,
toastManager: null,
taskId: undefined,
}
//#when
await sendSyncPrompt(mockClient as any, input)
//#then
expect(promptAsync).toHaveBeenCalled()
expect(promptArgs.body.tools.question).toBe(false)
})
test("applies agent tool restrictions for explore agent", async () => {
//#given
const { sendSyncPrompt } = require("./sync-prompt-sender")