File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ import type { PluginInput } from "@opencode-ai/plugin"
2+
3+ const EMPTY_RESPONSE_WARNING = `[Task Empty Response Warning]
4+
5+ Task invocation completed but returned no response. This indicates the agent either:
6+ - Failed to execute properly
7+ - Did not terminate correctly
8+ - Returned an empty result
9+
10+ Note: The call has already completed - you are NOT waiting for a response. Proceed accordingly.`
11+
12+ export function createEmptyTaskResponseDetectorHook ( _ctx : PluginInput ) {
13+ return {
14+ "tool.execute.after" : async (
15+ input : { tool : string ; sessionID : string ; callID : string } ,
16+ output : { title : string ; output : string ; metadata : unknown }
17+ ) => {
18+ if ( input . tool !== "Task" ) return
19+
20+ const responseText = output . output ?. trim ( ) ?? ""
21+
22+ if ( responseText === "" ) {
23+ output . output = EMPTY_RESPONSE_WARNING
24+ }
25+ } ,
26+ }
27+ }
Original file line number Diff line number Diff line change 88 createGrepOutputTruncatorHook ,
99 createPulseMonitorHook ,
1010 createDirectoryAgentsInjectorHook ,
11+ createEmptyTaskResponseDetectorHook ,
1112} from "./hooks" ;
1213import { updateTerminalTitle } from "./features/terminal" ;
1314import { builtinTools } from "./tools" ;
@@ -57,6 +58,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
5758 const commentChecker = createCommentCheckerHooks ( ) ;
5859 const grepOutputTruncator = createGrepOutputTruncatorHook ( ctx ) ;
5960 const directoryAgentsInjector = createDirectoryAgentsInjectorHook ( ctx ) ;
61+ const emptyTaskResponseDetector = createEmptyTaskResponseDetectorHook ( ctx ) ;
6062
6163 updateTerminalTitle ( { sessionId : "main" } ) ;
6264
@@ -212,6 +214,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
212214 await contextWindowMonitor [ "tool.execute.after" ] ( input , output ) ;
213215 await commentChecker [ "tool.execute.after" ] ( input , output ) ;
214216 await directoryAgentsInjector [ "tool.execute.after" ] ( input , output ) ;
217+ await emptyTaskResponseDetector [ "tool.execute.after" ] ( input , output ) ;
215218
216219 if ( input . sessionID === mainSessionID ) {
217220 updateTerminalTitle ( {
You can’t perform that action at this time.
0 commit comments