tools: delete dispatch_shared, use dispatch everywhere
dispatch_shared was a legacy wrapper — replaced by dispatch() which goes through the unified Tool registry. One dispatch path for all callers (interactive agent, subconscious agents, MCP server). Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
51e632c997
commit
1554d88694
2 changed files with 1 additions and 22 deletions
|
|
@ -144,23 +144,6 @@ pub async fn dispatch_with_agent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dispatch shared tools — used by subconscious agents.
|
|
||||||
pub async fn dispatch_shared(
|
|
||||||
name: &str,
|
|
||||||
args: &serde_json::Value,
|
|
||||||
_provenance: Option<&str>,
|
|
||||||
) -> Option<String> {
|
|
||||||
for tool in tools() {
|
|
||||||
if tool.name == name {
|
|
||||||
return Some(match (tool.handler)(None, args.clone()).await {
|
|
||||||
Ok(s) => s,
|
|
||||||
Err(e) => format!("Error: {}", e),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return all registered tools with definitions + handlers.
|
/// Return all registered tools with definitions + handlers.
|
||||||
pub fn tools() -> Vec<Tool> {
|
pub fn tools() -> Vec<Tool> {
|
||||||
let mut all = vec![
|
let mut all = vec![
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,7 @@ pub async fn call_api_with_tools(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let prov = provenance.borrow().clone();
|
let output = agent_tools::dispatch(&call.function.name, &args).await;
|
||||||
let output = match agent_tools::dispatch_shared(&call.function.name, &args, Some(&prov)).await {
|
|
||||||
Some(out) => out,
|
|
||||||
None => format!("Error: Unknown tool: {}", call.function.name),
|
|
||||||
};
|
|
||||||
|
|
||||||
if std::env::var("POC_AGENT_VERBOSE").is_ok() {
|
if std::env::var("POC_AGENT_VERBOSE").is_ok() {
|
||||||
log(&format!("TOOL RESULT ({} chars):\n{}", output.len(), output));
|
log(&format!("TOOL RESULT ({} chars):\n{}", output.len(), output));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue