Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(llm): fund Gemini's reasoning budget so anchored replies stop truncating

nirholas10a997c89eb0
diff --git a/api/_lib/llm.js b/api/_lib/llm.js
index cb04dea0e..74537337b 100644
--- a/api/_lib/llm.js
+++ b/api/_lib/llm.js
@@ -51,6 +51,7 @@ import {
vertexRequestHeaders,
toVertexBody,
} from './vertex-claude.js';
+import { vertexGeminiBudget } from './vertex-gemini.js';
import { DEFAULT_FREE_MODEL, promptCacheMinChars, isPaidModel } from './chat-models.js';
const GROQ_MODEL = 'llama-3.3-70b-versatile';
@@ -331,7 +332,10 @@ function vertexGeminiProvider() {
getHeaders: vertexRequestHeaders,
buildBody: (system, user, maxTokens) => ({
model: VERTEX_GEMINI_MODEL,
- max_tokens: maxTokens,
+ // Gemini reasons by default and bills those tokens against max_tokens
+ // without returning them, so an uncompensated budget comes back
+ // truncated. vertexGeminiBudget caps the reasoning and funds it on top.
+ ...vertexGeminiBudget(maxTokens),
messages: [
...(system ? [{ role: 'system', content: system }] : []),
{ role: 'user', content: user },