aKode 0.9.1: correzioni dalla prova di Fourier (apply_patch, write_file, errori visibili, rete dei pacchetti)
- apply_patch tollerante: aggiunge '*** Begin Patch'/'*** End Patch' mancanti quando
il contenuto inizia con Add/Update/Delete File, toglie i recinti ```; ogni altra
ambiguità resta un errore; riga con il formato e un esempio negli errori di formato.
- Strumento write_file (path + contenuto) sulla pipeline di apply_patch (stesse
verifiche, sandbox, approvazioni e hook), [tools] write_file (predefinito attivo);
dopo la scrittura ricorda al modello di verificare il file.
- Chiamate a strumento fallite visibili nella TUI ("✗ strumento: motivo · riprovo").
- Avanzamento mentre il modello scrive una chiamata lunga ("Scrivo file · N token")
e stato del gateway imeAI ("In coda…", "Leggo il prompt · 42%").
- write_stdin con id inesistente: elenca le sessioni aperte e indica exec_command o
write_file; descrizione più chiara.
- Protezione dai loop: un avviso al modello prima di fermare il turno.
- Sandbox predefinita: rete attiva solo verso i registri dei pacchetti attraverso il
proxy di rete ([features.network_proxy] nei default impacchettati); scritture
invariate; nota al modello sugli errori di rete in sandbox.
- Testi della TUI in italiano (benvenuto, segnaposto, suggerimenti, «Errore fatale»).
- Test adattati ai nuovi default (rete del profilo :workspace, allowlist), snapshot e
schemi rigenerati.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -92,6 +92,14 @@ pub enum ResponseEvent {
|
||||
call_id: Option<String>,
|
||||
delta: String,
|
||||
},
|
||||
/// aKode: progress of a local server before generation starts (imeAI gateway
|
||||
/// `imeai.queue` / `imeai.prefill`): `kind` is `queue` or `prefill`.
|
||||
ServerProgress {
|
||||
kind: String,
|
||||
percent: Option<f64>,
|
||||
eta_s: Option<f64>,
|
||||
ahead: Option<u64>,
|
||||
},
|
||||
ReasoningSummaryDelta {
|
||||
delta: String,
|
||||
summary_index: i64,
|
||||
|
||||
@@ -345,7 +345,9 @@ pub fn process_responses_event(
|
||||
return Ok(Some(ResponseEvent::OutputTextDelta(delta)));
|
||||
}
|
||||
}
|
||||
"response.custom_tool_call_input.delta" => {
|
||||
// aKode: function arguments stream too (used for progress while a long
|
||||
// call is generated). `call_id` is usually absent: the active call is used.
|
||||
"response.custom_tool_call_input.delta" | "response.function_call_arguments.delta" => {
|
||||
if let (Some(delta), Some(item_id)) =
|
||||
(event.delta, event.item_id.clone().or(event.call_id.clone()))
|
||||
{
|
||||
@@ -488,7 +490,6 @@ pub fn process_responses_event(
|
||||
| "response.content_part.added"
|
||||
| "response.content_part.done"
|
||||
| "response.custom_tool_call_input.done"
|
||||
| "response.function_call_arguments.delta"
|
||||
| "response.function_call_arguments.done"
|
||||
| "response.in_progress"
|
||||
| "response.metadata"
|
||||
@@ -590,7 +591,12 @@ async fn process_sse_with_treatment(
|
||||
trace!("SSE event: {}", &sse.data);
|
||||
|
||||
if is_server_progress_event(&sse.event) {
|
||||
// Queue position and prompt-reading progress: only signs of life for this client.
|
||||
// Queue position and prompt-reading progress: shown by the client as status.
|
||||
if let Some(event) = server_progress_event(&sse.event, &sse.data)
|
||||
&& tx_event.send(Ok(event)).await.is_err()
|
||||
{
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -675,6 +681,23 @@ fn is_server_progress_event(event: &str) -> bool {
|
||||
event.starts_with("imeai.")
|
||||
}
|
||||
|
||||
/// `imeai.queue` / `imeai.prefill` as a [`ResponseEvent::ServerProgress`]; other
|
||||
/// `imeai.*` events (or malformed data) yield nothing.
|
||||
fn server_progress_event(event: &str, data: &str) -> Option<ResponseEvent> {
|
||||
let kind = match event {
|
||||
"imeai.queue" => "queue",
|
||||
"imeai.prefill" => "prefill",
|
||||
_ => return None,
|
||||
};
|
||||
let value: Value = serde_json::from_str(data).ok()?;
|
||||
Some(ResponseEvent::ServerProgress {
|
||||
kind: kind.to_string(),
|
||||
percent: value.get("percent").and_then(Value::as_f64),
|
||||
eta_s: value.get("eta_s").and_then(Value::as_f64),
|
||||
ahead: value.get("ahead").and_then(Value::as_u64),
|
||||
})
|
||||
}
|
||||
|
||||
/// Waits for the next SSE event; fails only after `idle_timeout` without any bytes at all, so
|
||||
/// keep-alive comments and progress events keep a long prompt read alive.
|
||||
async fn next_with_activity_timeout<S>(
|
||||
@@ -1047,7 +1070,15 @@ mod tests {
|
||||
delta,
|
||||
} if item_id == "ctc_1" && call_id == "call_1" && delta == "*** Begin"
|
||||
);
|
||||
assert_matches!(&events[1], ResponseEvent::Completed { .. });
|
||||
assert_matches!(
|
||||
&events[1],
|
||||
ResponseEvent::ToolCallInputDelta {
|
||||
item_id,
|
||||
call_id: None,
|
||||
delta,
|
||||
} if item_id == "fc_1" && delta == "{\"input\":\""
|
||||
);
|
||||
assert_matches!(&events[2], ResponseEvent::Completed { .. });
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -1139,8 +1170,18 @@ data: {"type":"response.completed","response":{"id":"resp1"}}
|
||||
|
||||
let events = collect_until_closed(stream).await;
|
||||
|
||||
assert_eq!(events.len(), 1, "{events:?}");
|
||||
assert_matches!(&events[0], Ok(ResponseEvent::Completed { response_id, .. }) if response_id == "resp1");
|
||||
// aKode: queue and prefill progress are forwarded to the client as status.
|
||||
assert_eq!(events.len(), 4, "{events:?}");
|
||||
assert_matches!(
|
||||
&events[0],
|
||||
Ok(ResponseEvent::ServerProgress { kind, ahead: Some(1), .. }) if kind == "queue"
|
||||
);
|
||||
assert_matches!(
|
||||
&events[1],
|
||||
Ok(ResponseEvent::ServerProgress { kind, percent: Some(40.0), eta_s: Some(3.0), .. })
|
||||
if kind == "prefill"
|
||||
);
|
||||
assert_matches!(&events[3], Ok(ResponseEvent::Completed { response_id, .. }) if response_id == "resp1");
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
|
||||
Reference in New Issue
Block a user