fix(background-task): change default block to false and clarify system notification
- Change background_output default from block=true to block=false - Add documentation about system auto-notification on task completion - Clarify that block=false returns full status info, not empty 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -18,16 +18,19 @@ export const BACKGROUND_OUTPUT_DESCRIPTION = `Get output from a background task.
|
|||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- task_id: Required task ID to get output from
|
- task_id: Required task ID to get output from
|
||||||
- block: If true (default), wait for task completion. If false, return current status immediately.
|
- block: If true, wait for task completion. If false (default), return current status immediately.
|
||||||
- timeout: Max wait time in ms when blocking (default: 60000, max: 600000)
|
- timeout: Max wait time in ms when blocking (default: 60000, max: 600000)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
- When not blocking: Returns current status with task ID, description, agent, status, duration, and progress info
|
||||||
- When blocking: Waits for completion, then returns full result
|
- When blocking: Waits for completion, then returns full result
|
||||||
- When not blocking: Returns current status and progress
|
|
||||||
|
IMPORTANT: The system automatically notifies the main session when background tasks complete.
|
||||||
|
You typically don't need block=true - just use block=false to check status, and the system will notify you when done.
|
||||||
|
|
||||||
Use this to:
|
Use this to:
|
||||||
- Check task progress (block=false)
|
- Check task progress (block=false) - returns full status info, NOT empty
|
||||||
- Wait for and retrieve task result (block=true)
|
- Wait for and retrieve task result (block=true) - only when you explicitly need to wait
|
||||||
- Set custom timeout for long tasks`
|
- Set custom timeout for long tasks`
|
||||||
|
|
||||||
export const BACKGROUND_CANCEL_DESCRIPTION = `Cancel a running background task.
|
export const BACKGROUND_CANCEL_DESCRIPTION = `Cancel a running background task.
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ Description: ${task.description}
|
|||||||
Agent: ${task.agent}
|
Agent: ${task.agent}
|
||||||
Status: ${task.status}
|
Status: ${task.status}
|
||||||
|
|
||||||
Use \`background_output\` tool with task_id="${task.id}" to check progress or retrieve results.
|
The system will notify you when the task completes.
|
||||||
- block=false: Check status without waiting
|
Use \`background_output\` tool with task_id="${task.id}" to check progress:
|
||||||
- block=true (default): Wait for completion and get result`
|
- block=false (default): Check status immediately - returns full status info
|
||||||
|
- block=true: Wait for completion (rarely needed since system notifies)`
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : String(error)
|
const message = error instanceof Error ? error.message : String(error)
|
||||||
return `❌ Failed to launch background task: ${message}`
|
return `❌ Failed to launch background task: ${message}`
|
||||||
@@ -152,7 +153,7 @@ export function createBackgroundOutput(manager: BackgroundManager, client: Openc
|
|||||||
description: BACKGROUND_OUTPUT_DESCRIPTION,
|
description: BACKGROUND_OUTPUT_DESCRIPTION,
|
||||||
args: {
|
args: {
|
||||||
task_id: tool.schema.string().describe("Task ID to get output from"),
|
task_id: tool.schema.string().describe("Task ID to get output from"),
|
||||||
block: tool.schema.boolean().optional().describe("Wait for completion (default: true)"),
|
block: tool.schema.boolean().optional().describe("Wait for completion (default: false). System notifies when done, so blocking is rarely needed."),
|
||||||
timeout: tool.schema.number().optional().describe("Max wait time in ms (default: 60000, max: 600000)"),
|
timeout: tool.schema.number().optional().describe("Max wait time in ms (default: 60000, max: 600000)"),
|
||||||
},
|
},
|
||||||
async execute(args: BackgroundOutputArgs) {
|
async execute(args: BackgroundOutputArgs) {
|
||||||
@@ -162,7 +163,7 @@ export function createBackgroundOutput(manager: BackgroundManager, client: Openc
|
|||||||
return `Task not found: ${args.task_id}`
|
return `Task not found: ${args.task_id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldBlock = args.block !== false
|
const shouldBlock = args.block === true
|
||||||
const timeoutMs = Math.min(args.timeout ?? 60000, 600000)
|
const timeoutMs = Math.min(args.timeout ?? 60000, 600000)
|
||||||
|
|
||||||
// Non-blocking: return status immediately
|
// Non-blocking: return status immediately
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ When using this tool, you must specify a subagent_type parameter to select which
|
|||||||
|
|
||||||
**IMPORTANT: run_in_background parameter is REQUIRED**
|
**IMPORTANT: run_in_background parameter is REQUIRED**
|
||||||
- \`run_in_background=true\`: Task runs asynchronously in background. Returns immediately with task_id.
|
- \`run_in_background=true\`: Task runs asynchronously in background. Returns immediately with task_id.
|
||||||
Use \`background_output\` tool with the returned task_id to check progress or retrieve results.
|
The system will notify you when the task completes.
|
||||||
|
Use \`background_output\` tool with task_id to check progress (block=false returns full status info).
|
||||||
- \`run_in_background=false\`: Task runs synchronously. Waits for completion and returns full result.
|
- \`run_in_background=false\`: Task runs synchronously. Waits for completion and returns full result.
|
||||||
|
|
||||||
Usage notes:
|
Usage notes:
|
||||||
|
|||||||
Reference in New Issue
Block a user