fix(background-agent): use TUI appendPrompt + submitPrompt for notification
session.prompt() fails with validation errors in background context. Switch to TUI API which directly manipulates the main session input. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -231,29 +231,24 @@ export class BackgroundManager {
|
|||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = `[BACKGROUND TASK COMPLETED]
|
const message = `[BACKGROUND TASK COMPLETED] Task "${task.description}" finished in ${duration} (${toolCalls} tool calls). Use background_result with taskId="${task.id}" to get results.`
|
||||||
|
|
||||||
Task "${task.description}" has finished.
|
log("[background-agent] Sending notification via TUI appendPrompt + submitPrompt")
|
||||||
Duration: ${duration}
|
|
||||||
Tool calls: ${toolCalls}
|
|
||||||
|
|
||||||
Use \`background_result\` tool with taskId="${task.id}" to retrieve the full result.`
|
setTimeout(async () => {
|
||||||
|
try {
|
||||||
log("[background-agent] Scheduling prompt to parent session:", task.parentSessionID)
|
await tuiClient.tui.appendPrompt({
|
||||||
|
body: { text: message },
|
||||||
setTimeout(() => {
|
|
||||||
this.client.session.prompt({
|
|
||||||
path: { id: task.parentSessionID },
|
|
||||||
body: {
|
|
||||||
parts: [{ type: "text", text: message }],
|
|
||||||
},
|
|
||||||
query: { directory: this.directory },
|
query: { directory: this.directory },
|
||||||
}).then(() => {
|
|
||||||
this.clearNotificationsForTask(task.id)
|
|
||||||
log("[background-agent] Successfully sent prompt to parent session")
|
|
||||||
}).catch((error) => {
|
|
||||||
log("[background-agent] Failed to send prompt:", String(error))
|
|
||||||
})
|
})
|
||||||
|
await tuiClient.tui.submitPrompt({
|
||||||
|
query: { directory: this.directory },
|
||||||
|
})
|
||||||
|
this.clearNotificationsForTask(task.id)
|
||||||
|
log("[background-agent] Successfully sent via TUI API")
|
||||||
|
} catch (error) {
|
||||||
|
log("[background-agent] TUI API failed:", String(error))
|
||||||
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user