@opencode-ai/ai 0.0.0-next-15845 → 0.0.0-next-15847

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,13 +2,17 @@ import { Option, Schema } from "effect";
2
2
  import { AuthenticationReason, ContentPolicyReason, InvalidRequestReason, LLMError, ProviderErrorEvent, ProviderInternalReason, QuotaExceededReason, RateLimitReason, UnknownProviderReason, } from "./schema";
3
3
  const patterns = [
4
4
  /prompt is too long/i,
5
+ /request_too_large/i,
5
6
  /input is too long for requested model/i,
6
7
  /exceeds the context window/i,
8
+ /exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,
7
9
  /input token count.*exceeds the maximum/i,
8
10
  /tokens in request more than max tokens allowed/i,
9
11
  /maximum prompt length is \d+/i,
10
12
  /reduce the length of the messages/i,
11
13
  /maximum context length is \d+ tokens/i,
14
+ /exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,
15
+ /input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,
12
16
  /exceeds the limit of \d+/i,
13
17
  /exceeds the available context size/i,
14
18
  /greater than the context length/i,
@@ -20,9 +24,14 @@ const patterns = [
20
24
  /input length.*exceeds.*context length/i,
21
25
  /prompt too long; exceeded (?:max )?context length/i,
22
26
  /too large for model with \d+ maximum context length/i,
27
+ /prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,
23
28
  /model_context_window_exceeded/i,
29
+ /too many tokens/i,
30
+ /token limit exceeded/i,
24
31
  ];
25
- export const isContextOverflow = (message) => patterns.some((pattern) => pattern.test(message)) || /^4(00|13)\s*(status code)?\s*\(no body\)/i.test(message);
32
+ const exclusions = [/^(throttling error|service unavailable):/i, /rate limit/i, /too many requests/i];
33
+ export const isContextOverflow = (message) => !exclusions.some((pattern) => pattern.test(message)) &&
34
+ (patterns.some((pattern) => pattern.test(message)) || /^4(00|13)\s*(status code)?\s*\(no body\)/i.test(message));
26
35
  export const isContextOverflowFailure = (failure) => failure instanceof LLMError
27
36
  ? failure.reason._tag === "InvalidRequest" && failure.reason.classification === "context-overflow"
28
37
  : Schema.is(ProviderErrorEvent)(failure) && failure.classification === "context-overflow";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-next-15845",
3
+ "version": "0.0.0-next-15847",
4
4
  "name": "@opencode-ai/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@clack/prompts": "1.0.0-alpha.1",
28
28
  "@effect/platform-node": "4.0.0-beta.98",
29
- "@opencode-ai/http-recorder": "0.0.0-next-15845",
29
+ "@opencode-ai/http-recorder": "0.0.0-next-15847",
30
30
  "@tsconfig/bun": "1.0.9",
31
31
  "@types/bun": "1.3.13",
32
32
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@smithy/eventstream-codec": "4.2.14",
37
37
  "@smithy/util-utf8": "4.2.2",
38
- "@opencode-ai/schema": "0.0.0-next-15845",
38
+ "@opencode-ai/schema": "0.0.0-next-15847",
39
39
  "aws4fetch": "1.0.20",
40
40
  "effect": "4.0.0-beta.98",
41
41
  "google-auth-library": "10.5.0"