From 723fd6fa6260e3e07b59faace4f8acbc763a0c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Tue, 21 Apr 2026 14:54:19 +0200 Subject: [PATCH] agent: limit thinking budget to 2048 tokens --- src/agent/Agent.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/agent/Agent.zig b/src/agent/Agent.zig index 490bb883..21cda48f 100644 --- a/src/agent/Agent.zig +++ b/src/agent/Agent.zig @@ -728,6 +728,12 @@ fn processUserMessage(self: *Self, user_input: []const u8, record_comment: []con .max_turns = 30, .max_tokens = 4096, .tool_choice = .auto, + // Cap per-turn reasoning for thinking models. Without this, + // Gemini thinking models can spend minutes per turn exploring, + // which makes 30-turn tool-use loops take 7-10 min per task on + // open-ended questions. 2048 tokens is enough to plan the next + // tool call or finalize; it's ignored by non-thinking models. + .thinking_budget = 2048, }, ) catch |err| { log.err(.app, "AI API error", .{ .err = err });