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:
leonforcode
2026-05-02 12:17:52 +08:00
committed by GitHub
parent aa0b7a2c4a
commit 909b4ad064

View File

@@ -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)}",
)