Files
oh-my-opencode-free-fork/src/hooks/empty-task-response-detector.ts
2025-12-08 17:00:02 +09:00

28 lines
849 B
TypeScript

import type { PluginInput } from "@opencode-ai/plugin"
const EMPTY_RESPONSE_WARNING = `[Task Empty Response Warning]
Task invocation completed but returned no response. This indicates the agent either:
- Failed to execute properly
- Did not terminate correctly
- Returned an empty result
Note: The call has already completed - you are NOT waiting for a response. Proceed accordingly.`
export function createEmptyTaskResponseDetectorHook(_ctx: PluginInput) {
return {
"tool.execute.after": async (
input: { tool: string; sessionID: string; callID: string },
output: { title: string; output: string; metadata: unknown }
) => {
if (input.tool !== "Task") return
const responseText = output.output?.trim() ?? ""
if (responseText === "") {
output.output = EMPTY_RESPONSE_WARNING
}
},
}
}