Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix(agent): classify llama-server context-overflow bodies for compaction retry (#8655)
Akarshan Biswase6feae3547e4
diff --git a/src-tauri/src/core/agent/upstream.rs b/src-tauri/src/core/agent/upstream.rsindex 423e67c46..273984bf3 100644--- a/src-tauri/src/core/agent/upstream.rs+++ b/src-tauri/src/core/agent/upstream.rs@@ -544,6 +544,8 @@ pub(crate) fn is_context_overflow_body(body: &str) -> bool {|| b.contains("prompt is too long")|| b.contains("exceeds the maximum number of tokens")|| b.contains("the request exceeds the available context")+ || b.contains("exceeds the available context size")+ || b.contains("exceed_context_size_error")|| b.contains("exceed context")|| b.contains("context window")|| (b.contains("context") && b.contains("too long"))@@ -1117,6 +1119,11 @@ mod tests {assert!(is_context_overflow_body("the request exceeds the available context size"));+ assert!(is_context_overflow_body(+ "{\"error\":{\"code\":400,\"message\":\"request (4267 tokens) exceeds the available \+ context size (4096 tokens), try increasing it\",\"type\":\"exceed_context_size_error\",\+ \"n_prompt_tokens\":4267,\"n_ctx\":4096}}"+ ));assert!(!is_context_overflow_body("invalid api key"));assert!(!is_context_overflow_body("rate limit exceeded"));}