From dcefbad180233456bcd01f32bfd4eb665a53daa9 Mon Sep 17 00:00:00 2001 From: mawkone Date: Tue, 2 Jun 2026 13:29:34 -0700 Subject: [PATCH] fix: keep tool definitions active in schema for conversational turns to prevent MALFORMED_FUNCTION_CALL crashes --- vibn-frontend/app/api/chat/route.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vibn-frontend/app/api/chat/route.ts b/vibn-frontend/app/api/chat/route.ts index 518d43ab..318fc0cb 100644 --- a/vibn-frontend/app/api/chat/route.ts +++ b/vibn-frontend/app/api/chat/route.ts @@ -787,12 +787,10 @@ export async function POST(request: Request) { if (aborted) break; round++; - // On round 1, withhold tools if the message looks conversational. - // The model must answer in text first; tools unlock from round 2. - const toolDefs = - mcp_token && !(round === 1 && firstMessageIsConversational) - ? VIBN_TOOL_DEFINITIONS - : []; + // Keep tool definitions active in the schema to avoid model confusion and + // MALFORMED_FUNCTION_CALL gateway crashes, but let our system instructions + // guide the model to respond in plain text for conversational inputs. + const toolDefs = mcp_token ? VIBN_TOOL_DEFINITIONS : []; // Every 8 silent rounds or 12 tool calls, gently nudge the model to surface a one-liner // status before continuing. This is the user's only signal of