@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed OpenAI-compatible context overflow detection for parenthesized `maximum context length (N)` errors ([#5677](https://github.com/earendil-works/pi/issues/5677)).
|
||||||
- Fixed OpenAI GPT-5.4/GPT-5.5 and OpenAI Codex GPT-5.4/GPT-5.4 mini/GPT-5.5 context window metadata to match current OpenAI limits ([#5644](https://github.com/earendil-works/pi/issues/5644)).
|
- Fixed OpenAI GPT-5.4/GPT-5.5 and OpenAI Codex GPT-5.4/GPT-5.4 mini/GPT-5.5 context window metadata to match current OpenAI limits ([#5644](https://github.com/earendil-works/pi/issues/5644)).
|
||||||
- Increased the OpenAI Codex Responses SSE response-header timeout to 20 seconds to reduce false-positive stalls while retaining the bounded wait introduced for zero-event hangs ([#4945](https://github.com/earendil-works/pi/issues/4945)).
|
- Increased the OpenAI Codex Responses SSE response-header timeout to 20 seconds to reduce false-positive stalls while retaining the bounded wait introduced for zero-event hangs ([#4945](https://github.com/earendil-works/pi/issues/4945)).
|
||||||
- Fixed Claude Fable 5 thinking-off requests to omit Anthropic's unsupported `thinking.type: "disabled"` payload ([#5567](https://github.com/earendil-works/pi/pull/5567) by [@tmustier](https://github.com/tmustier)).
|
- Fixed Claude Fable 5 thinking-off requests to omit Anthropic's unsupported `thinking.type: "disabled"` payload ([#5567](https://github.com/earendil-works/pi/pull/5567) by [@tmustier](https://github.com/tmustier)).
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import type { AssistantMessage } from "../types.ts";
|
|||||||
* - Anthropic: "413 {\"error\":{\"type\":\"request_too_large\",\"message\":\"Request exceeds the maximum size\"}}"
|
* - Anthropic: "413 {\"error\":{\"type\":\"request_too_large\",\"message\":\"Request exceeds the maximum size\"}}"
|
||||||
* - OpenAI: "Your input exceeds the context window of this model"
|
* - OpenAI: "Your input exceeds the context window of this model"
|
||||||
* - OpenAI/LiteLLM: "Requested token count exceeds the model's maximum context length of 131072 tokens"
|
* - OpenAI/LiteLLM: "Requested token count exceeds the model's maximum context length of 131072 tokens"
|
||||||
|
* - OpenAI-compatible: "Input length (265330) exceeds model's maximum context length (262144)."
|
||||||
* - Google: "The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)"
|
* - Google: "The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)"
|
||||||
* - xAI: "This model's maximum prompt length is 131072 but the request contains 537812 tokens"
|
* - xAI: "This model's maximum prompt length is 131072 but the request contains 537812 tokens"
|
||||||
* - Groq: "Please reduce the length of the messages or completion"
|
* - Groq: "Please reduce the length of the messages or completion"
|
||||||
@@ -36,7 +37,7 @@ const OVERFLOW_PATTERNS = [
|
|||||||
/request_too_large/i, // Anthropic request byte-size overflow (HTTP 413)
|
/request_too_large/i, // Anthropic request byte-size overflow (HTTP 413)
|
||||||
/input is too long for requested model/i, // Amazon Bedrock
|
/input is too long for requested model/i, // Amazon Bedrock
|
||||||
/exceeds the context window/i, // OpenAI (Completions & Responses API)
|
/exceeds the context window/i, // OpenAI (Completions & Responses API)
|
||||||
/exceeds (?:the )?(?:model'?s )?maximum context length of [\d,]+ tokens?/i, // OpenAI-compatible proxies (LiteLLM)
|
/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i, // OpenAI-compatible proxies (LiteLLM)
|
||||||
/input token count.*exceeds the maximum/i, // Google (Gemini)
|
/input token count.*exceeds the maximum/i, // Google (Gemini)
|
||||||
/maximum prompt length is \d+/i, // xAI (Grok)
|
/maximum prompt length is \d+/i, // xAI (Grok)
|
||||||
/reduce the length of the messages/i, // Groq
|
/reduce the length of the messages/i, // Groq
|
||||||
@@ -85,7 +86,7 @@ const NON_OVERFLOW_PATTERNS = [
|
|||||||
*
|
*
|
||||||
* **Reliable detection (returns error with detectable message):**
|
* **Reliable detection (returns error with detectable message):**
|
||||||
* - Anthropic: "prompt is too long: X tokens > Y maximum" or "request_too_large"
|
* - Anthropic: "prompt is too long: X tokens > Y maximum" or "request_too_large"
|
||||||
* - OpenAI (Completions & Responses): "exceeds the context window" or "exceeds the model's maximum context length of X tokens"
|
* - OpenAI (Completions & Responses): "exceeds the context window", "exceeds the model's maximum context length of X tokens", or "exceeds model's maximum context length (X)"
|
||||||
* - Google Gemini: "input token count exceeds the maximum"
|
* - Google Gemini: "input token count exceeds the maximum"
|
||||||
* - xAI (Grok): "maximum prompt length is X but request contains Y"
|
* - xAI (Grok): "maximum prompt length is X but request contains Y"
|
||||||
* - Groq: "reduce the length of the messages"
|
* - Groq: "reduce the length of the messages"
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ describe("isContextOverflow", () => {
|
|||||||
expect(isContextOverflow(message, 131072)).toBe(true);
|
expect(isContextOverflow(message, 131072)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("detects OpenAI-compatible parenthesized maximum context length errors", () => {
|
||||||
|
const message = createErrorMessage(
|
||||||
|
"Error: 400 Input length (265330) exceeds model's maximum context length (262144).",
|
||||||
|
);
|
||||||
|
expect(isContextOverflow(message, 262144)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("detects OpenRouter Poolside maximum allowed input length errors", () => {
|
it("detects OpenRouter Poolside maximum allowed input length errors", () => {
|
||||||
const message = createErrorMessage(
|
const message = createErrorMessage(
|
||||||
"Provider returned error: Input length 131393 exceeds the maximum allowed input length of 131040 tokens.",
|
"Provider returned error: Input length 131393 exceeds the maximum allowed input length of 131040 tokens.",
|
||||||
|
|||||||
Reference in New Issue
Block a user