🐛 Fix max_tokens=0 bug — build_context now takes max_tokens from config
This commit is contained in:
@@ -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?;
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user