fix(delegate-task): add clear error when model not configured (#1139)
This commit is contained in:
parent
911e43445f
commit
acded4ba2a
@ -201,6 +201,56 @@ describe("sisyphus-task", () => {
|
|||||||
// #then proceeds without error - uses fallback chain
|
// #then proceeds without error - uses fallback chain
|
||||||
expect(result).not.toContain("oh-my-opencode requires a default model")
|
expect(result).not.toContain("oh-my-opencode requires a default model")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("returns clear error when no model can be resolved", async () => {
|
||||||
|
// #given - custom category with no model, no systemDefaultModel, no available models
|
||||||
|
const { createDelegateTask } = require("./tools")
|
||||||
|
|
||||||
|
const mockManager = { launch: async () => ({ id: "task-123" }) }
|
||||||
|
const mockClient = {
|
||||||
|
app: { agents: async () => ({ data: [] }) },
|
||||||
|
config: { get: async () => ({}) }, // No model configured
|
||||||
|
model: { list: async () => [] }, // No available models
|
||||||
|
session: {
|
||||||
|
create: async () => ({ data: { id: "test-session" } }),
|
||||||
|
prompt: async () => ({ data: {} }),
|
||||||
|
messages: async () => ({ data: [] }),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom category with no model defined
|
||||||
|
const tool = createDelegateTask({
|
||||||
|
manager: mockManager,
|
||||||
|
client: mockClient,
|
||||||
|
userCategories: {
|
||||||
|
"custom-no-model": { temperature: 0.5 }, // No model field
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const toolContext = {
|
||||||
|
sessionID: "parent-session",
|
||||||
|
messageID: "parent-message",
|
||||||
|
agent: "sisyphus",
|
||||||
|
abort: new AbortController().signal,
|
||||||
|
}
|
||||||
|
|
||||||
|
// #when delegating with a custom category that has no model
|
||||||
|
const result = await tool.execute(
|
||||||
|
{
|
||||||
|
description: "Test task",
|
||||||
|
prompt: "Do something",
|
||||||
|
category: "custom-no-model",
|
||||||
|
run_in_background: true,
|
||||||
|
load_skills: [],
|
||||||
|
},
|
||||||
|
toolContext
|
||||||
|
)
|
||||||
|
|
||||||
|
// #then returns clear error message with configuration guidance
|
||||||
|
expect(result).toContain("Model not configured")
|
||||||
|
expect(result).toContain("custom-no-model")
|
||||||
|
expect(result).toContain("Configure in one of")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("resolveCategoryConfig", () => {
|
describe("resolveCategoryConfig", () => {
|
||||||
|
|||||||
@ -573,13 +573,26 @@ To continue this session: session_id="${args.session_id}"`
|
|||||||
}
|
}
|
||||||
|
|
||||||
agentToUse = SISYPHUS_JUNIOR_AGENT
|
agentToUse = SISYPHUS_JUNIOR_AGENT
|
||||||
if (!categoryModel && actualModel) {
|
if (!categoryModel && actualModel) {
|
||||||
const parsedModel = parseModelString(actualModel)
|
const parsedModel = parseModelString(actualModel)
|
||||||
categoryModel = parsedModel ?? undefined
|
categoryModel = parsedModel ?? undefined
|
||||||
}
|
}
|
||||||
categoryPromptAppend = resolved.promptAppend || undefined
|
categoryPromptAppend = resolved.promptAppend || undefined
|
||||||
|
|
||||||
const isUnstableAgent = resolved.config.is_unstable_agent === true || (actualModel?.toLowerCase().includes("gemini") ?? false)
|
if (!categoryModel && !actualModel) {
|
||||||
|
const categoryNames = Object.keys({ ...DEFAULT_CATEGORIES, ...userCategories })
|
||||||
|
return `Model not configured for category "${args.category}".
|
||||||
|
|
||||||
|
Configure in one of:
|
||||||
|
1. OpenCode: Set "model" in opencode.json
|
||||||
|
2. Oh-My-OpenCode: Set category model in oh-my-opencode.json
|
||||||
|
3. Provider: Connect a provider with available models
|
||||||
|
|
||||||
|
Current category: ${args.category}
|
||||||
|
Available categories: ${categoryNames.join(", ")}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const isUnstableAgent = resolved.config.is_unstable_agent === true || (actualModel?.toLowerCase().includes("gemini") ?? false)
|
||||||
// Handle both boolean false and string "false" due to potential serialization
|
// Handle both boolean false and string "false" due to potential serialization
|
||||||
const isRunInBackgroundExplicitlyFalse = args.run_in_background === false || args.run_in_background === "false" as unknown as boolean
|
const isRunInBackgroundExplicitlyFalse = args.run_in_background === false || args.run_in_background === "false" as unknown as boolean
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user