fix(agent): always keep agent when model is explicitly configured

Previously, when an explicit model was configured, the agent name was
omitted to prevent opencode's built-in agent fallback chain from
overriding the user-specified model. This removes that conditional logic
and always passes the agent name alongside the model. Tests are updated
to reflect this behavior change.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
YeonGyu-Kim
2026-03-25 11:44:01 +09:00
parent bff74f4237
commit 42fb2548d6
6 changed files with 207 additions and 18 deletions
@@ -165,6 +165,55 @@ bunDescribe("sendSyncPrompt", () => {
bunExpect(promptArgs.body.tools.call_omo_agent).toBe(true)
})
bunTest("includes agent alongside explicit category model", async () => {
//#given
const { sendSyncPrompt } = require("./sync-prompt-sender")
let promptArgs: any
const promptAsync = bunMock(async (input: any) => {
promptArgs = input
return { data: {} }
})
const mockClient = {
session: {
promptAsync,
},
}
const input = {
sessionID: "test-session",
agentToUse: "sisyphus-junior",
args: {
description: "test task",
prompt: "test prompt",
category: "quick",
run_in_background: false,
load_skills: [],
},
systemContent: undefined,
categoryModel: {
providerID: "openai",
modelID: "gpt-5.4",
variant: "medium",
},
toastManager: null,
taskId: undefined,
}
//#when
await sendSyncPrompt(mockClient, input)
//#then
bunExpect(promptAsync).toHaveBeenCalled()
bunExpect(promptArgs.body.agent).toBe("sisyphus-junior")
bunExpect(promptArgs.body.model).toEqual({
providerID: "openai",
modelID: "gpt-5.4",
})
bunExpect(promptArgs.body.variant).toBe("medium")
})
bunTest("retries with promptSync for oracle when promptAsync fails with unexpected EOF", async () => {
//#given
const { sendSyncPrompt } = require("./sync-prompt-sender")
@@ -56,9 +56,7 @@ export async function sendSyncPrompt(
const promptArgs = {
path: { id: input.sessionID },
body: {
// When a custom model is configured, omit the agent name so opencode's
// built-in agent fallback chain does not override the user-specified model.
...(input.categoryModel ? {} : { agent: input.agentToUse }),
agent: input.agentToUse,
system: input.systemContent,
tools,
parts: [createInternalAgentTextPart(effectivePrompt)],