diff --git a/src/agents/sisyphus.ts b/src/agents/sisyphus.ts index 2decf5cd8..f534a50fa 100644 --- a/src/agents/sisyphus.ts +++ b/src/agents/sisyphus.ts @@ -251,9 +251,10 @@ result = task(..., run_in_background=false) // Never wait synchronously for exp 2. Continue only with non-overlapping work - If you have DIFFERENT independent work \u2192 do it now - Otherwise \u2192 **END YOUR RESPONSE.** -3. System sends \`\` on each task completion - then call \`background_output(task_id="...")\` -4. Need results not yet ready? **End your response.** The notification will trigger your next turn. -5. Cleanup: Cancel disposable tasks individually via \`background_cancel(taskId="...")\` +3. **STOP. END YOUR RESPONSE.** The system will send \`\` when tasks complete. +4. On receiving \`\` \u2192 collect results via \`background_output(task_id="...")\` +5. **NEVER call \`background_output\` before receiving \`\`.** This is a BLOCKING anti-pattern. +6. Cleanup: Cancel disposable tasks individually via \`background_cancel(taskId="...")\` ${buildAntiDuplicationSection()} diff --git a/src/agents/sisyphus/default.ts b/src/agents/sisyphus/default.ts index 981c49989..14895b124 100644 --- a/src/agents/sisyphus/default.ts +++ b/src/agents/sisyphus/default.ts @@ -331,9 +331,10 @@ result = task(..., run_in_background=false) // Never wait synchronously for exp 2. Continue only with non-overlapping work - If you have DIFFERENT independent work → do it now - Otherwise → **END YOUR RESPONSE.** -3. System sends \`\` on completion → triggers your next turn -4. Collect via \`background_output(task_id="...")\` -5. Cleanup: Cancel disposable tasks individually via \`background_cancel(taskId="...")\` +3. **STOP. END YOUR RESPONSE.** The system will send \`\` when tasks complete. +4. On receiving \`\` → collect results via \`background_output(task_id="...")\` +5. **NEVER call \`background_output\` before receiving \`\`.** This is a BLOCKING anti-pattern. +6. Cleanup: Cancel disposable tasks individually via \`background_cancel(taskId="...")\` ${buildAntiDuplicationSection()} diff --git a/src/agents/sisyphus/gpt-5-4.ts b/src/agents/sisyphus/gpt-5-4.ts index f82637b10..3dcb12d0d 100644 --- a/src/agents/sisyphus/gpt-5-4.ts +++ b/src/agents/sisyphus/gpt-5-4.ts @@ -260,9 +260,10 @@ Background result collection: 2. Continue only with non-overlapping work - If you have DIFFERENT independent work → do it now - Otherwise → **END YOUR RESPONSE.** -3. System sends \`\` on completion → triggers your next turn -4. Collect via \`background_output(task_id="...")\` -5. Cancel disposable tasks individually via \`background_cancel(taskId="...")\` +3. **STOP. END YOUR RESPONSE.** The system will send \`\` when tasks complete. +4. On receiving \`\` → collect results via \`background_output(task_id="...")\` +5. **NEVER call \`background_output\` before receiving \`\`.** This is a BLOCKING anti-pattern. +6. Cancel disposable tasks individually via \`background_cancel(taskId="...")\` ${buildAntiDuplicationSection()} diff --git a/src/tools/background-task/constants.ts b/src/tools/background-task/constants.ts index 0a1eeedea..011c2d692 100644 --- a/src/tools/background-task/constants.ts +++ b/src/tools/background-task/constants.ts @@ -2,6 +2,8 @@ export const BACKGROUND_TASK_DESCRIPTION = `Run agent task in background. Return Use \`background_output\` to get results. Prompts MUST be in English.` -export const BACKGROUND_OUTPUT_DESCRIPTION = `Get output from background task. Use full_session=true to fetch session messages with filters. System notifies on completion, so block=true rarely needed. - Timeout values are in milliseconds (ms), NOT seconds.` +export const BACKGROUND_OUTPUT_DESCRIPTION = `Get output from background task. Use full_session=true to fetch session messages with filters. System notifies on completion, so block=true rarely needed. - Timeout values are in milliseconds (ms), NOT seconds. + +IMPORTANT: ONLY call this tool AFTER receiving a notification for the task. Do NOT call immediately after launching a background task - wait for the notification first.` export const BACKGROUND_CANCEL_DESCRIPTION = `Cancel running background task(s). Use all=true to cancel ALL before final answer.` diff --git a/src/tools/background-task/create-background-task.ts b/src/tools/background-task/create-background-task.ts index 679bc533e..0d2c38f0f 100644 --- a/src/tools/background-task/create-background-task.ts +++ b/src/tools/background-task/create-background-task.ts @@ -114,10 +114,9 @@ Description: ${task.description} Agent: ${task.agent} Status: ${task.status} -The system will notify you when the task completes. -Use \`background_output\` tool with task_id="${task.id}" to check progress: -- block=false (default): Check status immediately - returns full status info -- block=true: Wait for completion (rarely needed since system notifies)` +System notifies on completion. Use \`background_output\` with task_id="${task.id}" to check. + +Do NOT call background_output now. Wait for notification first.` } catch (error) { const message = error instanceof Error ? error.message : String(error) return `[ERROR] Failed to launch background task: ${message}` diff --git a/src/tools/call-omo-agent/background-agent-executor.ts b/src/tools/call-omo-agent/background-agent-executor.ts index 9b82e59a3..7318d958c 100644 --- a/src/tools/call-omo-agent/background-agent-executor.ts +++ b/src/tools/call-omo-agent/background-agent-executor.ts @@ -81,10 +81,9 @@ Description: ${task.description} Agent: ${task.agent} (subagent) Status: ${task.status} -The system will notify you when the task completes. -Use \`background_output\` tool with task_id="${task.id}" to check progress: -- block=false (default): Check status immediately - returns full status info -- block=true: Wait for completion (rarely needed since system notifies)` +System notifies on completion. Use \`background_output\` with task_id="${task.id}" to check. + +Do NOT call background_output now. Wait for notification first.` } catch (error) { const message = error instanceof Error ? error.message : String(error) return `Failed to launch background agent task: ${message}` diff --git a/src/tools/call-omo-agent/background-executor.ts b/src/tools/call-omo-agent/background-executor.ts index fac45e1ce..d76133c0b 100644 --- a/src/tools/call-omo-agent/background-executor.ts +++ b/src/tools/call-omo-agent/background-executor.ts @@ -88,10 +88,9 @@ Description: ${task.description} Agent: ${task.agent} (subagent) Status: ${task.status} -The system will notify you when the task completes. -Use \`background_output\` tool with task_id="${task.id}" to check progress: -- block=false (default): Check status immediately - returns full status info -- block=true: Wait for completion (rarely needed since system notifies)` +System notifies on completion. Use \`background_output\` with task_id="${task.id}" to check. + +Do NOT call background_output now. Wait for notification first.` } catch (error) { const message = error instanceof Error ? error.message : String(error) return `Failed to launch background agent task: ${message}` diff --git a/src/tools/delegate-task/background-continuation.ts b/src/tools/delegate-task/background-continuation.ts index aa8fecc30..0d365d964 100644 --- a/src/tools/delegate-task/background-continuation.ts +++ b/src/tools/delegate-task/background-continuation.ts @@ -51,7 +51,9 @@ Agent: ${task.agent} Status: ${task.status} Agent continues with full previous context preserved. -Use \`background_output\` with task_id="${task.id}" to check progress. +System notifies on completion. Use \`background_output\` with task_id="${task.id}" to check. + +Do NOT call background_output now. Wait for notification first. session_id: ${task.sessionID} diff --git a/src/tools/delegate-task/background-task.ts b/src/tools/delegate-task/background-task.ts index 937de5c39..0dbb042ab 100644 --- a/src/tools/delegate-task/background-task.ts +++ b/src/tools/delegate-task/background-task.ts @@ -149,7 +149,9 @@ Description: ${task.description} Agent: ${task.agent}${args.category ? ` (category: ${args.category})` : ""} Status: ${task.status} -System notifies on completion. Use \`background_output\` with task_id="${task.id}" to check.${taskMetadataBlock}` +System notifies on completion. Use \`background_output\` with task_id="${task.id}" to check. + +Do NOT call background_output now. Wait for notification first.${taskMetadataBlock}` } catch (error) { return formatDetailedError(error, { operation: "Launch background task",