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