Compare commits

..

3 Commits

8 changed files with 16 additions and 17 deletions

View File

@ -642,17 +642,6 @@ fn chat_message_to_llm_message(m: &ChatMessage, image_budget: &mut ImageInlineBu
} }
} }
fn chat_message_to_text_only_llm_message(m: &ChatMessage) -> Message {
Message {
role: m.role.clone(),
content: vec![ContentBlock::text(&m.content)],
reasoning_content: m.reasoning_content.clone(),
tool_call_id: m.tool_call_id.clone(),
name: m.tool_name.clone(),
tool_calls: m.tool_calls.clone(),
}
}
/// AgentLoop - Stateless agent that processes messages with tool calling support. /// AgentLoop - Stateless agent that processes messages with tool calling support.
/// History is managed externally by SessionManager. /// History is managed externally by SessionManager.
pub struct AgentLoop { pub struct AgentLoop {

View File

@ -556,7 +556,7 @@ impl InitWizard {
let agent = AgentConfig { let agent = AgentConfig {
provider: selected_provider.clone(), provider: selected_provider.clone(),
model: selected_model.clone(), model: selected_model.clone(),
max_tool_iterations: 100, max_tool_iterations: 1000,
tool_result_max_chars: 100_000, tool_result_max_chars: 100_000,
context_tool_result_trim_chars: 2000, context_tool_result_trim_chars: 2000,
}; };

View File

@ -479,7 +479,7 @@ pub struct AgentConfig {
} }
fn default_max_tool_iterations() -> usize { fn default_max_tool_iterations() -> usize {
100 1000
} }
fn default_tool_result_max_chars() -> usize { fn default_tool_result_max_chars() -> usize {
@ -1456,7 +1456,7 @@ mod tests {
} }
#[test] #[test]
fn test_agent_config_defaults_max_tool_iterations_to_100() { fn test_agent_config_defaults_max_tool_iterations_to_1000() {
let file = tempfile::NamedTempFile::new().unwrap(); let file = tempfile::NamedTempFile::new().unwrap();
std::fs::write( std::fs::write(
file.path(), file.path(),
@ -1485,7 +1485,7 @@ mod tests {
.unwrap(); .unwrap();
let config = Config::load(file.path().to_str().unwrap()).unwrap(); let config = Config::load(file.path().to_str().unwrap()).unwrap();
assert_eq!(config.agents["default"].max_tool_iterations, 100); assert_eq!(config.agents["default"].max_tool_iterations, 1000);
assert_eq!(config.agents["default"].tool_result_max_chars, 100_000); assert_eq!(config.agents["default"].tool_result_max_chars, 100_000);
assert_eq!( assert_eq!(
config.agents["default"].context_tool_result_trim_chars, config.agents["default"].context_tool_result_trim_chars,

View File

@ -0,0 +1,6 @@
<!-- # 自定义 Agent 配置 -->
<!--
在此处添加你的自定义指令。
此文件的内容将注入到 agent 的 system prompt 中。
支持 Markdown 语法。
-->

View File

@ -512,7 +512,8 @@ impl Session {
.unwrap_or(false) .unwrap_or(false)
} }
pub(crate) fn matches_current_user_turn(&self, topic_id: &str, message: &ChatMessage) -> bool { #[cfg(test)]
fn matches_current_user_turn(&self, topic_id: &str, message: &ChatMessage) -> bool {
self.history.matches_current_user_turn(topic_id, message) self.history.matches_current_user_turn(topic_id, message)
} }

View File

@ -220,6 +220,7 @@ impl SessionHistory {
.and_then(|history| history.iter().rev().find(|message| message.role == "user")) .and_then(|history| history.iter().rev().find(|message| message.role == "user"))
} }
#[cfg(test)]
pub(crate) fn matches_current_user_turn(&self, topic_id: &str, message: &ChatMessage) -> bool { pub(crate) fn matches_current_user_turn(&self, topic_id: &str, message: &ChatMessage) -> bool {
self.latest_user_message(topic_id) self.latest_user_message(topic_id)
.map(|current| { .map(|current| {

View File

@ -3,6 +3,7 @@ use futures_util::StreamExt;
use reqwest::Client; use reqwest::Client;
use serde::Deserialize; use serde::Deserialize;
use serde_json::{Value, json}; use serde_json::{Value, json};
use std::collections::BTreeMap;
use std::collections::HashMap; use std::collections::HashMap;
use std::time::Duration; use std::time::Duration;
@ -25,7 +26,7 @@ struct StreamingToolCall {
struct StreamingAccumulator { struct StreamingAccumulator {
content: String, content: String,
reasoning_content: Option<String>, reasoning_content: Option<String>,
tool_calls: HashMap<usize, StreamingToolCall>, tool_calls: BTreeMap<usize, StreamingToolCall>,
response_id: String, response_id: String,
} }

View File

@ -1232,6 +1232,7 @@ mod tests {
SkillSource::Project, SkillSource::Project,
SkillSource::ProjectAgent, SkillSource::ProjectAgent,
SkillSource::ProjectOpenclaw, SkillSource::ProjectOpenclaw,
SkillSource::Custom("unknown".to_string()),
] ]
); );
} }