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:
@@ -712,12 +712,22 @@ pub(crate) async fn run_turn(
|
||||
);
|
||||
}
|
||||
|
||||
if needs_follow_up
|
||||
&& let Some(message) = super::loop_guard::repeated_failure_message(
|
||||
sess.clone_history().await.raw_items(),
|
||||
let loop_message = if needs_follow_up {
|
||||
let history = sess.clone_history().await;
|
||||
super::loop_guard::repeated_failure_message(
|
||||
history.raw_items(),
|
||||
turn_context.config.max_repeated_failures,
|
||||
)
|
||||
{
|
||||
.or_else(|| {
|
||||
super::loop_guard::identical_calls_message(
|
||||
history.raw_items(),
|
||||
turn_context.config.max_identical_tool_calls,
|
||||
)
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some(message) = loop_message {
|
||||
let event = EventMsg::Error(ErrorEvent {
|
||||
misalignment: None,
|
||||
message,
|
||||
@@ -2776,6 +2786,11 @@ async fn try_run_sampling_request(
|
||||
let defer_streamed_turn_items_for_contributors =
|
||||
!sess.services.extensions.turn_item_contributors().is_empty();
|
||||
let mut active_item_is_streaming_to_client = false;
|
||||
// Loop protection on the streamed text (`[agent] max_repeated_text`): answer and reasoning.
|
||||
let mut answer_loop =
|
||||
super::loop_guard::TextLoopDetector::new(turn_context.config.max_repeated_text);
|
||||
let mut reasoning_loop =
|
||||
super::loop_guard::TextLoopDetector::new(turn_context.config.max_repeated_text);
|
||||
let receiving_span = trace_span!("receiving_stream");
|
||||
let outcome: CodexResult<SamplingRequestResult> = loop {
|
||||
if response_completed && resampling.accepted_output.is_empty() {
|
||||
@@ -3275,6 +3290,11 @@ async fn try_run_sampling_request(
|
||||
}
|
||||
}
|
||||
ResponseEvent::OutputTextDelta(delta) => {
|
||||
if answer_loop.push(&delta) {
|
||||
break Err(CodexErr::Fatal(
|
||||
super::loop_guard::REPEATED_TEXT_MESSAGE.to_string(),
|
||||
));
|
||||
}
|
||||
// In review child threads, suppress assistant text deltas; the
|
||||
// UI will show a selection popup from the final ReviewOutput.
|
||||
if let Some(active) = active_item.as_ref() {
|
||||
@@ -3404,6 +3424,11 @@ async fn try_run_sampling_request(
|
||||
delta,
|
||||
content_index,
|
||||
} => {
|
||||
if reasoning_loop.push(&delta) {
|
||||
break Err(CodexErr::Fatal(
|
||||
super::loop_guard::REPEATED_TEXT_MESSAGE.to_string(),
|
||||
));
|
||||
}
|
||||
if let Some(active) = active_item.as_ref() {
|
||||
if !active_item_is_streaming_to_client {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user