Skip to content

Commit 2a08185

Browse files
committed
fix: improve context length error detection for PPIO platform compatibility
- Extend error detection to handle PPIO's error message format: 'The input is longer than the model's context length' - Add case-insensitive matching using .lower() for robustness - Maintain backward compatibility with existing 'maximum context length' check This fixes the issue where PPIO platform models (e.g., ppio/zai-org/glm-5-turbo) would fail with AgentState.ERROR due to unrecognized context length errors.
1 parent 7cee5bd commit 2a08185

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

astrbot/core/provider/sources/openai_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ async def _handle_api_error(
10691069
image_fallback_used,
10701070
)
10711071
raise e
1072-
if "maximum context length" in str(e):
1072+
if "maximum context length" in str(e) or "context length" in str(e).lower():
10731073
logger.warning(
10741074
f"上下文长度超过限制。尝试弹出最早的记录然后重试。当前记录条数: {len(context_query)}",
10751075
)

0 commit comments

Comments
 (0)