Compare commits
No commits in common. "389e222b11f78adc9dc2cb82d93354d7b68a1469" and "f8e1f3c2eb4431957784ac6209a473918545ebef" have entirely different histories.
389e222b11
...
f8e1f3c2eb
@ -642,6 +642,17 @@ 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 {
|
||||||
|
|||||||
@ -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: 1000,
|
max_tool_iterations: 100,
|
||||||
tool_result_max_chars: 100_000,
|
tool_result_max_chars: 100_000,
|
||||||
context_tool_result_trim_chars: 2000,
|
context_tool_result_trim_chars: 2000,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -479,7 +479,7 @@ pub struct AgentConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn default_max_tool_iterations() -> usize {
|
fn default_max_tool_iterations() -> usize {
|
||||||
1000
|
100
|
||||||
}
|
}
|
||||||
|
|
||||||
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_1000() {
|
fn test_agent_config_defaults_max_tool_iterations_to_100() {
|
||||||
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, 1000);
|
assert_eq!(config.agents["default"].max_tool_iterations, 100);
|
||||||
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,
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
<!-- # 自定义 Agent 配置 -->
|
|
||||||
<!--
|
|
||||||
在此处添加你的自定义指令。
|
|
||||||
此文件的内容将注入到 agent 的 system prompt 中。
|
|
||||||
支持 Markdown 语法。
|
|
||||||
-->
|
|
||||||
@ -512,8 +512,7 @@ impl Session {
|
|||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
pub(crate) fn matches_current_user_turn(&self, topic_id: &str, message: &ChatMessage) -> bool {
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -220,7 +220,6 @@ 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| {
|
||||||
|
|||||||
@ -3,7 +3,6 @@ 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;
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ struct StreamingToolCall {
|
|||||||
struct StreamingAccumulator {
|
struct StreamingAccumulator {
|
||||||
content: String,
|
content: String,
|
||||||
reasoning_content: Option<String>,
|
reasoning_content: Option<String>,
|
||||||
tool_calls: BTreeMap<usize, StreamingToolCall>,
|
tool_calls: HashMap<usize, StreamingToolCall>,
|
||||||
response_id: String,
|
response_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1232,7 +1232,6 @@ mod tests {
|
|||||||
SkillSource::Project,
|
SkillSource::Project,
|
||||||
SkillSource::ProjectAgent,
|
SkillSource::ProjectAgent,
|
||||||
SkillSource::ProjectOpenclaw,
|
SkillSource::ProjectOpenclaw,
|
||||||
SkillSource::Custom("unknown".to_string()),
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user