fix(sync): forward delegated model tuning params

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-04 15:40:37 +09:00
parent fd476fe9a1
commit 1fae073009
6 changed files with 281 additions and 16 deletions
@@ -8,6 +8,11 @@ type PromptAsyncInput = {
agent: string
tools: Record<string, boolean>
parts: Array<{ type: string; text: string }>
model?: { providerID: string; modelID: string }
variant?: string
temperature?: number
topP?: number
options?: Record<string, unknown>
}
}
@@ -141,6 +146,56 @@ describe("executeSync", () => {
)
})
test("forwards delegated model tuning params in the sync prompt body", async () => {
//#given
const executeSync = await importExecuteSync()
const deps = createDependencies()
const toolContext = createToolContext()
const recorder = createPromptAsyncRecorder()
const args = {
subagent_type: "explore",
description: "test task",
prompt: "find something",
run_in_background: false,
}
const model = {
providerID: "openai",
modelID: "gpt-5.4",
variant: "high",
temperature: 0.12,
top_p: 0.34,
maxTokens: 5678,
reasoningEffort: "medium",
thinking: { type: "disabled" as const },
}
//#when
await executeSync(
args,
toolContext,
createContext(recorder.promptAsync) as never,
deps,
undefined,
undefined,
model,
)
//#then
const promptInput = recorder.getCapturedInput()
expect(promptInput?.body.model).toEqual({
providerID: "openai",
modelID: "gpt-5.4",
})
expect(promptInput?.body.variant).toBe("high")
expect(promptInput?.body.temperature).toBe(0.12)
expect(promptInput?.body.topP).toBe(0.34)
expect(promptInput?.body.options).toEqual({
maxTokens: 5678,
reasoningEffort: "medium",
thinking: { type: "disabled" },
})
})
test("records metadata with description and created session id", async () => {
//#given
const executeSync = await importExecuteSync()
+22
View File
@@ -3,6 +3,7 @@ import type { PluginInput } from "@opencode-ai/plugin"
import { subagentSessions, syncSubagentSessions } from "../../features/claude-code-session-state"
import { clearSessionFallbackChain, setSessionFallbackChain } from "../../hooks/model-fallback/hook"
import { getAgentToolRestrictions, log } from "../../shared"
import { applySessionPromptParams } from "../../shared/session-prompt-params-helpers"
import type { DelegatedModelConfig } from "../../shared/model-resolution-types"
import type { FallbackEntry } from "../../shared/model-requirements"
import { waitForCompletion } from "./completion-poller"
@@ -34,6 +35,24 @@ const defaultDeps: ExecuteSyncDeps = {
clearSessionFallbackChain,
}
function buildPromptGenerationParams(model: DelegatedModelConfig | undefined): Record<string, unknown> {
if (!model) {
return {}
}
const promptOptions: Record<string, unknown> = {
...(model.reasoningEffort ? { reasoningEffort: model.reasoningEffort } : {}),
...(model.thinking ? { thinking: model.thinking } : {}),
...(model.maxTokens !== undefined ? { maxTokens: model.maxTokens } : {}),
}
return {
...(model.temperature !== undefined ? { temperature: model.temperature } : {}),
...(model.top_p !== undefined ? { topP: model.top_p } : {}),
...(Object.keys(promptOptions).length > 0 ? { options: promptOptions } : {}),
}
}
export async function executeSync(
args: CallOmoAgentArgs,
toolContext: {
@@ -69,6 +88,8 @@ export async function executeSync(
appliedFallbackChain = true
}
applySessionPromptParams(sessionID, model)
await Promise.resolve(
toolContext.metadata?.({
title: args.description,
@@ -92,6 +113,7 @@ export async function executeSync(
parts: [{ type: "text", text: args.prompt }],
...(model ? { model: { providerID: model.providerID, modelID: model.modelID } } : {}),
...(model?.variant ? { variant: model.variant } : {}),
...buildPromptGenerationParams(model),
},
})
} catch (error) {