fix(background-agent): omit model field to use session's lastModel

Previously, background task completion notifications passed parentModel when defined, causing OpenCode to use default Sonnet model when parentModel was undefined. Now model field is always omitted, letting OpenCode use the session's existing lastModel (like todo-continuation hook).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
justsisyphus
2026-01-14 18:02:20 +09:00
parent 45d660176e
commit 6ded689d08
2 changed files with 14 additions and 16 deletions
+2 -4
View File
@@ -639,16 +639,14 @@ Use \`background_output(task_id="${task.id}")\` to retrieve this result when rea
}
// Inject notification via session.prompt with noReply
// Preserve parent session's model/agent context to prevent model switching
// Don't pass model - let OpenCode use session's existing lastModel (like todo-continuation)
// This prevents model switching when parentModel is undefined
try {
await this.client.session.prompt({
path: { id: task.parentSessionID },
body: {
noReply: !allComplete,
...(task.parentAgent !== undefined ? { agent: task.parentAgent } : {}),
...(task.parentModel?.providerID && task.parentModel?.modelID
? { model: { providerID: task.parentModel.providerID, modelID: task.parentModel.modelID } }
: {}),
parts: [{ type: "text", text: notification }],
},
})