mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(copilot): check error field (not just content) for transient API errors
The transient error detection was checking str(sdk_msg.content) which contains content blocks, not the actual error string from sdk_msg.error. Now checks both the error field and content preview for transient patterns.
This commit is contained in:
@@ -1093,6 +1093,7 @@ async def stream_chat_completion_sdk(
|
||||
# so we can debug Anthropic API 400s surfaced by the CLI.
|
||||
sdk_error = getattr(sdk_msg, "error", None)
|
||||
if isinstance(sdk_msg, AssistantMessage) and sdk_error:
|
||||
error_text = str(sdk_error)
|
||||
error_preview = str(sdk_msg.content)[:500]
|
||||
logger.error(
|
||||
"[SDK] [%s] AssistantMessage has error=%s, "
|
||||
@@ -1107,7 +1108,10 @@ async def stream_chat_completion_sdk(
|
||||
# ECONNRESET) — replace raw message with a
|
||||
# user-friendly error and mark as retryable so the
|
||||
# frontend can offer a retry button.
|
||||
if is_transient_api_error(error_preview):
|
||||
# Check both the error field and content for patterns.
|
||||
if is_transient_api_error(error_text) or is_transient_api_error(
|
||||
error_preview
|
||||
):
|
||||
logger.warning(
|
||||
"%s Transient Anthropic API error detected, "
|
||||
"suppressing raw error text",
|
||||
|
||||
Reference in New Issue
Block a user