Merge pull request #3872 from x-x-gpu/dev
fix: pass resolved model to session.create so sub-agent sessions use the correct model
This commit is contained in:
@@ -725,6 +725,15 @@ export class BackgroundManager {
|
||||
parentID: input.parentSessionId,
|
||||
title: `${input.description} (@${input.agent} subagent)`,
|
||||
...(input.sessionPermission ? { permission: input.sessionPermission } : {}),
|
||||
...(input.model
|
||||
? {
|
||||
model: {
|
||||
id: input.model.modelID,
|
||||
providerID: input.model.providerID,
|
||||
...(input.model.variant ? { variant: input.model.variant } : {}),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
} as Record<string, unknown>,
|
||||
query: {
|
||||
directory: parentDirectory,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { CallOmoAgentArgs } from "./types"
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import type { DelegatedModelConfig } from "../../shared/model-resolution-types"
|
||||
import { subagentSessions, syncSubagentSessions } from "../../features/claude-code-session-state"
|
||||
import { log } from "../../shared"
|
||||
|
||||
@@ -12,7 +13,8 @@ export async function createOrGetSession(
|
||||
abort: AbortSignal
|
||||
metadata?: (input: { title?: string; metadata?: Record<string, unknown> }) => void
|
||||
},
|
||||
ctx: PluginInput
|
||||
ctx: PluginInput,
|
||||
model?: DelegatedModelConfig,
|
||||
): Promise<{ sessionID: string; isNew: boolean }> {
|
||||
if (args.session_id) {
|
||||
log(`[call_omo_agent] Using existing session: ${args.session_id}`)
|
||||
@@ -39,6 +41,15 @@ export async function createOrGetSession(
|
||||
body: {
|
||||
parentID: toolContext.sessionID,
|
||||
title: `${args.description} (@${args.subagent_type} subagent)`,
|
||||
...(model
|
||||
? {
|
||||
model: {
|
||||
id: model.modelID,
|
||||
providerID: model.providerID,
|
||||
...(model.variant ? { variant: model.variant } : {}),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
} as Record<string, unknown>,
|
||||
query: {
|
||||
directory: parentDirectory,
|
||||
|
||||
@@ -78,7 +78,7 @@ export async function executeSync(
|
||||
let appliedFallbackChain = false
|
||||
|
||||
try {
|
||||
const session = await deps.createOrGetSession(args, toolContext, ctx)
|
||||
const session = await deps.createOrGetSession(args, toolContext, ctx, model)
|
||||
sessionID = session.sessionID
|
||||
createdSessionForExecution = session.isNew
|
||||
subagentSessions.add(sessionID)
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import type { OpencodeClient } from "./types"
|
||||
import type { DelegatedModelConfig } from "../../shared/model-resolution-types"
|
||||
import { QUESTION_DENIED_SESSION_PERMISSION } from "../../shared/question-denied-session-permission"
|
||||
|
||||
export async function createSyncSession(
|
||||
client: OpencodeClient,
|
||||
input: { parentSessionID: string; agentToUse: string; description: string; defaultDirectory: string }
|
||||
input: {
|
||||
parentSessionID: string
|
||||
agentToUse: string
|
||||
description: string
|
||||
defaultDirectory: string
|
||||
categoryModel?: DelegatedModelConfig
|
||||
}
|
||||
): Promise<{ ok: true; sessionID: string; parentDirectory: string } | { ok: false; error: string }> {
|
||||
const parentSession = client.session.get
|
||||
? await client.session.get({ path: { id: input.parentSessionID } }).catch(() => null)
|
||||
@@ -15,6 +22,15 @@ export async function createSyncSession(
|
||||
parentID: input.parentSessionID,
|
||||
title: `${input.description} (@${input.agentToUse} subagent)`,
|
||||
permission: QUESTION_DENIED_SESSION_PERMISSION,
|
||||
...(input.categoryModel
|
||||
? {
|
||||
model: {
|
||||
id: input.categoryModel.modelID,
|
||||
providerID: input.categoryModel.providerID,
|
||||
...(input.categoryModel.variant ? { variant: input.categoryModel.variant } : {}),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
} as Record<string, unknown>,
|
||||
query: {
|
||||
directory: parentDirectory,
|
||||
|
||||
@@ -90,6 +90,7 @@ export async function executeSyncTask(
|
||||
agentToUse,
|
||||
description: args.description,
|
||||
defaultDirectory: directory,
|
||||
categoryModel,
|
||||
})
|
||||
|
||||
if (!createSessionResult.ok) {
|
||||
@@ -281,6 +282,7 @@ export async function executeSyncTask(
|
||||
agentToUse,
|
||||
description: args.description,
|
||||
defaultDirectory: directory,
|
||||
categoryModel: nextFallbackModel,
|
||||
})
|
||||
if (!retrySessionResult.ok) {
|
||||
return retrySessionResult.error
|
||||
|
||||
Reference in New Issue
Block a user