aKode: consegna delle sessioni al server memoria (memory_ingest_session)

- ext/memoria: trascrizione compatta e cumulativa del thread (utente, risposte
  finali senza commentary, comandi con output troncato a ~1500 caratteri,
  file modificati, ricerche web, altri server MCP; le chiamate al server
  memoria sono ignorate), limite di ~150k caratteri tenendo il primo
  messaggio e i turni più recenti, external_context (web, other_mcp).
- Consegna con reason "idle" dopo `[memoria] deliver_idle_minutes` minuti di
  inattività (predefinito 10, il timer si annulla a ogni nuovo turno) e con
  reason "end" alla chiusura del thread (al massimo 5 s, poi rinuncia).
  Solo se ci sono turni nuovi dall'ultima consegna accettata (queued,
  duplicate, skipped); `[memoria] deliver_sessions = false` la spegne. Solo
  thread dell'utente, con il plugin memoria attivo e il server pronto.
- akode-mcp: McpResourceClient::call_tool e McpConnectionSet::call_host_tool
  per le chiamate dell'host a strumenti non elencati e fuori dal filtro
  enabled_tools (il filtro resta per il modello).
- extension-api: on_thread_closing, chiamato a inizio chiusura quando i server
  MCP sono ancora connessi (on_thread_stop arriva dopo il loro arresto).
- Test sul modello di ext/memoria/src/tests.rs: ruoli, compattazione,
  esclusione del server memoria, external_context, nessuna consegna senza
  turni nuovi, errori, timer di inattività; test del percorso host in
  akode-mcp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-15 00:49:51 +01:00
parent 854c7a66c9
commit 6d4c830805
9 changed files with 1233 additions and 10 deletions

View File

@@ -195,6 +195,16 @@ pub trait ThreadLifecycleContributor<C: Sync>: Send + Sync {
})
}
/// Called at the start of runtime teardown, after running turns were aborted and while the
/// MCP servers are still connected (they are shut down before [`Self::on_thread_stop`]).
/// The host waits for the callback, so implementations must bound their work.
fn on_thread_closing<'a>(&'a self, input: ThreadStopInput<'a>) -> ExtensionFuture<'a, ()> {
Box::pin(async move {
let _self = self;
let _input = input;
})
}
/// Called during runtime teardown, before the host closes persistent history.
/// Contributors must cancel and join their background work before returning.
fn on_thread_stop<'a>(&'a self, input: ThreadStopInput<'a>) -> ExtensionFuture<'a, ()> {