fix: keep tool definitions active in schema for conversational turns to prevent MALFORMED_FUNCTION_CALL crashes

This commit is contained in:
2026-06-02 13:29:34 -07:00
parent 0358b02ebe
commit dcefbad180

View File

@@ -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