From 0f62ba8dd54d5af061f4196f7becfcccf061232f Mon Sep 17 00:00:00 2001 From: Gab Date: Fri, 27 Mar 2026 08:56:02 +1100 Subject: [PATCH] fix: better agents --- .../tfcode/src/cli/cmd/tui/context/local.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/tfcode/src/cli/cmd/tui/context/local.tsx b/packages/tfcode/src/cli/cmd/tui/context/local.tsx index ffe6aec0d..80078bdd4 100644 --- a/packages/tfcode/src/cli/cmd/tui/context/local.tsx +++ b/packages/tfcode/src/cli/cmd/tui/context/local.tsx @@ -35,9 +35,7 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ } const tfFallbackModel = createMemo(() => { - const m = { providerID: "toothfairyai", modelID: "mystica-15" } - if (isModelValid(m)) return m - return undefined + return { providerID: "toothfairyai", modelID: "mystica-15" } }) const agent = iife(() => { @@ -393,15 +391,24 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ createEffect(() => { const value = agent.current() const isTFAgent = !!value.options?.tf_agent_id - if (value.model) { + + if (isTFAgent) { + // For TF agents, always ensure a valid model is set + if (value.model && isModelValid(value.model)) { + model.set({ + providerID: value.model.providerID, + modelID: value.model.modelID, + }) + } else { + // Fallback to toothfairyai/mystica-15 for TF agents + model.setDefault({ providerID: "toothfairyai", modelID: "mystica-15" }) + } + } else if (value.model) { if (isModelValid(value.model)) { model.set({ providerID: value.model.providerID, modelID: value.model.modelID, }) - } else if (isTFAgent) { - // For TF agents with invalid model, force default to toothfairyai/mystica-15 - model.setDefault({ providerID: "toothfairyai", modelID: "mystica-15" }) } else { toast.show({ variant: "warning",