Files
oh-my-openagent/src/tools/call-omo-agent/sync-executor.test.ts
YeonGyu-Kim b58f3edf6d 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
2026-02-13 14:55:46 +09:00

92 lines
2.1 KiB
TypeScript

const { describe, test, expect, mock } = require("bun:test")
mock.module("./session-creator", () => ({
createOrGetSession: mock(async () => ({ sessionID: "ses-test-123" })),
}))
mock.module("./completion-poller", () => ({
waitForCompletion: mock(async () => {}),
}))
mock.module("./message-processor", () => ({
processMessages: mock(async () => "agent response"),
}))
describe("executeSync", () => {
test("passes question=false via tools parameter to block question tool", async () => {
//#given
const { executeSync } = require("./sync-executor")
let promptArgs: any
const promptAsync = mock(async (input: any) => {
promptArgs = input
return { data: {} }
})
const args = {
subagent_type: "explore",
description: "test task",
prompt: "find something",
}
const toolContext = {
sessionID: "parent-session",
messageID: "msg-1",
agent: "sisyphus",
abort: new AbortController().signal,
metadata: mock(async () => {}),
}
const ctx = {
client: {
session: { promptAsync },
},
}
//#when
await executeSync(args, toolContext, ctx as any)
//#then
expect(promptAsync).toHaveBeenCalled()
expect(promptArgs.body.tools.question).toBe(false)
})
test("passes task=false via tools parameter", async () => {
//#given
const { executeSync } = require("./sync-executor")
let promptArgs: any
const promptAsync = mock(async (input: any) => {
promptArgs = input
return { data: {} }
})
const args = {
subagent_type: "librarian",
description: "search docs",
prompt: "find docs",
}
const toolContext = {
sessionID: "parent-session",
messageID: "msg-2",
agent: "sisyphus",
abort: new AbortController().signal,
metadata: mock(async () => {}),
}
const ctx = {
client: {
session: { promptAsync },
},
}
//#when
await executeSync(args, toolContext, ctx as any)
//#then
expect(promptAsync).toHaveBeenCalled()
expect(promptArgs.body.tools.task).toBe(false)
})
})