@remnic/core 10.0.163 → 10.0.165
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.
- package/dist/access-admin-ops-surface.js +3 -3
- package/dist/access-cli.js +3 -3
- package/dist/access-extraction-force-flush-preempt.js +3 -3
- package/dist/access-extraction-force-flush.js +3 -3
- package/dist/access-http-briefing.js +3 -3
- package/dist/access-http-query.js +3 -3
- package/dist/access-http.js +3 -3
- package/dist/access-identity-continuity-surface.js +3 -3
- package/dist/access-lcm-surface.js +3 -3
- package/dist/access-mcp.js +3 -3
- package/dist/access-observe-write-surface.js +3 -3
- package/dist/access-operations-batch.js +3 -3
- package/dist/access-operations.js +3 -3
- package/dist/access-recall-concurrency.js +3 -3
- package/dist/access-recall-response.js +3 -3
- package/dist/access-recall-surface.js +3 -3
- package/dist/access-service.js +3 -3
- package/dist/{chunk-5MXKS25U.js → chunk-6S4DM53Y.js} +2 -2
- package/dist/{chunk-GDAFI6HH.js → chunk-IHOKB3L3.js} +2 -2
- package/dist/{chunk-2S3M2GLC.js → chunk-M7Q7Z6V5.js} +34 -1
- package/dist/chunk-M7Q7Z6V5.js.map +1 -0
- package/dist/{chunk-QUC4S2D2.js → chunk-V4ASAWRP.js} +10 -2
- package/dist/chunk-V4ASAWRP.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/explicit-capture.js +3 -3
- package/dist/extraction-error-classification.d.ts +23 -1
- package/dist/extraction-error-classification.d.ts.map +1 -1
- package/dist/extraction-error-classification.js +7 -1
- package/dist/extraction.d.ts.map +1 -1
- package/dist/extraction.js +2 -2
- package/dist/index.js +3 -3
- package/dist/orchestration/backlog-scheduler.js +4 -4
- package/dist/orchestration/buffer-drain-runner.js +4 -4
- package/dist/orchestrator.js +3 -3
- package/dist/recall-navigation.js +3 -3
- package/package.json +2 -2
- package/src/extraction-direct-input-too-large.test.ts +141 -0
- package/src/extraction-error-classification.ts +61 -1
- package/src/extraction.ts +7 -1
- package/dist/chunk-2S3M2GLC.js.map +0 -1
- package/dist/chunk-QUC4S2D2.js.map +0 -1
- /package/dist/{chunk-5MXKS25U.js.map → chunk-6S4DM53Y.js.map} +0 -0
- /package/dist/{chunk-GDAFI6HH.js.map → chunk-IHOKB3L3.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -259,7 +259,7 @@ import {
|
|
|
259
259
|
writeManifest,
|
|
260
260
|
writeMeetingEpisodeMemory,
|
|
261
261
|
writeTimelineState
|
|
262
|
-
} from "./chunk-
|
|
262
|
+
} from "./chunk-IHOKB3L3.js";
|
|
263
263
|
import "./chunk-TH6OYP6I.js";
|
|
264
264
|
import "./chunk-PQM3B54K.js";
|
|
265
265
|
import {
|
|
@@ -753,7 +753,7 @@ import {
|
|
|
753
753
|
import "./chunk-LEO4MQ3S.js";
|
|
754
754
|
import {
|
|
755
755
|
ExtractionEngine
|
|
756
|
-
} from "./chunk-
|
|
756
|
+
} from "./chunk-V4ASAWRP.js";
|
|
757
757
|
import "./chunk-EI6V5UXY.js";
|
|
758
758
|
import "./chunk-6TPWIPE3.js";
|
|
759
759
|
import {
|
|
@@ -805,7 +805,7 @@ import "./chunk-FNV6ZPCY.js";
|
|
|
805
805
|
import "./chunk-PT4DZDJA.js";
|
|
806
806
|
import "./chunk-MLAMXQAW.js";
|
|
807
807
|
import "./chunk-AIYXVWUH.js";
|
|
808
|
-
import "./chunk-
|
|
808
|
+
import "./chunk-M7Q7Z6V5.js";
|
|
809
809
|
import "./chunk-C7SRUWBW.js";
|
|
810
810
|
import "./chunk-OZKOPQCM.js";
|
|
811
811
|
import "./chunk-PWFCHOB3.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BufferDrainRunner
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-6S4DM53Y.js";
|
|
4
|
+
import "../chunk-IHOKB3L3.js";
|
|
5
5
|
import "../chunk-TH6OYP6I.js";
|
|
6
6
|
import "../chunk-PQM3B54K.js";
|
|
7
7
|
import "../chunk-2MWKUVHT.js";
|
|
@@ -194,7 +194,7 @@ import "../chunk-64NJRYU2.js";
|
|
|
194
194
|
import "../chunk-U2PSE7MB.js";
|
|
195
195
|
import "../chunk-BPPUH5JM.js";
|
|
196
196
|
import "../chunk-LEO4MQ3S.js";
|
|
197
|
-
import "../chunk-
|
|
197
|
+
import "../chunk-V4ASAWRP.js";
|
|
198
198
|
import "../chunk-EI6V5UXY.js";
|
|
199
199
|
import "../chunk-6TPWIPE3.js";
|
|
200
200
|
import "../chunk-YAVIBVCU.js";
|
|
@@ -217,7 +217,7 @@ import "../chunk-FNV6ZPCY.js";
|
|
|
217
217
|
import "../chunk-PT4DZDJA.js";
|
|
218
218
|
import "../chunk-MLAMXQAW.js";
|
|
219
219
|
import "../chunk-AIYXVWUH.js";
|
|
220
|
-
import "../chunk-
|
|
220
|
+
import "../chunk-M7Q7Z6V5.js";
|
|
221
221
|
import "../chunk-C7SRUWBW.js";
|
|
222
222
|
import "../chunk-OZKOPQCM.js";
|
|
223
223
|
import "../chunk-PWFCHOB3.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BufferDrainRunner,
|
|
3
3
|
ClaimBufferStorage
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-6S4DM53Y.js";
|
|
5
|
+
import "../chunk-IHOKB3L3.js";
|
|
6
6
|
import "../chunk-TH6OYP6I.js";
|
|
7
7
|
import "../chunk-PQM3B54K.js";
|
|
8
8
|
import "../chunk-2MWKUVHT.js";
|
|
@@ -195,7 +195,7 @@ import "../chunk-64NJRYU2.js";
|
|
|
195
195
|
import "../chunk-U2PSE7MB.js";
|
|
196
196
|
import "../chunk-BPPUH5JM.js";
|
|
197
197
|
import "../chunk-LEO4MQ3S.js";
|
|
198
|
-
import "../chunk-
|
|
198
|
+
import "../chunk-V4ASAWRP.js";
|
|
199
199
|
import "../chunk-EI6V5UXY.js";
|
|
200
200
|
import "../chunk-6TPWIPE3.js";
|
|
201
201
|
import "../chunk-YAVIBVCU.js";
|
|
@@ -218,7 +218,7 @@ import "../chunk-FNV6ZPCY.js";
|
|
|
218
218
|
import "../chunk-PT4DZDJA.js";
|
|
219
219
|
import "../chunk-MLAMXQAW.js";
|
|
220
220
|
import "../chunk-AIYXVWUH.js";
|
|
221
|
-
import "../chunk-
|
|
221
|
+
import "../chunk-M7Q7Z6V5.js";
|
|
222
222
|
import "../chunk-C7SRUWBW.js";
|
|
223
223
|
import "../chunk-OZKOPQCM.js";
|
|
224
224
|
import "../chunk-PWFCHOB3.js";
|
package/dist/orchestrator.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
mergeGraphExpandedResults,
|
|
7
7
|
qmdStartupCollectionChecksWithTimeout,
|
|
8
8
|
resolveEffectiveIdentityInjectionMode
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IHOKB3L3.js";
|
|
10
10
|
import "./chunk-TH6OYP6I.js";
|
|
11
11
|
import "./chunk-PQM3B54K.js";
|
|
12
12
|
import "./chunk-2MWKUVHT.js";
|
|
@@ -203,7 +203,7 @@ import "./chunk-64NJRYU2.js";
|
|
|
203
203
|
import "./chunk-U2PSE7MB.js";
|
|
204
204
|
import "./chunk-BPPUH5JM.js";
|
|
205
205
|
import "./chunk-LEO4MQ3S.js";
|
|
206
|
-
import "./chunk-
|
|
206
|
+
import "./chunk-V4ASAWRP.js";
|
|
207
207
|
import "./chunk-EI6V5UXY.js";
|
|
208
208
|
import "./chunk-6TPWIPE3.js";
|
|
209
209
|
import "./chunk-YAVIBVCU.js";
|
|
@@ -226,7 +226,7 @@ import "./chunk-FNV6ZPCY.js";
|
|
|
226
226
|
import "./chunk-PT4DZDJA.js";
|
|
227
227
|
import "./chunk-MLAMXQAW.js";
|
|
228
228
|
import "./chunk-AIYXVWUH.js";
|
|
229
|
-
import "./chunk-
|
|
229
|
+
import "./chunk-M7Q7Z6V5.js";
|
|
230
230
|
import "./chunk-C7SRUWBW.js";
|
|
231
231
|
import "./chunk-OZKOPQCM.js";
|
|
232
232
|
import "./chunk-PWFCHOB3.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runRecallNavigation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IHOKB3L3.js";
|
|
4
4
|
import "./chunk-TH6OYP6I.js";
|
|
5
5
|
import "./chunk-PQM3B54K.js";
|
|
6
6
|
import "./chunk-2MWKUVHT.js";
|
|
@@ -193,7 +193,7 @@ import "./chunk-64NJRYU2.js";
|
|
|
193
193
|
import "./chunk-U2PSE7MB.js";
|
|
194
194
|
import "./chunk-BPPUH5JM.js";
|
|
195
195
|
import "./chunk-LEO4MQ3S.js";
|
|
196
|
-
import "./chunk-
|
|
196
|
+
import "./chunk-V4ASAWRP.js";
|
|
197
197
|
import "./chunk-EI6V5UXY.js";
|
|
198
198
|
import "./chunk-6TPWIPE3.js";
|
|
199
199
|
import "./chunk-YAVIBVCU.js";
|
|
@@ -216,7 +216,7 @@ import "./chunk-FNV6ZPCY.js";
|
|
|
216
216
|
import "./chunk-PT4DZDJA.js";
|
|
217
217
|
import "./chunk-MLAMXQAW.js";
|
|
218
218
|
import "./chunk-AIYXVWUH.js";
|
|
219
|
-
import "./chunk-
|
|
219
|
+
import "./chunk-M7Q7Z6V5.js";
|
|
220
220
|
import "./chunk-C7SRUWBW.js";
|
|
221
221
|
import "./chunk-OZKOPQCM.js";
|
|
222
222
|
import "./chunk-PWFCHOB3.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remnic/core",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.165",
|
|
4
4
|
"description": "Framework-agnostic Remnic memory engine — orchestrator, storage, extraction, search, trust zones",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -3406,7 +3406,7 @@
|
|
|
3406
3406
|
"core"
|
|
3407
3407
|
],
|
|
3408
3408
|
"peerDependencies": {
|
|
3409
|
-
"@remnic/coding-graph": "^10.0.
|
|
3409
|
+
"@remnic/coding-graph": "^10.0.165"
|
|
3410
3410
|
},
|
|
3411
3411
|
"peerDependenciesMeta": {
|
|
3412
3412
|
"@remnic/coding-graph": {
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { parseConfig } from "./config.js";
|
|
5
|
+
import { isRequestTooLargeError } from "./extraction-error-classification.js";
|
|
6
|
+
import { ExtractionEngine } from "./extraction.js";
|
|
7
|
+
import type { StructuredParseResult } from "./fallback-llm-codex-subscription.js";
|
|
8
|
+
import type { BufferTurn, ExtractionResult } from "./types.js";
|
|
9
|
+
|
|
10
|
+
// Issue #3531: forced and fail-closed flushes send the whole window as one
|
|
11
|
+
// atomic direct-client request. When the provider refuses it as too large, the
|
|
12
|
+
// failure must say so instead of surfacing as a gateway "no parsed output", and
|
|
13
|
+
// it must stay retryable so the retained turns are never parked or dropped.
|
|
14
|
+
|
|
15
|
+
const SENTENCE = "Moonlight's theme color is green, not blue. ";
|
|
16
|
+
|
|
17
|
+
// A synthetic window far over the 12,000-char per-call budget.
|
|
18
|
+
const OVERSIZED_WINDOW: BufferTurn[] = Array.from({ length: 40 }, (_, index) => ({
|
|
19
|
+
role: index % 2 === 0 ? "user" : "assistant",
|
|
20
|
+
content: SENTENCE.repeat(250),
|
|
21
|
+
timestamp: `2026-11-20T12:${String(index).padStart(2, "0")}:00.000Z`,
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
class FakeBadRequestError extends Error {
|
|
25
|
+
readonly status: number;
|
|
26
|
+
constructor(status: number, message: string) {
|
|
27
|
+
super(`${status} ${message}`);
|
|
28
|
+
this.status = status;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function engineWithDirectFailure(
|
|
33
|
+
err: Error,
|
|
34
|
+
gatewayResult: StructuredParseResult<ExtractionResult> = {
|
|
35
|
+
result: null,
|
|
36
|
+
failureReason: "no_models",
|
|
37
|
+
errorClass: "no_models",
|
|
38
|
+
},
|
|
39
|
+
) {
|
|
40
|
+
const engine = new ExtractionEngine(parseConfig({ openaiApiKey: "fixture-key" }));
|
|
41
|
+
let direct = 0;
|
|
42
|
+
let gateway = 0;
|
|
43
|
+
const client = {
|
|
44
|
+
chat: {
|
|
45
|
+
completions: {
|
|
46
|
+
async create() {
|
|
47
|
+
direct += 1;
|
|
48
|
+
throw err;
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const fallbackLlm = {
|
|
54
|
+
async parseWithSchemaDetailed() {
|
|
55
|
+
gateway += 1;
|
|
56
|
+
return gatewayResult;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
assert.equal(Reflect.set(engine, "client", client), true);
|
|
60
|
+
assert.equal(Reflect.set(engine, "fallbackLlm", fallbackLlm), true);
|
|
61
|
+
return { engine, directCalls: () => direct, gatewayCalls: () => gateway };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
test("an oversized atomic direct request fails as direct_input_too_large and stays retryable", async () => {
|
|
65
|
+
const { engine, directCalls } = engineWithDirectFailure(
|
|
66
|
+
new FakeBadRequestError(400, "The total text input size exceeds 8 MB"),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const result = await engine.extract(OVERSIZED_WINDOW);
|
|
70
|
+
|
|
71
|
+
assert.equal(directCalls(), 1);
|
|
72
|
+
assert.equal(result.extractionFailure, "direct_input_too_large");
|
|
73
|
+
// provider_retryable keeps the window: the drain never counts it toward a drop
|
|
74
|
+
// and the retry layer never long-parks it as a parse failure.
|
|
75
|
+
assert.equal(result.extractionFailureClass, "provider_retryable");
|
|
76
|
+
assert.deepEqual(result.facts, []);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("an HTTP 413 from the direct client is a size rejection too", async () => {
|
|
80
|
+
const { engine } = engineWithDirectFailure(new FakeBadRequestError(413, "Request Entity Too Large"));
|
|
81
|
+
const result = await engine.extract(OVERSIZED_WINDOW);
|
|
82
|
+
assert.equal(result.extractionFailure, "direct_input_too_large");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("the gateway fallback still runs and wins after a direct size rejection", async () => {
|
|
86
|
+
const { engine, gatewayCalls } = engineWithDirectFailure(
|
|
87
|
+
new FakeBadRequestError(400, "This model's maximum context length is 128000 tokens"),
|
|
88
|
+
{
|
|
89
|
+
modelUsed: "fixture-gateway",
|
|
90
|
+
result: {
|
|
91
|
+
facts: [{ category: "fact", content: SENTENCE.trim(), confidence: 0.95, tags: [] }],
|
|
92
|
+
profileUpdates: [],
|
|
93
|
+
entities: [],
|
|
94
|
+
questions: [],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const result = await engine.extract(OVERSIZED_WINDOW);
|
|
100
|
+
|
|
101
|
+
assert.equal(gatewayCalls(), 1);
|
|
102
|
+
assert.equal(result.extractionFailure, undefined);
|
|
103
|
+
assert.equal(result.facts[0]?.content, SENTENCE.trim());
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("a direct 400 that is not about size keeps the gateway failure", async () => {
|
|
107
|
+
const { engine } = engineWithDirectFailure(new FakeBadRequestError(400, "invalid model id"));
|
|
108
|
+
const result = await engine.extract(OVERSIZED_WINDOW);
|
|
109
|
+
assert.equal(result.extractionFailure, "fallback_no_parsed_output");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("isRequestTooLargeError rejects 400s whose 'exceed' is not about input size", () => {
|
|
113
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "max_tokens exceeds maximum allowed")), false);
|
|
114
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "temperature exceeds 2.0")), false);
|
|
115
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "quota exceeded")), false);
|
|
116
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "spending limit exceeded")), false);
|
|
117
|
+
assert.equal(
|
|
118
|
+
isRequestTooLargeError(new FakeBadRequestError(400, "You exceeded your current quota, please check your plan")),
|
|
119
|
+
false,
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("isRequestTooLargeError matches size rejections only", () => {
|
|
124
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(413, "Payload Too Large")), true);
|
|
125
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "The total text input size exceeds 8 MB")), true);
|
|
126
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "maximum context length is 8192 tokens")), true);
|
|
127
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "prompt is too long")), true);
|
|
128
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "invalid model id")), false);
|
|
129
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(500, "upstream payload too large")), false);
|
|
130
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(429, "rate limit exceeded")), false);
|
|
131
|
+
assert.equal(isRequestTooLargeError(new Error("input too large")), false);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("isRequestTooLargeError needs an input subject for 'too large' and 'too long' (#3533)", () => {
|
|
135
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "temperature is too large")), false);
|
|
136
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "max_tokens is too large: 9000")), false);
|
|
137
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "top_k value is too large")), false);
|
|
138
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "stop sequence is too long")), false);
|
|
139
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "Request too large for model")), true);
|
|
140
|
+
assert.equal(isRequestTooLargeError(new FakeBadRequestError(400, "prompt is too long")), true);
|
|
141
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtractionFailureClass } from "./types.js";
|
|
1
|
+
import type { ExtractionFailureClass, ExtractionResult } from "./types.js";
|
|
2
2
|
import { isTransientHttpError } from "./connectors/live/transient-errors.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -32,6 +32,66 @@ export function classifyExtractionThrownError(err: unknown): ExtractionFailureCl
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
const CONTEXT_LIMIT_MESSAGE = /maximum context|context length|context window|request entity/i;
|
|
36
|
+
const SIZE_LIMIT_PHRASE = /too large|too long|exceed/i;
|
|
37
|
+
const INPUT_SUBJECT_TERM =
|
|
38
|
+
/\b(?:input|prompt|request|payload|body|messages?|content|context|size|length|tokens?)\b/i;
|
|
39
|
+
const REQUEST_TOO_LARGE_EXCLUDE =
|
|
40
|
+
/\b(?:max_tokens|max_completion_tokens|temperature|top_p|quota|rate limit|spending|billing)\b/i;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* True when a provider refused the request because the input is too big: HTTP
|
|
44
|
+
* 413, or HTTP 400 whose message names a size or context limit (OpenAI-style
|
|
45
|
+
* "maximum context length", "total text input size exceeds 8 MB"). "too large",
|
|
46
|
+
* "too long" and "exceed" count only beside an input subject and never beside
|
|
47
|
+
* an output, quota or sampling term (`max_tokens exceeds limit`,
|
|
48
|
+
* `temperature is too large`, `quota exceeded` are different failures).
|
|
49
|
+
* Resending the same atomic request can never succeed (#3531). Never throws.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/** An Error or SDK error object; the HTTP status is sniffed off it when present. */
|
|
53
|
+
export interface HttpThrowable {
|
|
54
|
+
readonly status?: number;
|
|
55
|
+
readonly message?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isRequestTooLargeError(err: HttpThrowable): boolean {
|
|
59
|
+
try {
|
|
60
|
+
const status = httpStatusFromError(err);
|
|
61
|
+
if (status === 413) return true;
|
|
62
|
+
if (status !== 400 || !(err instanceof Error)) return false;
|
|
63
|
+
const message = err.message;
|
|
64
|
+
if (CONTEXT_LIMIT_MESSAGE.test(message)) return true;
|
|
65
|
+
if (REQUEST_TOO_LARGE_EXCLUDE.test(message)) return false;
|
|
66
|
+
return SIZE_LIMIT_PHRASE.test(message) && INPUT_SUBJECT_TERM.test(message);
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Result when the provider refused the window as too large (#3531). Retryable
|
|
74
|
+
* on purpose: the retained turns are never parked or dropped, and
|
|
75
|
+
* `remnic buffer drain` can still extract them in budget-sized chunks.
|
|
76
|
+
*/
|
|
77
|
+
export function directInputTooLargeResult(): ExtractionResult {
|
|
78
|
+
return {
|
|
79
|
+
facts: [],
|
|
80
|
+
profileUpdates: [],
|
|
81
|
+
entities: [],
|
|
82
|
+
questions: [],
|
|
83
|
+
extractionFailure: "direct_input_too_large",
|
|
84
|
+
extractionFailureClass: "provider_retryable",
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function formatDirectInputTooLargeLog(chars: number): string {
|
|
89
|
+
return (
|
|
90
|
+
`extraction: direct client refused a ${chars}-char request as too large; an atomic flush is never ` +
|
|
91
|
+
"split, so any turns the gateway fallback does not extract stay buffered for `remnic buffer drain`"
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
35
95
|
/**
|
|
36
96
|
* Map the gateway fallback's discriminated parse-failure reason to a coarse
|
|
37
97
|
* extraction failure class. "no models configured" is an auth/config problem;
|
package/src/extraction.ts
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
import { applyGroundingWithConnector, headerConnector, renderExtractionConversation, resolveSourceConnector, type ExtractionGroundingContext } from "./source-agent-qualifier.js";
|
|
39
39
|
import { isMemoryCategory } from "./write-envelope.js";
|
|
40
40
|
export { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction-error-classification.js";
|
|
41
|
-
import { LocalLlmRejectedError, classifyExtractionThrownError, classifyFallbackParseFailure, classifyLocalLlmRejected, formatExtractionParseFailureLog, localRejectionStatus, type LocalFailureDiag } from "./extraction-error-classification.js";
|
|
41
|
+
import { LocalLlmRejectedError, classifyExtractionThrownError, classifyFallbackParseFailure, classifyLocalLlmRejected, formatExtractionParseFailureLog, directInputTooLargeResult, formatDirectInputTooLargeLog, isRequestTooLargeError, localRejectionStatus, type LocalFailureDiag } from "./extraction-error-classification.js";
|
|
42
42
|
import { buildUnusableReplyDiagnostic, formatUnusableReplyDiagnostic, looksLikeExtractionResultPayload } from "./extraction-reply-diagnostic.js";
|
|
43
43
|
import { AMBIENT_CAPTURE_PROMPT_SECTION_COMPACT, clampAmbientCaptureConfidence } from "./ambient-provenance.js";
|
|
44
44
|
import {
|
|
@@ -1179,6 +1179,8 @@ export class ExtractionEngine {
|
|
|
1179
1179
|
// fallback, so a gateway "no models" result doesn't re-classify a real
|
|
1180
1180
|
// primary failure as auth_config (codex review: preserve direct/local failures).
|
|
1181
1181
|
let primaryExtractorAttempted = false;
|
|
1182
|
+
// Direct client refused the request as too large (#3531): report that if the gateway fails too.
|
|
1183
|
+
let directInputTooLarge = false;
|
|
1182
1184
|
|
|
1183
1185
|
try {
|
|
1184
1186
|
// Try local LLM first if enabled
|
|
@@ -1275,6 +1277,8 @@ export class ExtractionEngine {
|
|
|
1275
1277
|
});
|
|
1276
1278
|
} catch { /* trace emit must not block fallback */ }
|
|
1277
1279
|
closedDirectTrace = true;
|
|
1280
|
+
directInputTooLarge = err instanceof Object && isRequestTooLargeError(err);
|
|
1281
|
+
if (directInputTooLarge) log.warn(formatDirectInputTooLargeLog(conversation.length));
|
|
1278
1282
|
log.info("extraction: direct client failed, falling back to gateway AI:", err);
|
|
1279
1283
|
} finally {
|
|
1280
1284
|
try { this.profiler.endSpan("direct-client", extractionTraceId); } catch { /* span may already be closed */ }
|
|
@@ -1383,6 +1387,7 @@ export class ExtractionEngine {
|
|
|
1383
1387
|
"provider_retryable"
|
|
1384
1388
|
: classifyFallbackParseFailure(detailed.failureReason)
|
|
1385
1389
|
: "parse_empty";
|
|
1390
|
+
if (directInputTooLarge) return directInputTooLargeResult();
|
|
1386
1391
|
return {
|
|
1387
1392
|
facts: [],
|
|
1388
1393
|
profileUpdates: [],
|
|
@@ -1398,6 +1403,7 @@ export class ExtractionEngine {
|
|
|
1398
1403
|
durationMs: Date.now() - fallbackStartTime, error: String(err),
|
|
1399
1404
|
});
|
|
1400
1405
|
log.error("extraction fallback failed", err);
|
|
1406
|
+
if (directInputTooLarge) return directInputTooLargeResult();
|
|
1401
1407
|
return {
|
|
1402
1408
|
facts: [],
|
|
1403
1409
|
profileUpdates: [],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/extraction-error-classification.ts"],"sourcesContent":["import type { ExtractionFailureClass } from \"./types.js\";\nimport { isTransientHttpError } from \"./connectors/live/transient-errors.js\";\n\n/**\n * Read a numeric HTTP status off a thrown error without re-implementing the\n * shared transient classifier. Uses `in`/typeof narrowing (no inline casts).\n */\nfunction httpStatusFromError(err: unknown): number | undefined {\n if (!err || typeof err !== \"object\") return undefined;\n if (\"status\" in err && typeof err.status === \"number\" && Number.isFinite(err.status)) return err.status;\n if (\"statusCode\" in err && typeof err.statusCode === \"number\" && Number.isFinite(err.statusCode)) {\n return err.statusCode;\n }\n return undefined;\n}\n\n/**\n * Map a thrown extraction error to a coarse failure class for the retry/breaker\n * layer. 401/403 → `auth_config` (misconfigured provider, open the breaker);\n * transient (429/5xx/network, per the shared `isTransientHttpError`) → back off;\n * anything else defaults to `provider_retryable` (fail-open toward retry, but\n * capped by the per-fingerprint attempt budget). Never throws.\n */\nexport function classifyExtractionThrownError(err: unknown): ExtractionFailureClass {\n try {\n const status = httpStatusFromError(err);\n if (status === 401 || status === 403) return \"auth_config\";\n if (isTransientHttpError(err)) return \"provider_retryable\";\n return \"provider_retryable\";\n } catch {\n return \"provider_retryable\";\n }\n}\n\n/**\n * Map the gateway fallback's discriminated parse-failure reason to a coarse\n * extraction failure class. \"no models configured\" is an auth/config problem;\n * an HTTP/transport failure backs off; an unparseable-but-present response is a\n * genuine empty-parse.\n */\nexport function classifyFallbackParseFailure(\n reason: \"no_models\" | \"empty\" | \"http_error\" | \"schema_rejection\" | \"timeout\",\n): ExtractionFailureClass {\n switch (reason) {\n case \"no_models\":\n return \"auth_config\";\n case \"http_error\":\n case \"timeout\":\n return \"provider_retryable\";\n case \"empty\":\n case \"schema_rejection\":\n return \"parse_empty\";\n }\n}\n\n/**\n * Operator-visible extraction parse-failure line. Keeps the historical\n * greppable prefix and appends the fields that used to live only at debug.\n */\nexport function formatExtractionParseFailureLog(input: {\n failureReason: string;\n attemptedModel?: string;\n httpStatus?: number;\n errorClass?: string;\n traceId: string;\n}): string {\n const modelUsed =\n typeof input.attemptedModel === \"string\" && input.attemptedModel.length > 0\n ? input.attemptedModel\n : \"unknown\";\n const errorClass =\n typeof input.errorClass === \"string\" && input.errorClass.length > 0\n ? input.errorClass\n : \"none\";\n const httpStatus =\n typeof input.httpStatus === \"number\" && Number.isFinite(input.httpStatus)\n ? String(input.httpStatus)\n : \"none\";\n return [\n \"extraction fallback returned no parsed output\",\n `failureReason=${input.failureReason}`,\n `modelUsed=${modelUsed}`,\n `errorClass=${errorClass}`,\n `httpStatus=${httpStatus}`,\n `traceId=${input.traceId}`,\n ].join(\" \");\n}\n\n/**\n * The local endpoint answered, and what it said rejects this input (unusable content, or a client error that is not\n * auth, timeout or rate limiting): the chunk's problem, not an outage. A `finish_reason=length` reply classifies as\n * `output_truncated` (#3521); every other rejection retries like an empty parse, and a trigger-drain\n * chunk that keeps drawing it is dropped after its recovery copy is saved.\n */\nexport class LocalLlmRejectedError extends Error {\n constructor(readonly httpStatus?: number, readonly finishReason?: string) {\n super(httpStatus === undefined ? \"local LLM answered with unusable content\" : `local LLM rejected the input (HTTP ${httpStatus})`);\n this.name = \"LocalLlmRejectedError\";\n }\n}\n\n/**\n * Map a local-endpoint rejection to its failure class: a reply cut off at the\n * output ceiling (`finish_reason=length`) is `output_truncated` — retries at\n * the same `maxOutputTokens` can never complete (#3521). Every other unusable\n * or refused reply stays `parse_empty`.\n */\nexport function classifyLocalLlmRejected(err: LocalLlmRejectedError): ExtractionFailureClass {\n return err.finishReason === \"length\" ? \"output_truncated\" : \"parse_empty\";\n}\n\n/** What the local client recorded about a failed call (`failureDiag`). */\nexport interface LocalFailureDiag {\n lastError?: unknown;\n /** The completion's `finish_reason` as the client received it (validated before it is logged). */\n finishReason?: string;\n}\n\n/** The HTTP status when the local endpoint answered and refuses this input (400, 413, 422); else undefined. A wrong model name or route (404, 405, 410), auth, timeout and rate limiting are the setup's problem, not the chunk's. */\nexport function localRejectionStatus(diag: LocalFailureDiag): number | undefined {\n const status = httpStatusFromError(diag.lastError);\n return status !== undefined && [400, 413, 422].includes(status) ? status : undefined;\n}\n"],"mappings":";;;;;AAOA,SAAS,oBAAoB,KAAkC;AAC7D,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,MAAI,YAAY,OAAO,OAAO,IAAI,WAAW,YAAY,OAAO,SAAS,IAAI,MAAM,EAAG,QAAO,IAAI;AACjG,MAAI,gBAAgB,OAAO,OAAO,IAAI,eAAe,YAAY,OAAO,SAAS,IAAI,UAAU,GAAG;AAChG,WAAO,IAAI;AAAA,EACb;AACA,SAAO;AACT;AASO,SAAS,8BAA8B,KAAsC;AAClF,MAAI;AACF,UAAM,SAAS,oBAAoB,GAAG;AACtC,QAAI,WAAW,OAAO,WAAW,IAAK,QAAO;AAC7C,QAAI,qBAAqB,GAAG,EAAG,QAAO;AACtC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAQO,SAAS,6BACd,QACwB;AACxB,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAMO,SAAS,gCAAgC,OAMrC;AACT,QAAM,YACJ,OAAO,MAAM,mBAAmB,YAAY,MAAM,eAAe,SAAS,IACtE,MAAM,iBACN;AACN,QAAM,aACJ,OAAO,MAAM,eAAe,YAAY,MAAM,WAAW,SAAS,IAC9D,MAAM,aACN;AACN,QAAM,aACJ,OAAO,MAAM,eAAe,YAAY,OAAO,SAAS,MAAM,UAAU,IACpE,OAAO,MAAM,UAAU,IACvB;AACN,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB,MAAM,aAAa;AAAA,IACpC,aAAa,SAAS;AAAA,IACtB,cAAc,UAAU;AAAA,IACxB,cAAc,UAAU;AAAA,IACxB,WAAW,MAAM,OAAO;AAAA,EAC1B,EAAE,KAAK,GAAG;AACZ;AAQO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,YAAqB,YAA8B,cAAuB;AACxE,UAAM,eAAe,SAAY,6CAA6C,sCAAsC,UAAU,GAAG;AAD9G;AAA8B;AAEjD,SAAK,OAAO;AAAA,EACd;AAAA,EAHqB;AAAA,EAA8B;AAIrD;AAQO,SAAS,yBAAyB,KAAoD;AAC3F,SAAO,IAAI,iBAAiB,WAAW,qBAAqB;AAC9D;AAUO,SAAS,qBAAqB,MAA4C;AAC/E,QAAM,SAAS,oBAAoB,KAAK,SAAS;AACjD,SAAO,WAAW,UAAa,CAAC,KAAK,KAAK,GAAG,EAAE,SAAS,MAAM,IAAI,SAAS;AAC7E;","names":[]}
|