Merge pull request #274 from mai1015/feat/refactor-agent-loop

feat(providers): add native tool-calling for OpenRouter/Anthropic and align provider tests with simple_chat
This commit is contained in:
Chummy 2026-02-17 01:06:56 +08:00 committed by GitHub
commit f13ce909c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 2596 additions and 474 deletions

View file

@ -221,14 +221,9 @@ impl Tool for DelegateTool {
match result {
Ok(response) => {
let has_tool_calls = response.has_tool_calls();
let mut rendered = response.text.unwrap_or_default();
let mut rendered = response;
if rendered.trim().is_empty() {
if has_tool_calls {
rendered = "[Tool-only response; no text content]".to_string();
} else {
rendered = "[Empty response]".to_string();
}
rendered = "[Empty response]".to_string();
}
Ok(ToolResult {

View file

@ -170,8 +170,12 @@ pub fn all_tools_with_runtime(
// Add delegation tool when agents are configured
if !agents.is_empty() {
let delegate_agents: HashMap<String, DelegateAgentConfig> = agents
.iter()
.map(|(name, cfg)| (name.clone(), cfg.clone()))
.collect();
tools.push(Box::new(DelegateTool::new(
agents.clone(),
delegate_agents,
fallback_api_key.map(String::from),
)));
}