mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(copilot): prevent duplicate error markers and extract shared helper
- Change stale error marker cleanup from `if` to `while` so ALL trailing markers are removed (fixes issue where mid-stream error + cleanup error could leave a stale marker) - Skip appending error marker in BaseException handler when one was already appended inside the stream loop (ended_with_stream_error) - Extract `_append_error_marker()` helper to deduplicate marker appending logic across 4 call sites - Update misleading "mark as retryable" comment to match actual behavior (uses retryable prefix, not a model field) - Add docstring to `_safe()` helper - Remove unused `prefix` variable from stream error tuple
This commit is contained in:
@@ -660,7 +660,10 @@ async def stream_chat_completion_sdk(
|
||||
len(session.messages) > 0
|
||||
and session.messages[-1].role == "assistant"
|
||||
and session.messages[-1].content
|
||||
and COPILOT_ERROR_PREFIX in session.messages[-1].content
|
||||
and (
|
||||
COPILOT_ERROR_PREFIX in session.messages[-1].content
|
||||
or COPILOT_RETRYABLE_ERROR_PREFIX in session.messages[-1].content
|
||||
)
|
||||
):
|
||||
logger.info(
|
||||
"[SDK] [%s] Removing stale error marker from previous turn",
|
||||
|
||||
Reference in New Issue
Block a user