mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix: handle PPIO platform context-length error messages (#7888)
* fix: 压缩算法删除 user 消息 Bug 修复 * perf: improve truncate algo * 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. --------- Co-authored-by: Soulter <905617992@qq.com>
This commit is contained in:
@@ -1076,7 +1076,7 @@ class ProviderOpenAIOfficial(Provider):
|
||||
image_fallback_used,
|
||||
)
|
||||
raise e
|
||||
if "maximum context length" in str(e):
|
||||
if "maximum context length" in str(e) or "context length" in str(e).lower():
|
||||
logger.warning(
|
||||
f"上下文长度超过限制。尝试弹出最早的记录然后重试。当前记录条数: {len(context_query)}",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user