From 6ded689d08c4e493ce128af9e5768ab33f23d60a Mon Sep 17 00:00:00 2001 From: justsisyphus Date: Wed, 14 Jan 2026 18:02:20 +0900 Subject: [PATCH] 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 --- src/features/background-agent/manager.test.ts | 24 +++++++++---------- src/features/background-agent/manager.ts | 6 ++--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/features/background-agent/manager.test.ts b/src/features/background-agent/manager.test.ts index 00fdee5e..cbab1a6b 100644 --- a/src/features/background-agent/manager.test.ts +++ b/src/features/background-agent/manager.test.ts @@ -675,9 +675,9 @@ describe("LaunchInput.skillContent", () => { }) }) -describe("BackgroundManager.notifyParentSession - model/agent context preservation", () => { - test("should include model field in session.prompt when parentModel is defined", async () => { - // #given +describe("BackgroundManager.notifyParentSession - agent context preservation", () => { + test("should never pass model field - let OpenCode use session's lastModel", async () => { + // #given - task with parentModel defined const task: BackgroundTask = { id: "task-with-model", sessionID: "session-child", @@ -696,8 +696,8 @@ describe("BackgroundManager.notifyParentSession - model/agent context preservati // #when const promptBody = buildNotificationPromptBody(task) - // #then - model MUST be included when parentModel is defined - expect(promptBody.model).toEqual({ providerID: "anthropic", modelID: "claude-opus-4-5" }) + // #then - model MUST NOT be passed (OpenCode uses session's lastModel) + expect("model" in promptBody).toBe(false) expect(promptBody.agent).toBe("Sisyphus") }) @@ -721,9 +721,9 @@ describe("BackgroundManager.notifyParentSession - model/agent context preservati // #when const promptBody = buildNotificationPromptBody(task) - // #then + // #then - no agent, no model (let OpenCode handle) expect("agent" in promptBody).toBe(false) - expect(promptBody.model).toEqual({ providerID: "anthropic", modelID: "claude-opus" }) + expect("model" in promptBody).toBe(false) }) test("should include agent field when parentAgent is defined", async () => { @@ -748,9 +748,10 @@ describe("BackgroundManager.notifyParentSession - model/agent context preservati // #then expect(promptBody.agent).toBe("Sisyphus") + expect("model" in promptBody).toBe(false) }) - test("should not pass model field when parentModel is undefined", async () => { + test("should not pass model field even when parentModel is undefined", async () => { // #given const task: BackgroundTask = { id: "task-no-model", @@ -770,7 +771,7 @@ describe("BackgroundManager.notifyParentSession - model/agent context preservati // #when const promptBody = buildNotificationPromptBody(task) - // #then + // #then - model never passed regardless of parentModel expect("model" in promptBody).toBe(false) expect(promptBody.agent).toBe("Sisyphus") }) @@ -785,9 +786,8 @@ function buildNotificationPromptBody(task: BackgroundTask): Record