aKode: integrazione della memoria di imeAI (plugin memoria)
- nuovo crate ext/memoria: aggiunge le istruzioni del plugin (instructions.md) come developer policy solo se il plugin memoria è abilitato e il suo server MCP è pronto; nessuna modifica alle istruzioni di base, [features] memories resta spento - pollutes_memory configurabile per server MCP (predefinito true) - project_header per i server HTTP: progetto ricavato dalla cartella della sessione (origin come host/owner/repo, altrimenti la cartella), connessioni separate per progetto - token Bearer dei server MCP anche dal portachiavi di aKode, solo sotto mcp:<server> (mai le chiavi dei provider dei modelli) - tool namespace (MCP, multi-agente) appiattiti in <namespace>__<tool> per i server compatibili OpenAI che accettano solo function tool (llama.cpp, ik_llama.cpp, vLLM li scartavano); capacità del provider tool_namespaces - prove: parsing e propagazione, intestazione del progetto, iniezione solo se attivo e connesso, appiattimento e mappatura delle chiamate, chiavi dei provider mai consegnate ai server MCP Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -275,8 +275,18 @@ impl ToolRouter {
|
||||
ref mut encrypted_function_args,
|
||||
..
|
||||
} => {
|
||||
let tool_name =
|
||||
let mut tool_name =
|
||||
ToolName::new(namespace.clone(), name.clone()).with_default_namespace();
|
||||
// Flattened namespace tools come back as `<namespace>__<tool>` (see client.rs).
|
||||
if namespace.is_none()
|
||||
&& self.registry.registered_tool(&tool_name).is_none()
|
||||
&& let Some((ns, tool)) = name.rsplit_once(akode_tools::FLAT_NAMESPACE_SEPARATOR)
|
||||
{
|
||||
let candidate = ToolName::new(Some(ns.to_string()), tool.to_string()).with_default_namespace();
|
||||
if self.registry.registered_tool(&candidate).is_some() {
|
||||
tool_name = candidate;
|
||||
}
|
||||
}
|
||||
let retain_native_call = self
|
||||
.registry
|
||||
.registered_tool(&tool_name)
|
||||
|
||||
@@ -736,3 +736,46 @@ fn namespace_function_names(specs: &[ToolSpec], namespace_name: &str) -> Vec<Str
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn build_tool_call_maps_flattened_namespace_names() -> anyhow::Result<()> {
|
||||
let (session, turn) = make_session_and_context().await;
|
||||
let turn = Arc::new(turn);
|
||||
let step_context = StepContext::for_test(Arc::clone(&turn));
|
||||
let router = test_tool_router(
|
||||
step_context.as_ref(),
|
||||
vec![mcp_runtime(mcp_tool_info(
|
||||
"memoria",
|
||||
/*supports_parallel_tool_calls*/ false,
|
||||
"mcp__memoria",
|
||||
"memory_recall",
|
||||
))],
|
||||
Vec::new(),
|
||||
session.dynamic_tools().await.as_ref(),
|
||||
);
|
||||
let call = |name: &str| ResponseItem::FunctionCall {
|
||||
status: None,
|
||||
encrypted_content: None,
|
||||
id: None,
|
||||
name: name.to_string(),
|
||||
namespace: None,
|
||||
arguments: "{}".to_string(),
|
||||
encrypted_function_args: None,
|
||||
call_id: "call-flat".to_string(),
|
||||
internal_chat_message_metadata_passthrough: None,
|
||||
};
|
||||
// Servers that only accept function tools see `<namespace>__<tool>` and call it back so.
|
||||
let mapped = router
|
||||
.build_tool_call(call("mcp__memoria__memory_recall"))?
|
||||
.expect("function_call should produce a tool call");
|
||||
assert_eq!(mapped.tool_name, ToolName::namespaced("mcp__memoria", "memory_recall"));
|
||||
// Unknown flat names are left alone (the router reports them as unknown tools later).
|
||||
let unknown = router
|
||||
.build_tool_call(call("mcp__altro__memory_recall"))?
|
||||
.expect("function_call should produce a tool call");
|
||||
assert_eq!(
|
||||
unknown.tool_name,
|
||||
ToolName::plain("mcp__altro__memory_recall").with_default_namespace()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user