refactor(sisyphus-task): use dynamic model fallback from OpenCode config

- Remove hardcoded "anthropic/claude-sonnet-4-5" fallback
- Fetch systemDefaultModel from client.config.get() at tool boundary
- Add 'category-default' and 'system-default' fallback types
- Use switch(actualModel) for cleaner type detection
- Add guard clauses and fail-loud validation for invalid models
- Wrap config fetch in try/catch for graceful degradation
- Update toast messages with typed suffixMap
This commit is contained in:
Kenny
2026-01-14 14:45:01 -05:00
parent 4a892a9809
commit 8a9ebe1012
5 changed files with 153 additions and 49 deletions
@@ -144,14 +144,35 @@ describe("TaskToastManager", () => {
})
describe("model fallback info in toast message", () => {
test("should display warning when model falls back to default", () => {
// #given - a task with model fallback to default
test("should display warning when model falls back to category-default", () => {
// #given - a task with model fallback to category-default
const task = {
id: "task_1",
description: "Task with default model",
description: "Task with category default model",
agent: "Sisyphus-Junior",
isBackground: false,
modelInfo: { model: "anthropic/claude-sonnet-4-5", type: "default" as const },
modelInfo: { model: "google/gemini-3-pro-preview", type: "category-default" as const },
}
// #when - addTask is called
toastManager.addTask(task)
// #then - toast should show warning with model info
expect(mockClient.tui.showToast).toHaveBeenCalled()
const call = mockClient.tui.showToast.mock.calls[0][0]
expect(call.body.message).toContain("⚠️")
expect(call.body.message).toContain("google/gemini-3-pro-preview")
expect(call.body.message).toContain("(category default)")
})
test("should display warning when model falls back to system-default", () => {
// #given - a task with model fallback to system-default
const task = {
id: "task_1b",
description: "Task with system default model",
agent: "Sisyphus-Junior",
isBackground: false,
modelInfo: { model: "anthropic/claude-sonnet-4-5", type: "system-default" as const },
}
// #when - addTask is called
@@ -162,7 +183,7 @@ describe("TaskToastManager", () => {
const call = mockClient.tui.showToast.mock.calls[0][0]
expect(call.body.message).toContain("⚠️")
expect(call.body.message).toContain("anthropic/claude-sonnet-4-5")
expect(call.body.message).toContain("(default)")
expect(call.body.message).toContain("(system default)")
})
test("should display warning when model is inherited from parent", () => {
@@ -204,7 +225,8 @@ describe("TaskToastManager", () => {
const call = mockClient.tui.showToast.mock.calls[0][0]
expect(call.body.message).not.toContain("⚠️ Model:")
expect(call.body.message).not.toContain("(inherited)")
expect(call.body.message).not.toContain("(default)")
expect(call.body.message).not.toContain("(category default)")
expect(call.body.message).not.toContain("(system default)")
})
test("should not display model info when not provided", () => {
+6 -1
View File
@@ -110,7 +110,12 @@ export class TaskToastManager {
// Show model fallback warning for the new task if applicable
if (newTask.modelInfo && newTask.modelInfo.type !== "user-defined") {
const icon = "⚠️"
const suffix = newTask.modelInfo.type === "inherited" ? " (inherited)" : " (default)"
const suffixMap: Partial<Record<ModelFallbackInfo["type"], string>> = {
inherited: " (inherited)",
"category-default": " (category default)",
"system-default": " (system default)",
}
const suffix = suffixMap[newTask.modelInfo.type] ?? ""
lines.push(`${icon} Model: ${newTask.modelInfo.model}${suffix}`)
lines.push("")
}
+1 -1
View File
@@ -2,7 +2,7 @@ export type TaskStatus = "running" | "queued" | "completed" | "error"
export interface ModelFallbackInfo {
model: string
type: "user-defined" | "inherited" | "default"
type: "user-defined" | "inherited" | "category-default" | "system-default"
}
export interface TrackedTask {