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:
YeonGyu-Kim
2025-12-12 10:15:46 +09:00
parent 3fd9e95579
commit 6449a00f46

View File

@@ -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)
} }