fix: 识别Claude上下文超限错误提示

补充对“input tokens exceeds the model's maximum context length”错误信息的判断,统一提示上下文过长的解决建议,提升异常提示准确性。
This commit is contained in:
ccnetcore
2026-02-04 23:46:22 +08:00
parent fadaa0d129
commit 0b30dbb8de

View File

@@ -77,7 +77,7 @@ public class AnthropicChatCompletionsService(
var error = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
var message = $"恭喜你运气爆棚遇到了错误尊享包对话异常StatusCode【{response.StatusCode.GetHashCode()}】ErrorId【{errorId}】";
if (error.Contains("prompt is too long") || error.Contains("提示词太长"))
if (error.Contains("prompt is too long") || error.Contains("提示词太长")||error.Contains("input tokens exceeds the model's maximum context length"))
{
message += $", tip: 当前提示词过长,上下文已达到上限,如在 claudecode中使用建议执行/compact压缩当前会话或开启新会话后重试";
}
@@ -128,7 +128,7 @@ public class AnthropicChatCompletionsService(
var error = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
var message = $"恭喜你运气爆棚遇到了错误尊享包对话异常StatusCode【{response.StatusCode.GetHashCode()}】ErrorId【{errorId}】";
if (error.Contains("prompt is too long") || error.Contains("提示词太长"))
if (error.Contains("prompt is too long") || error.Contains("提示词太长")||error.Contains("input tokens exceeds the model's maximum context length"))
{
message += $", tip: 当前提示词过长,上下文已达到上限,如在 claudecode中使用建议执行/compact压缩当前会话或开启新会话后重试";
}