From f70d108193b19bbb7462c1ef5aa7699d36550f81 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 22 Mar 2026 02:16:51 -0400 Subject: [PATCH] api: include turn/payload/message count in API error messages Co-Authored-By: Claude Opus 4.6 (1M context) --- poc-memory/src/agents/api.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/poc-memory/src/agents/api.rs b/poc-memory/src/agents/api.rs index 71db94d..33dddc5 100644 --- a/poc-memory/src/agents/api.rs +++ b/poc-memory/src/agents/api.rs @@ -59,7 +59,13 @@ pub async fn call_api_with_tools( &ui_tx, StreamTarget::Autonomous, &reasoning, - ).await.map_err(|e| format!("API error: {}", e))?; + ).await.map_err(|e| { + let msg_bytes: usize = messages.iter() + .map(|m| m.content_text().len()) + .sum(); + format!("API error on turn {} (~{}KB payload, {} messages): {}", + turn, msg_bytes / 1024, messages.len(), e) + })?; if let Some(u) = &usage { log(&format!("tokens: {} prompt + {} completion",