fix(background-agent): preserve parent model in notifyParentSession

Fixes model switching bug where sisyphus_task with category would
change the main session's model after completion.

- Add parentModel to session.prompt body in notifyParentSession
- Add test verifying model is included when parentModel is defined
This commit is contained in:
justsisyphus
2026-01-14 13:50:12 +09:00
parent 1351f52bc3
commit 8e46b08aea
2 changed files with 32 additions and 3 deletions
+6 -2
View File
@@ -639,12 +639,16 @@ 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
try {
await this.client.session.prompt({
path: { id: task.parentSessionID },
body: {
noReply: !allComplete, // Silent unless all complete
agent: task.parentAgent,
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 }],
},
})