aKode: robustezza dell'agente (punto 4, blocco B)
- Compattazione: prima del riassunto l'output degli strumenti più vecchi (tutti tranne gli ultimi 3, sopra i 400 caratteri) diventa un segnaposto breve; le chiamate restano. La compattazione usa sempre il provider configurato: verificato, con un test sulle capacità dei provider. - Protezione dai loop in stile Gemini CLI, accanto a max_repeated_failures: [agent] max_identical_tool_calls (5 risposte di fila con la stessa chiamata, qualunque sia il risultato; esclusi write_stdin e wait_agent; le chiamate parallele di una risposta contano una volta) e [agent] max_repeated_text (lo stesso testo ripetuto 10 volte di seguito mentre arriva, nella risposta o nel ragionamento; esclusi blocchi di codice e separatori). - Cancellazioni ricorsive protette (rm -r, rm -rf, find -delete): radice, home, radice del repository, cartella di lavoro, percorsi fuori da essa o calcolati a runtime ($VAR, $(...), xargs) chiedono sempre la conferma dell'utente, anche con regole che li permetterebbero; in accesso completo vengono rifiutati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -696,6 +696,12 @@ pub const DEFAULT_MAX_REPEATED_FAILURES: u32 = 3;
|
||||
/// Default for `[agent] announce_nudges`.
|
||||
pub const DEFAULT_ANNOUNCE_NUDGES: u32 = 1;
|
||||
|
||||
/// Default for `[agent] max_identical_tool_calls` (the threshold of Gemini CLI).
|
||||
pub const DEFAULT_MAX_IDENTICAL_TOOL_CALLS: u32 = 5;
|
||||
|
||||
/// Default for `[agent] max_repeated_text` (the threshold of Gemini CLI).
|
||||
pub const DEFAULT_MAX_REPEATED_TEXT: u32 = 10;
|
||||
|
||||
/// Session delivery of the `memoria` plugin (`[memoria] deliver_sessions`).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct MemoriaDeliveryConfig {
|
||||
@@ -1283,6 +1289,14 @@ pub struct Config {
|
||||
/// (`[agent] announce_nudges`). `0` disables it.
|
||||
pub announce_nudges: u32,
|
||||
|
||||
/// Loop protection: stop the turn after this many identical tool calls in a row, whatever
|
||||
/// the result (`[agent] max_identical_tool_calls`). `0` disables the check.
|
||||
pub max_identical_tool_calls: u32,
|
||||
|
||||
/// Loop protection: stop a streaming answer that repeats the same text this many times
|
||||
/// back to back (`[agent] max_repeated_text`). `0` disables the check.
|
||||
pub max_repeated_text: u32,
|
||||
|
||||
/// Session-start briefing of the `memoria` plugin (`[memoria]`).
|
||||
pub memoria_briefing: MemoriaBriefingConfig,
|
||||
|
||||
@@ -4293,6 +4307,16 @@ impl Config {
|
||||
.as_ref()
|
||||
.and_then(|agent| agent.announce_nudges)
|
||||
.unwrap_or(DEFAULT_ANNOUNCE_NUDGES);
|
||||
let max_identical_tool_calls = cfg
|
||||
.agent
|
||||
.as_ref()
|
||||
.and_then(|agent| agent.max_identical_tool_calls)
|
||||
.unwrap_or(DEFAULT_MAX_IDENTICAL_TOOL_CALLS);
|
||||
let max_repeated_text = cfg
|
||||
.agent
|
||||
.as_ref()
|
||||
.and_then(|agent| agent.max_repeated_text)
|
||||
.unwrap_or(DEFAULT_MAX_REPEATED_TEXT);
|
||||
let memoria_briefing = {
|
||||
let defaults = MemoriaBriefingConfig::default();
|
||||
let toml = cfg.memoria.clone().unwrap_or_default();
|
||||
@@ -4935,6 +4959,8 @@ impl Config {
|
||||
background_terminal_max_timeout,
|
||||
max_repeated_failures,
|
||||
announce_nudges,
|
||||
max_identical_tool_calls,
|
||||
max_repeated_text,
|
||||
memoria_briefing,
|
||||
memoria_delivery,
|
||||
memoria_anchors,
|
||||
|
||||
Reference in New Issue
Block a user