Merge pull request #1951 from edxeth/feat/custom-agents

feat(config): make custom agents first-class for planning and delegation
This commit is contained in:
YeonGyu-Kim
2026-03-02 23:28:57 +09:00
committed by GitHub
19 changed files with 1511 additions and 47 deletions
@@ -79,4 +79,56 @@ describe("resolveSubagentExecution", () => {
error: "network timeout",
})
})
test("uses inherited model for custom agents without explicit model", async () => {
//#given
const args = createBaseArgs({ subagent_type: "translator" })
const executorCtx = createExecutorContext(async () => ({
data: [{ name: "translator", mode: "subagent" }],
}))
//#when
const result = await resolveSubagentExecution(
args,
executorCtx,
"sisyphus",
"deep",
"openai/gpt-5.3-codex",
"anthropic/claude-opus-4-6",
)
//#then
expect(result.error).toBeUndefined()
expect(result.agentToUse).toBe("translator")
expect(result.categoryModel).toEqual({
providerID: "openai",
modelID: "gpt-5.3-codex",
})
})
test("uses system default model when inherited model is unavailable", async () => {
//#given
const args = createBaseArgs({ subagent_type: "translator" })
const executorCtx = createExecutorContext(async () => ({
data: [{ name: "translator", mode: "subagent" }],
}))
//#when
const result = await resolveSubagentExecution(
args,
executorCtx,
"sisyphus",
"deep",
undefined,
"anthropic/claude-opus-4-6",
)
//#then
expect(result.error).toBeUndefined()
expect(result.agentToUse).toBe("translator")
expect(result.categoryModel).toEqual({
providerID: "anthropic",
modelID: "claude-opus-4-6",
})
})
})
+13 -1
View File
@@ -15,7 +15,9 @@ export async function resolveSubagentExecution(
args: DelegateTaskArgs,
executorCtx: ExecutorContext,
parentAgent: string | undefined,
categoryExamples: string
categoryExamples: string,
inheritedModel?: string,
systemDefaultModel?: string,
): Promise<{ agentToUse: string; categoryModel: { providerID: string; modelID: string; variant?: string } | undefined; fallbackChain?: FallbackEntry[]; error?: string }> {
const { client, agentOverrides } = executorCtx
@@ -124,6 +126,16 @@ Create the work plan directly - that's your job as the planning agent.`,
if (!categoryModel && matchedAgent.model) {
categoryModel = matchedAgent.model
}
if (!categoryModel) {
const fallbackModel = inheritedModel ?? systemDefaultModel
if (fallbackModel) {
const parsedFallback = parseModelString(fallbackModel)
if (parsedFallback) {
categoryModel = parsedFallback
}
}
}
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)
log("[delegate-task] Failed to resolve subagent execution", {
+8 -1
View File
@@ -226,7 +226,14 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
return executeUnstableAgentTask(args, ctx, options, parentContext, agentToUse, categoryModel, systemContent, actualModel)
}
} else {
const resolution = await resolveSubagentExecution(args, options, parentContext.agent, categoryExamples)
const resolution = await resolveSubagentExecution(
args,
options,
parentContext.agent,
categoryExamples,
inheritedModel,
systemDefaultModel,
)
if (resolution.error) {
return resolution.error
}