api: include turn/payload/message count in API error messages
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
be2b499978
commit
f70d108193
1 changed files with 7 additions and 1 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue