fix(background-task): return result instead of status for completed tasks
- Fix background_output to check completion status before block flag - Update call_omo_agent return message to correctly indicate block=false as default - Add system notification guidance in return message 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -211,12 +211,7 @@ export function createBackgroundOutput(manager: BackgroundManager, client: Openc
|
|||||||
const shouldBlock = args.block === true
|
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
|
// Already completed: return result immediately (regardless of block flag)
|
||||||
if (!shouldBlock) {
|
|
||||||
return formatTaskStatus(task)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Already completed: return result immediately
|
|
||||||
if (task.status === "completed") {
|
if (task.status === "completed") {
|
||||||
return await formatTaskResult(task, client)
|
return await formatTaskResult(task, client)
|
||||||
}
|
}
|
||||||
@@ -226,6 +221,11 @@ export function createBackgroundOutput(manager: BackgroundManager, client: Openc
|
|||||||
return formatTaskStatus(task)
|
return formatTaskStatus(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Non-blocking and still running: return status
|
||||||
|
if (!shouldBlock) {
|
||||||
|
return formatTaskStatus(task)
|
||||||
|
}
|
||||||
|
|
||||||
// Blocking: poll until completion or timeout
|
// Blocking: poll until completion or timeout
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
|
|
||||||
|
|||||||
@@ -67,9 +67,10 @@ Description: ${task.description}
|
|||||||
Agent: ${task.agent} (subagent)
|
Agent: ${task.agent} (subagent)
|
||||||
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 agent task: ${message}`
|
return `Failed to launch background agent task: ${message}`
|
||||||
|
|||||||
Reference in New Issue
Block a user