From e309d5e2ccb660b84158fe700ee4c1d8ce1fe0c5 Mon Sep 17 00:00:00 2001 From: Tara Menon Date: Thu, 11 Jun 2026 22:22:03 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20max=5Ftokens=3D0=20bug=20?= =?UTF-8?q?=E2=80=94=20build=5Fcontext=20now=20takes=20max=5Ftokens=20from?= =?UTF-8?q?=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/gyandoot-agent/src/agent_loop.rs | 8 ++++---- crates/gyandoot-agent/src/context.rs | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/gyandoot-agent/src/agent_loop.rs b/crates/gyandoot-agent/src/agent_loop.rs index c1304c1..a7af987 100644 --- a/crates/gyandoot-agent/src/agent_loop.rs +++ b/crates/gyandoot-agent/src/agent_loop.rs @@ -301,7 +301,7 @@ impl AgentLoop { // Build context and call LLM (with retry) let context = self .context_compressor - .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions()); + .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions(), self.config.max_tokens); *self.status.lock().await = AgentStatus::Thinking; let response = self.call_with_retry(context).await?; @@ -332,7 +332,7 @@ impl AgentLoop { // Follow-up call with tool results let follow_context = self .context_compressor - .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions()); + .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions(), self.config.max_tokens); *self.status.lock().await = AgentStatus::Thinking; let follow_up = self.call_with_retry(follow_context).await?; @@ -361,7 +361,7 @@ impl AgentLoop { let context = self .context_compressor - .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions()); + .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions(), self.config.max_tokens); *self.status.lock().await = AgentStatus::Thinking; let response = self.call_with_retry(context).await?; @@ -393,7 +393,7 @@ impl AgentLoop { let follow_context = self .context_compressor - .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions()); + .build_context(&messages, &self.config.system_prompt, &self.tool_executor.definitions(), self.config.max_tokens); *self.status.lock().await = AgentStatus::Thinking; let follow_up = self.call_with_retry(follow_context).await?; diff --git a/crates/gyandoot-agent/src/context.rs b/crates/gyandoot-agent/src/context.rs index 8a1b5fd..5efb6aa 100644 --- a/crates/gyandoot-agent/src/context.rs +++ b/crates/gyandoot-agent/src/context.rs @@ -223,12 +223,13 @@ impl ContextCompressor { messages: &[Message], system_prompt: &str, tool_definitions: &[ToolDefinition], + max_tokens: usize, ) -> ConversationContext { ConversationContext { messages: messages.to_vec(), system_prompt: system_prompt.to_string(), tools: tool_definitions.to_vec(), - max_tokens: 0, // caller sets this or provider defaults + max_tokens, } } }