@owlmeans/llm 0.1.18-rc.2 → 0.1.18-rc.21
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/README.md +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/llm/SKILL.md +239 -116
- package/agent-meta/skills/llm-prompt-caching/SKILL.md +37 -3
- package/build/execution/service.d.ts.map +1 -1
- package/build/execution/service.js +46 -11
- package/build/execution/service.js.map +1 -1
- package/build/execution/types.d.ts +72 -12
- package/build/execution/types.d.ts.map +1 -1
- package/build/execution/utils.d.ts.map +1 -1
- package/build/execution/utils.js +15 -9
- package/build/execution/utils.js.map +1 -1
- package/build/helpers/retry.d.ts +14 -0
- package/build/helpers/retry.d.ts.map +1 -1
- package/build/helpers/retry.js +14 -0
- package/build/helpers/retry.js.map +1 -1
- package/build/helpers/spectate.d.ts.map +1 -1
- package/build/helpers/spectate.js +12 -5
- package/build/helpers/spectate.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/model.d.ts +1 -1
- package/build/model.d.ts.map +1 -1
- package/build/model.js +60 -28
- package/build/model.js.map +1 -1
- package/build/plugins/anthropic.d.ts +40 -0
- package/build/plugins/anthropic.d.ts.map +1 -1
- package/build/plugins/anthropic.js +79 -6
- package/build/plugins/anthropic.js.map +1 -1
- package/build/plugins/openai.d.ts +12 -0
- package/build/plugins/openai.d.ts.map +1 -1
- package/build/plugins/openai.js +29 -3
- package/build/plugins/openai.js.map +1 -1
- package/build/plugins/types.d.ts +7 -0
- package/build/plugins/types.d.ts.map +1 -1
- package/build/prompt/service.d.ts.map +1 -1
- package/build/prompt/service.js +11 -0
- package/build/prompt/service.js.map +1 -1
- package/build/prompt/types.d.ts +20 -0
- package/build/prompt/types.d.ts.map +1 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +42 -7
- package/build/service.js.map +1 -1
- package/build/types.d.ts +71 -1
- package/build/types.d.ts.map +1 -1
- package/build/utils/config.d.ts +11 -0
- package/build/utils/config.d.ts.map +1 -1
- package/build/utils/config.js +21 -1
- package/build/utils/config.js.map +1 -1
- package/build/utils/null-report.d.ts.map +1 -1
- package/build/utils/null-report.js +9 -1
- package/build/utils/null-report.js.map +1 -1
- package/package.json +13 -13
- package/src/execution/service.ts +46 -11
- package/src/execution/types.ts +77 -13
- package/src/execution/utils.ts +16 -9
- package/src/helpers/retry.ts +16 -0
- package/src/helpers/spectate.ts +14 -5
- package/src/index.ts +4 -2
- package/src/model.ts +77 -27
- package/src/plugins/anthropic.ts +89 -6
- package/src/plugins/openai.ts +33 -3
- package/src/plugins/types.ts +8 -0
- package/src/prompt/service.ts +12 -0
- package/src/prompt/types.ts +20 -0
- package/src/service.ts +53 -7
- package/src/types.ts +71 -1
- package/src/utils/config.ts +23 -1
- package/src/utils/null-report.ts +9 -1
- package/tests/context.ts +3 -0
- package/tests/execution.spec.ts +148 -13
- package/tests/helpers.spec.ts +4 -1
- package/tests/plugins.spec.ts +211 -0
- package/tests/prompt.spec.ts +43 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/execution/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/execution/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEpF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAMnE,OAAO,EACL,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,aAA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,aAAa,CAChD,KAAK,EAAE,mBAAmB,CAAI,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAwB,CAC7E,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAGpC,GAAM,EACN,KAAK,GAAW,iBAAiB,EACjC,OAAO,GAA4B,EAAE,EACR,EAAE;IAC/B,MAAM,OAAO,GAAG,GAAkC,CAAA;IAElD,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAI,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;IAEhE,OAAO,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAsB,KAAK,CAAC,CAAA;IAEtE,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -69,6 +69,16 @@ export interface HelperExecutionInput {
|
|
|
69
69
|
prompt?: PromptPolicy;
|
|
70
70
|
/** Refines `purpose.dedication`. */
|
|
71
71
|
dedication?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Initial output-token budget for this helper's model (`ModelConfig.maxTokens`), for
|
|
74
|
+
* work whose ONE answer is genuinely large — a whole source file rather than a decision.
|
|
75
|
+
*
|
|
76
|
+
* The role's preset value sizes the common case; a helper that routinely needs more
|
|
77
|
+
* would otherwise spend its first attempt producing a truncated answer and only reach a
|
|
78
|
+
* workable budget through the retry escalator, which doubles from this number. Clamped
|
|
79
|
+
* to the provider's `maxOutput` and preserved across `temperatureFactory`.
|
|
80
|
+
*/
|
|
81
|
+
output?: number;
|
|
72
82
|
}
|
|
73
83
|
/** Collaborators re-attached to a state that was restored from storage. */
|
|
74
84
|
export interface RestoreCollaborators {
|
|
@@ -77,16 +87,40 @@ export interface RestoreCollaborators {
|
|
|
77
87
|
files?: FileProviderRef;
|
|
78
88
|
}
|
|
79
89
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
* What a performer wants to know before it acts. Runtime-only — never snapshotted, so it
|
|
91
|
+
* carries whatever the advisor and its callers agree on.
|
|
92
|
+
*/
|
|
93
|
+
export interface AdviceRequest {
|
|
94
|
+
/** Which advisor is being asked; an advisor that does not own this kind returns null. */
|
|
95
|
+
kind: string;
|
|
96
|
+
/** The work at hand, in the caller's own words — normally the assignment text. */
|
|
97
|
+
task: string;
|
|
98
|
+
/** Anything that narrows the answer (a subproject, a path prefix, an entity). */
|
|
99
|
+
hints?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Extension seam. A plugin ANSWERS a performer's question about its surroundings.
|
|
103
|
+
*
|
|
104
|
+
* It used to carry a checkpoint pair as well (`onCheckpoint`/`onRestore`), and that is gone: an
|
|
105
|
+
* execution is a bundle of collaborators and domain context, not a workflow position, and the only
|
|
106
|
+
* position it ever carried was three optional fields nothing ever read back. Recoverable work is a
|
|
107
|
+
* PIPELINE — `@owlmeans/agent`'s `makePipeline` — whose steps are named, whose state is scalars and
|
|
108
|
+
* keys, and whose run row is a single authority on where it stands. Two mechanisms answering "where
|
|
109
|
+
* is this run" is two half-truths, which is exactly what this deletion removes.
|
|
84
110
|
*/
|
|
85
111
|
export interface ExecutionPlugin {
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Identity for de-duplication. A plugin registered twice — two `append*` calls composing the
|
|
114
|
+
* same layer — would otherwise answer twice, and the first usable answer wins, so the duplicate
|
|
115
|
+
* is silent rather than loud.
|
|
116
|
+
*/
|
|
117
|
+
alias?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Answer a performer's question about the project it is working in. Return the text to
|
|
120
|
+
* hand the model, or `null` when this plugin does not own the request's `kind` — or
|
|
121
|
+
* cannot answer it. Advice is advisory: a `null` never blocks the work.
|
|
122
|
+
*/
|
|
123
|
+
advise?: (exec: Execution, request: AdviceRequest) => Promise<string | null>;
|
|
90
124
|
}
|
|
91
125
|
/**
|
|
92
126
|
* The set of domain types an {@link ExecutionService} works with. A consumer declares
|
|
@@ -117,13 +151,39 @@ export interface ExecutionService<S extends ExecutionShape = ExecutionShape> ext
|
|
|
117
151
|
withPurpose: <E extends S['exec']>(exec: E, patch: Partial<S['purpose']>) => E;
|
|
118
152
|
escalate: <E extends S['exec']>(exec: E, patch: Partial<ModelPolicy>) => E;
|
|
119
153
|
model: (exec: S['exec'], role?: ModelRole, override?: ModelConfigOverride) => BaseChatModel;
|
|
120
|
-
|
|
121
|
-
|
|
154
|
+
/**
|
|
155
|
+
* The cheap model for work that is not the work — a relevance pick, a classification, a
|
|
156
|
+
* one-line judgement a plugin needs before the real call can be shaped.
|
|
157
|
+
*
|
|
158
|
+
* Resolves `policy.utilityRole ?? UTILITY_ROLE` at {@link ExecutionEffort.Economy} through
|
|
159
|
+
* the SAME ladder as {@link model}, so `roleOverrides` and `modelOverrides` govern it
|
|
160
|
+
* exactly as they govern every other role. The effort floor is local: the execution it
|
|
161
|
+
* was asked on keeps its own tier.
|
|
162
|
+
*/
|
|
163
|
+
utility: (exec: S['exec'], override?: ModelConfigOverride) => BaseChatModel;
|
|
164
|
+
/**
|
|
165
|
+
* A factory that re-resolves the same role at another temperature. `baseOverride` is
|
|
166
|
+
* layered UNDER the temperature patch, so a caller-chosen budget (see
|
|
167
|
+
* `HelperExecutionInput.output`) survives the refinement.
|
|
168
|
+
*/
|
|
169
|
+
temperatureFactory: (exec: S['exec'], role?: ModelRole, baseOverride?: ModelConfigOverride) => TemperatureFactory;
|
|
170
|
+
/** Register an execution plugin (advice). Seated by `alias` when it carries one. */
|
|
122
171
|
use: (plugin: ExecutionPlugin) => void;
|
|
123
|
-
/**
|
|
124
|
-
|
|
172
|
+
/**
|
|
173
|
+
* The JSON-safe half of an execution — everything that is not a collaborator.
|
|
174
|
+
*
|
|
175
|
+
* A transport-level convenience, not a workflow position: nothing here says where a run has got
|
|
176
|
+
* to, and nothing should. See {@link ExecutionPlugin}.
|
|
177
|
+
*/
|
|
125
178
|
snapshot: (exec: S['exec']) => ExecutionState;
|
|
126
179
|
restore: (state: ExecutionState, collaborators?: S['collaborators']) => S['exec'];
|
|
180
|
+
/**
|
|
181
|
+
* Ask the registered plugins about the project this execution runs in. Plugins are
|
|
182
|
+
* consulted in registration order and the FIRST usable answer wins, so one advisor owns
|
|
183
|
+
* each `kind` rather than several concatenating half-answers. Never throws: a plugin
|
|
184
|
+
* that fails is skipped, and `null` means nobody answered.
|
|
185
|
+
*/
|
|
186
|
+
advise: (exec: S['exec'], request: AdviceRequest) => Promise<string | null>;
|
|
127
187
|
}
|
|
128
188
|
export interface ExecutionServiceOptions {
|
|
129
189
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/execution/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EACV,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAC5E,mBAAmB,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAC9E,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C,wFAAwF;IACxF,MAAM,EAAE,MAAM,UAAU,CAAA;IACxB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,aAAa,CAAA;IAC7B,yFAAyF;IACzF,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;A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CAAC,CAAC,SAAS,cAAc,GAAG,cAAc;IAC7E,UAAU,EAAE,MAAM,gBAAgB,CAAC,CAAC,CAAC,CAAA;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/execution/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EACtE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EACzD,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1D,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,KAAK,CAAC,KAAG,QAAQ,CAAC,CAAC,CAAqB,CAAA;AAE/E,wFAAwF;AACxF,eAAO,MAAM,WAAW,SAAU,WAAW,SAAS,OAAO,CAAC,WAAW,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/execution/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EACtE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EACzD,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1D,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,KAAK,CAAC,KAAG,QAAQ,CAAC,CAAC,CAAqB,CAAA;AAE/E,wFAAwF;AACxF,eAAO,MAAM,WAAW,SAAU,WAAW,SAAS,OAAO,CAAC,WAAW,CAAC,KAAG,WAe5E,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,SAChB,YAAY,GAAG,SAAS,SACvB,YAAY,GAAG,SAAS,KAC9B,YAAY,GAAG,SAYjB,CAAA;AAED,0CAA0C;AAC1C,eAAO,MAAM,WAAW,WAAY,WAAW,QAAQ,SAAS,KAAG,SACF,CAAA;AAEjE,eAAO,MAAM,WAAW,WAAY,eAAe,KAAG,gBAAwC,CAAA;AAE9F,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,aAAc,mBAAmB,KAAG,gBACH,CAAA;AAEhE;;;GAGG;AACH,eAAO,MAAM,aAAa,eACZ,gBAAgB,kBACZ,mBAAmB,GAAG,SAAS,gBACjC,mBAAmB,GAAG,SAAS,KAC5C,gBAIF,CAAA;AAID;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAU,SAAS,oBAAoB,MAAM,EAAE,KAAG,cAQ9E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAU,aAAa,oBAAoB,MAAM,EAAE,KAAG,kBAWlF,CAAA"}
|
package/build/execution/utils.js
CHANGED
|
@@ -2,15 +2,21 @@ import { ExecutionLevel } from '@owlmeans/llm-common';
|
|
|
2
2
|
import { EFFORT_TABLE } from '../consts.js';
|
|
3
3
|
export const freeze = (o) => Object.freeze(o);
|
|
4
4
|
/** Overlay a partial policy onto a base one. Override maps are merged, not replaced. */
|
|
5
|
-
export const mergePolicy = (base, patch) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:
|
|
13
|
-
}
|
|
5
|
+
export const mergePolicy = (base, patch) => {
|
|
6
|
+
const utilityRole = patch.utilityRole ?? base.utilityRole;
|
|
7
|
+
return {
|
|
8
|
+
effort: patch.effort ?? base.effort,
|
|
9
|
+
roleOverrides: patch.roleOverrides != null || base.roleOverrides != null
|
|
10
|
+
? { ...base.roleOverrides, ...patch.roleOverrides }
|
|
11
|
+
: undefined,
|
|
12
|
+
modelOverrides: patch.modelOverrides != null || base.modelOverrides != null
|
|
13
|
+
? { ...base.modelOverrides, ...patch.modelOverrides }
|
|
14
|
+
: undefined,
|
|
15
|
+
// Added only when it exists, unlike the maps above: a project that never names a
|
|
16
|
+
// cheap tier must not gain a `utilityRole` key it would then carry into every snapshot.
|
|
17
|
+
...(utilityRole != null ? { utilityRole } : {}),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
14
20
|
/**
|
|
15
21
|
* Overlay a prompt policy onto the one inherited from the parent level.
|
|
16
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAKrD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAmB,CAAI,EAAe,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAE/E,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,KAA2B,EAAe,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAKrD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAmB,CAAI,EAAe,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAE/E,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,KAA2B,EAAe,EAAE;IACzF,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAA;IAEzD,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;QACnC,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI;YACtE,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KAAK,CAAA;QACpB,CAAC;IACH,CAAC;IACD,OAAO,KAAkC,CAAA;AAC3C,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAAE,gBAA0B,EAAsB,EAAE;IACtG,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAuB,CAAA;IAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAK,EAAyB,CAAA;IACtD,OAAO;QACL,GAAG,IAAI;QACP,KAAK,EAAE,cAAc,CAAC,IAAI;QAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAA;AACH,CAAC,CAAA"}
|
package/build/helpers/retry.d.ts
CHANGED
|
@@ -8,6 +8,20 @@ import type { FatalErrorResolver, RetryOptions } from '../types.js';
|
|
|
8
8
|
* consulted, plus the per-call {@link RetryOptions.fatal}.
|
|
9
9
|
*/
|
|
10
10
|
export declare const registerFatalError: (resolver: FatalErrorResolver) => void;
|
|
11
|
+
/**
|
|
12
|
+
* The one answer to "can any retry fix this?", exported so callers above the retry loop can ask it.
|
|
13
|
+
*
|
|
14
|
+
* A retry loop is not the only place that decides to carry on: a fix ladder rescues a failed
|
|
15
|
+
* repair and climbs to a stronger model, an agent runner catches a round that threw and reports
|
|
16
|
+
* "gave up". Both of those are right for a model that answered badly and wrong for a budget that
|
|
17
|
+
* ran out — and a blanket `catch` cannot tell them apart, so an exhausted balance became more
|
|
18
|
+
* expensive calls rather than a halt. Rather than each caller re-deriving the rule (and drifting
|
|
19
|
+
* from it), they ask the same resolvers, in the same order, that `withRetry` uses.
|
|
20
|
+
*
|
|
21
|
+
* Returns the error to abort WITH — a resolver may unwrap a carrier and hand back the real
|
|
22
|
+
* cause — or `null` when nothing considers it terminal.
|
|
23
|
+
*/
|
|
24
|
+
export declare const isFatalError: (e: unknown, fatal?: FatalErrorResolver) => Error | null;
|
|
11
25
|
/**
|
|
12
26
|
* Run `fn` up to `retries` times, passing the 0-based attempt number so the callee can
|
|
13
27
|
* escalate (a bigger output budget, a stronger model). Every non-fatal error is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/helpers/retry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAInE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,aAAc,kBAAkB,KAAG,IAEjE,CAAA;
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/helpers/retry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAInE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,aAAc,kBAAkB,KAAG,IAEjE,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,MAAO,OAAO,UAAU,kBAAkB,KAAG,KAAK,GAAG,IACtD,CAAA;AAgBxB;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAU,CAAC,oCACW,YAAY,MAClD,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAClC,OAAO,CAAC,CAAC,CAiBX,CAAA"}
|
package/build/helpers/retry.js
CHANGED
|
@@ -12,6 +12,20 @@ const resolvers = [];
|
|
|
12
12
|
export const registerFatalError = (resolver) => {
|
|
13
13
|
resolvers.push(resolver);
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* The one answer to "can any retry fix this?", exported so callers above the retry loop can ask it.
|
|
17
|
+
*
|
|
18
|
+
* A retry loop is not the only place that decides to carry on: a fix ladder rescues a failed
|
|
19
|
+
* repair and climbs to a stronger model, an agent runner catches a round that threw and reports
|
|
20
|
+
* "gave up". Both of those are right for a model that answered badly and wrong for a budget that
|
|
21
|
+
* ran out — and a blanket `catch` cannot tell them apart, so an exhausted balance became more
|
|
22
|
+
* expensive calls rather than a halt. Rather than each caller re-deriving the rule (and drifting
|
|
23
|
+
* from it), they ask the same resolvers, in the same order, that `withRetry` uses.
|
|
24
|
+
*
|
|
25
|
+
* Returns the error to abort WITH — a resolver may unwrap a carrier and hand back the real
|
|
26
|
+
* cause — or `null` when nothing considers it terminal.
|
|
27
|
+
*/
|
|
28
|
+
export const isFatalError = (e, fatal) => resolveFatal(e, fatal);
|
|
15
29
|
const resolveFatal = (e, fatal) => {
|
|
16
30
|
const own = fatal?.(e);
|
|
17
31
|
if (own != null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/helpers/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAG7C,MAAM,SAAS,GAAyB,EAAE,CAAA;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAA4B,EAAQ,EAAE;IACvE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,CAAU,EAAE,KAA0B,EAAgB,EAAE;IAC5E,MAAM,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACtB,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,GAAG,CAAA;IAC3B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QACzB,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,KAAK,CAAA;IACjC,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,MA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C,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;QACpB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;YACpC,IAAI,KAAK,IAAI,IAAI;gBAAE,MAAM,KAAK,CAAA;YAC9B,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAA;YAClB,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAA;YACpB,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAA;gBAC1C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,QAAQ,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectate.d.ts","sourceRoot":"","sources":["../../src/helpers/spectate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAA;AAIjE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"spectate.d.ts","sourceRoot":"","sources":["../../src/helpers/spectate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAA;AAIjE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAwC/D;;;GAGG;AACH,eAAO,MAAM,QAAQ,cAAe,YAAY,YAAY,MAAM,aAEvD,cAAc,EAAE,WACd,SAAS,UACV,MAAM,WACL,MAAM,cACH,MAAM,iEA+BnB,CAAA"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { BaseMessage } from '@langchain/core/messages';
|
|
2
2
|
import { SpectatorContentType } from '@owlmeans/llm-common';
|
|
3
3
|
import { hasCacheActivity, readCacheUsage } from './cache.js';
|
|
4
|
+
/**
|
|
5
|
+
* The trace's `content` column is a string; LangChain content is a string-or-blocks union, and
|
|
6
|
+
* tool calls are arrays. Anything non-string must be stored as JSON — a plain string coercion
|
|
7
|
+
* downstream turns it into `[object Object]` and destroys the readable half of the trace
|
|
8
|
+
* (`raw` keeps the payload, but `content` is what trace readers query).
|
|
9
|
+
*/
|
|
10
|
+
const asText = (content) => typeof content === 'string' ? content : JSON.stringify(content) ?? '';
|
|
4
11
|
/** Normalize one prompt message into the spectator's storage shape. */
|
|
5
12
|
const describeInput = (msg, callType) => {
|
|
6
13
|
const entry = {
|
|
@@ -11,7 +18,7 @@ const describeInput = (msg, callType) => {
|
|
|
11
18
|
};
|
|
12
19
|
if (msg instanceof BaseMessage) {
|
|
13
20
|
entry.type = msg.type;
|
|
14
|
-
entry.content = msg.content;
|
|
21
|
+
entry.content = asText(msg.content);
|
|
15
22
|
entry.name = msg.name;
|
|
16
23
|
entry.contentType = typeof msg.content === 'string' ? SpectatorContentType.Text : SpectatorContentType.Json;
|
|
17
24
|
entry.usage = 'usage_metadata' in msg ? msg.usage_metadata : undefined;
|
|
@@ -19,11 +26,11 @@ const describeInput = (msg, callType) => {
|
|
|
19
26
|
}
|
|
20
27
|
else if (typeof msg === 'object' && 'content' in msg) {
|
|
21
28
|
entry.type = msg.role ?? 'unknown';
|
|
22
|
-
entry.content = msg.content ?? msg;
|
|
29
|
+
entry.content = asText(msg.content ?? msg);
|
|
23
30
|
entry.raw = JSON.stringify(msg);
|
|
24
31
|
}
|
|
25
32
|
else {
|
|
26
|
-
entry.content = msg;
|
|
33
|
+
entry.content = asText(msg);
|
|
27
34
|
entry.raw = JSON.stringify(msg);
|
|
28
35
|
}
|
|
29
36
|
return entry;
|
|
@@ -44,11 +51,11 @@ export const spectate = (spectator, callType) => async (input, message, action,
|
|
|
44
51
|
raw: JSON.stringify({ message, content: message.content, meta: message.response_metadata }),
|
|
45
52
|
};
|
|
46
53
|
if (message.tool_calls != null && message.tool_calls.length > 0) {
|
|
47
|
-
completion.content = message.tool_calls;
|
|
54
|
+
completion.content = asText(message.tool_calls);
|
|
48
55
|
completion.contentType = SpectatorContentType.ToolCall;
|
|
49
56
|
}
|
|
50
57
|
else {
|
|
51
|
-
completion.content = message.content;
|
|
58
|
+
completion.content = asText(message.content);
|
|
52
59
|
}
|
|
53
60
|
// Silent unless the provider reported cache activity, so it costs nothing when
|
|
54
61
|
// caching is off — and is the one signal that tells a stable prefix from a broken one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectate.js","sourceRoot":"","sources":["../../src/helpers/spectate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAG3D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE7D,uEAAuE;AACvE,MAAM,aAAa,GAAG,CAAC,GAAmB,EAAE,QAAgB,EAAyB,EAAE;IACrF,MAAM,KAAK,GAA0B;QACnC,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,oBAAoB,CAAC,IAAI;KACvC,CAAA;IAED,IAAI,GAAG,YAAY,WAAW,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;QACrB,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"spectate.js","sourceRoot":"","sources":["../../src/helpers/spectate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAG3D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE7D;;;;;GAKG;AACH,MAAM,M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,UAAU,CAAC,CAAA;QAC/C,UAAU,CAAC,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAA;IACxD,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC;IAED,+EAA+E;IAC/E,uFAAuF;IACvF,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;IACrC,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CACT,iBAAiB,MAAM,WAAW,KAAK,CAAC,IAAI,aAAa,KAAK,CAAC,QAAQ,cAAc,KAAK,CAAC,KAAK,EAAE,CACnG,CAAA;IACH,CAAC;IAED,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;AAC3F,CAAC,CAAA"}
|
package/build/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from './execution/index.js';
|
|
|
8
8
|
export * from './prompt/index.js';
|
|
9
9
|
export type * from './plugins/types.js';
|
|
10
10
|
export { plugins, registerLlmPlugin, pluginOf, pluginFor, resolvePlugin } from './plugins/index.js';
|
|
11
|
-
export { anthropicPlugin, ANTHROPIC_FAMILY } from './plugins/anthropic.js';
|
|
11
|
+
export { anthropicPlugin, ANTHROPIC_FAMILY, NO_SAMPLING_PREFIXES, rejectsSampling } from './plugins/anthropic.js';
|
|
12
12
|
export { compatiblePlugin } from './plugins/compatible.js';
|
|
13
|
-
export { openAiPlugin, openAiFamily, OPENAI_FAMILY } from './plugins/openai.js';
|
|
13
|
+
export { openAiPlugin, openAiFamily, OPENAI_FAMILY, RESPONSES_API_PREFIXES, usesResponsesApi, } from './plugins/openai.js';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,mBAAmB,oBAAoB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,mBAAmB,oBAAoB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EACL,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,GACpF,MAAM,qBAAqB,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export * from './helpers/index.js';
|
|
|
6
6
|
export * from './execution/index.js';
|
|
7
7
|
export * from './prompt/index.js';
|
|
8
8
|
export { plugins, registerLlmPlugin, pluginOf, pluginFor, resolvePlugin } from './plugins/index.js';
|
|
9
|
-
export { anthropicPlugin, ANTHROPIC_FAMILY } from './plugins/anthropic.js';
|
|
9
|
+
export { anthropicPlugin, ANTHROPIC_FAMILY, NO_SAMPLING_PREFIXES, rejectsSampling } from './plugins/anthropic.js';
|
|
10
10
|
export { compatiblePlugin } from './plugins/compatible.js';
|
|
11
|
-
export { openAiPlugin, openAiFamily, OPENAI_FAMILY } from './plugins/openai.js';
|
|
11
|
+
export { openAiPlugin, openAiFamily, OPENAI_FAMILY, RESPONSES_API_PREFIXES, usesResponsesApi, } from './plugins/openai.js';
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAE3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAE3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EACL,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,GACpF,MAAM,qBAAqB,CAAA"}
|
package/build/model.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ import type { LlmModel, LlmModelOptions, LlmSpectator } from './types.js';
|
|
|
8
8
|
* provider-independent parts: streaming under an idle deadline, retry/fallback
|
|
9
9
|
* escalation, schema validation and coercion, spectator logging, and null diagnostics.
|
|
10
10
|
*/
|
|
11
|
-
export declare const makeLlmModel: ({ model, outputErrors, captureNull, retries, purpose, prompt, prompts, files, }: LlmModelOptions, spectator: LlmSpectator) => LlmModel;
|
|
11
|
+
export declare const makeLlmModel: ({ model, outputErrors, captureNull, retries, purpose, prompt, prompts, files, utility, }: LlmModelOptions, spectator: LlmSpectator) => LlmModel;
|
|
12
12
|
//# sourceMappingURL=model.d.ts.map
|
package/build/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACuB,QAAQ,EAAE,eAAe,EAC1D,YAAY,EACb,MAAM,YAAY,CAAA;AA8CnB;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACuB,QAAQ,EAAE,eAAe,EAC1D,YAAY,EACb,MAAM,YAAY,CAAA;AA8CnB;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,6FAUtB,eAAe,aAAa,YAAY,KAAG,QAyb7C,CAAA"}
|
package/build/model.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Ajv } from 'ajv';
|
|
2
2
|
import { AIMessage, BaseMessage } from '@langchain/core/messages';
|
|
3
3
|
import { StructuredMode } from '@owlmeans/llm-common';
|
|
4
|
-
import {
|
|
4
|
+
import { DEFAULT_MODEL_RETRIES, FALLBACK_AFTER_ATTEMPTS, MAX_CACHE_BREAKPOINTS, } from './consts.js';
|
|
5
5
|
import { LlmModelError } from './errors.js';
|
|
6
6
|
import { pluginFor, pluginOf } from './plugins/index.js';
|
|
7
7
|
import { coerceToSchema, parseJsonContent } from './helpers/json.js';
|
|
8
8
|
import { normalizeInput } from './helpers/messages.js';
|
|
9
9
|
import { withRetry } from './helpers/retry.js';
|
|
10
10
|
import { spectate } from './helpers/spectate.js';
|
|
11
|
-
import { idleTimeout, readConfig } from './utils/config.js';
|
|
11
|
+
import { idleTimeout, readConfig, resolveOutputCap } from './utils/config.js';
|
|
12
12
|
import { reportNull } from './utils/null-report.js';
|
|
13
13
|
import { applyNoThink, dropBlankContent, ensureJsonMention, stripCacheMarkers } from './utils/prompt.js';
|
|
14
14
|
import { resolveSchemaValidator, toToolName, unwrapNamed } from './utils/schema.js';
|
|
@@ -59,13 +59,22 @@ const takeLeadingSystem = (msgs) => {
|
|
|
59
59
|
* provider-independent parts: streaming under an idle deadline, retry/fallback
|
|
60
60
|
* escalation, schema validation and coercion, spectator logging, and null diagnostics.
|
|
61
61
|
*/
|
|
62
|
-
export const makeLlmModel = ({ model, outputErrors = false, captureNull = false, retries = DEFAULT_MODEL_RETRIES, purpose, prompt, prompts, files, }, spectator) => {
|
|
62
|
+
export const makeLlmModel = ({ model, outputErrors = false, captureNull = false, retries = DEFAULT_MODEL_RETRIES, purpose, prompt, prompts, files, utility, }, spectator) => {
|
|
63
63
|
const ajv = new Ajv({ strict: false });
|
|
64
64
|
// The original config and its plugin are static per model instance: a REFINED instance
|
|
65
65
|
// is rebuilt from `lc_kwargs` and does not reliably carry the metadata back.
|
|
66
66
|
const config = readConfig(model);
|
|
67
67
|
const plugin = pluginOf(config.provider) ?? pluginFor(model);
|
|
68
68
|
const timeout = idleTimeout(config);
|
|
69
|
+
/**
|
|
70
|
+
* Where on the escalation ladder this call starts.
|
|
71
|
+
*
|
|
72
|
+
* The ladder has exactly `retries` rungs, so a seed past the last one buys nothing and
|
|
73
|
+
* would only inflate the attempt number handed to `refine`. Clamped, `refineModel` sees
|
|
74
|
+
* at most `2 * (retries - 1)` — the escalator's own doubling stays bounded by the
|
|
75
|
+
* output cap either way.
|
|
76
|
+
*/
|
|
77
|
+
const ladderSeed = (escalation) => Math.max(0, Math.min(Math.floor(escalation ?? 0), retries - 1));
|
|
69
78
|
/**
|
|
70
79
|
* Normalize, compose the system prompt, then apply every in-place prompt adaptation, in
|
|
71
80
|
* dependency order.
|
|
@@ -90,7 +99,7 @@ export const makeLlmModel = ({ model, outputErrors = false, captureNull = false,
|
|
|
90
99
|
...prompt,
|
|
91
100
|
context: [...(prompt?.context ?? []), ...carried],
|
|
92
101
|
callSkills: callSkills ?? prompt?.callSkills,
|
|
93
|
-
}, msgs, { model, provider: plugin, purpose, action, cacheMax, files });
|
|
102
|
+
}, msgs, { model, provider: plugin, purpose, action, cacheMax, files, utility });
|
|
94
103
|
if (composed.system != null) {
|
|
95
104
|
msgs.unshift(composed.system);
|
|
96
105
|
reserved = composed.breakpoints;
|
|
@@ -104,7 +113,9 @@ export const makeLlmModel = ({ model, outputErrors = false, captureNull = false,
|
|
|
104
113
|
}
|
|
105
114
|
if (json)
|
|
106
115
|
ensureJsonMention(msgs);
|
|
107
|
-
|
|
116
|
+
// The soft switch is for models with no request-level control; a plugin that sends the
|
|
117
|
+
// real parameter must not also get the directive as prompt text.
|
|
118
|
+
applyNoThink(msgs, config.disableThinking === true && plugin?.suppressesThinking?.(config) !== true);
|
|
108
119
|
// Cache markers replace string content with content blocks, so they must go last.
|
|
109
120
|
const ttl = prompt?.cacheTtl;
|
|
110
121
|
const marked = plugin?.patchCache?.(msgs, {
|
|
@@ -158,9 +169,9 @@ export const makeLlmModel = ({ model, outputErrors = false, captureNull = false,
|
|
|
158
169
|
const basePlugin = pluginOf(baseConfig.provider) ?? pluginFor(base);
|
|
159
170
|
if (basePlugin == null)
|
|
160
171
|
return base;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
// Read from the ACTIVE base — after the fallback swap that is the fallback's own
|
|
173
|
+
// config, so the escalator sizes the model it is actually talking to.
|
|
174
|
+
const maxOutputCap = resolveOutputCap(baseConfig);
|
|
164
175
|
const refined = basePlugin.refine({ base, attempt, temperature, maxOutputCap });
|
|
165
176
|
if (attempt > 0) {
|
|
166
177
|
const maxTokens = refined.maxTokens;
|
|
@@ -220,10 +231,11 @@ export const makeLlmModel = ({ model, outputErrors = false, captureNull = false,
|
|
|
220
231
|
return { piece, result, mode };
|
|
221
232
|
};
|
|
222
233
|
const helper = {
|
|
223
|
-
ask: async (input, { ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills }) => {
|
|
234
|
+
ask: async (input, { ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills, escalation, fatal, }) => {
|
|
224
235
|
const msgs = await prepare(input, action, useCache, cacheMax, false, skills);
|
|
225
|
-
|
|
226
|
-
|
|
236
|
+
const seed = ladderSeed(escalation);
|
|
237
|
+
return withRetry({ retries, outputErrors, fatal }, async (i) => {
|
|
238
|
+
const refined = refineModel(seed + i);
|
|
227
239
|
console.log('Use model to ask: ', refined.getName(), refined.lc_kwargs.model);
|
|
228
240
|
const startedAt = Date.now();
|
|
229
241
|
let result = null;
|
|
@@ -240,28 +252,46 @@ export const makeLlmModel = ({ model, outputErrors = false, captureNull = false,
|
|
|
240
252
|
? result.content
|
|
241
253
|
.filter((c) => typeof c === 'object' && c !== null && 'type' in c && c.type === 'text')
|
|
242
254
|
.map(c => c.text)
|
|
243
|
-
.join('')
|
|
244
|
-
:
|
|
255
|
+
.join('')
|
|
256
|
+
: '';
|
|
257
|
+
// A completion can carry text in blocks this strict filter does not name — the tolerant
|
|
258
|
+
// extractor reads any block with a string `text`. Only consulted once the strict pass
|
|
259
|
+
// found nothing, so the usual path keeps its exact spacing.
|
|
260
|
+
if (output.trim() === '') {
|
|
261
|
+
output = textOf(result.content);
|
|
262
|
+
}
|
|
245
263
|
const entry = await spectate(spectator, 'ask')(msgs, message, action, i, startedAt);
|
|
246
264
|
if (ref != null)
|
|
247
265
|
ref.spectatorEntry = entry;
|
|
266
|
+
// An empty completion is a NULL RESULT, and it is diagnosed here rather than blamed on
|
|
267
|
+
// the caller. Both shipped filters return null only for empty input, so letting one run
|
|
268
|
+
// first reported every empty answer as `filter-rejected` — naming the innocent party and,
|
|
269
|
+
// worse, skipping `reportNull`, whose stop reason and output-token count are the only
|
|
270
|
+
// things that say WHY nothing came back (a model that spent its whole budget thinking).
|
|
271
|
+
if (output.trim() === '') {
|
|
272
|
+
throw await nullResult('ask', {
|
|
273
|
+
action, attempt: i, startedAt, refined, msgs, raw: result, useCache,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
248
276
|
if (filter != null) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
277
|
+
const produced = output;
|
|
278
|
+
const filtered = await filter(produced, message);
|
|
279
|
+
if (filtered == null) {
|
|
280
|
+
// The OUTPUT, not the message envelope: `JSON.stringify(new AIMessage(...))` is 80
|
|
281
|
+
// constant characters of LangChain serialization stub and says nothing at all.
|
|
282
|
+
throw new LlmModelError(`filter-rejected:${produced.substring(0, 200)}`);
|
|
252
283
|
}
|
|
253
|
-
|
|
254
|
-
else if (output == null || output.trim() === '') {
|
|
255
|
-
throw new LlmModelError(`empty-content:${JSON.stringify(message).substring(0, 50)}...`);
|
|
284
|
+
output = filtered;
|
|
256
285
|
}
|
|
257
286
|
notifyRef(ref, message);
|
|
258
287
|
return output;
|
|
259
288
|
});
|
|
260
289
|
},
|
|
261
|
-
talk: async (input, { ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills }) => {
|
|
290
|
+
talk: async (input, { ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills, escalation, fatal, }) => {
|
|
262
291
|
const msgs = await prepare(input, action, useCache, cacheMax, false, skills);
|
|
263
|
-
|
|
264
|
-
|
|
292
|
+
const seed = ladderSeed(escalation);
|
|
293
|
+
return withRetry({ retries, outputErrors, fatal }, async (i) => {
|
|
294
|
+
const refined = refineModel(seed + i);
|
|
265
295
|
console.log('Use model to talk: ', refined.getName(), refined.lc_kwargs.model);
|
|
266
296
|
const startedAt = Date.now();
|
|
267
297
|
let result = null;
|
|
@@ -285,12 +315,13 @@ export const makeLlmModel = ({ model, outputErrors = false, captureNull = false,
|
|
|
285
315
|
return message;
|
|
286
316
|
});
|
|
287
317
|
},
|
|
288
|
-
invoke: async (input, schema, { temperature, ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills }) => {
|
|
318
|
+
invoke: async (input, schema, { temperature, ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills, escalation, fatal, }) => {
|
|
289
319
|
const msgs = await prepare(input, action, useCache, cacheMax, true, skills);
|
|
290
320
|
const { name, innerSchema, validate } = resolveSchemaValidator(ajv, schema);
|
|
291
321
|
const toolName = toToolName(innerSchema.title ?? name);
|
|
292
|
-
|
|
293
|
-
|
|
322
|
+
const seed = ladderSeed(escalation);
|
|
323
|
+
return withRetry({ retries, outputErrors, fatal }, async (i) => {
|
|
324
|
+
const refined = refineModel(seed + i, temperature);
|
|
294
325
|
console.log('Use model invoke: ', refined.getName(), refined.lc_kwargs.model);
|
|
295
326
|
const startedAt = Date.now();
|
|
296
327
|
const { piece, result: collected } = await streamStructured(refined, msgs, innerSchema, toolName, action);
|
|
@@ -323,12 +354,13 @@ export const makeLlmModel = ({ model, outputErrors = false, captureNull = false,
|
|
|
323
354
|
return result;
|
|
324
355
|
});
|
|
325
356
|
},
|
|
326
|
-
request: async (input, schema, { ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills }) => {
|
|
357
|
+
request: async (input, schema, { ref, filter, action, useCache = false, cacheMax = MAX_CACHE_BREAKPOINTS, skills, escalation, fatal, }) => {
|
|
327
358
|
const msgs = await prepare(input, action, useCache, cacheMax, true, skills);
|
|
328
359
|
const { name, innerSchema, validate } = resolveSchemaValidator(ajv, schema);
|
|
329
360
|
const toolName = toToolName(innerSchema.title ?? name);
|
|
330
|
-
|
|
331
|
-
|
|
361
|
+
const seed = ladderSeed(escalation);
|
|
362
|
+
return withRetry({ retries, outputErrors, fatal }, async (i) => {
|
|
363
|
+
const refined = refineModel(seed + i);
|
|
332
364
|
console.log('Use model request: ', refined.getName(), refined.lc_kwargs.model);
|
|
333
365
|
const startedAt = Date.now();
|
|
334
366
|
const { piece, result: collected } = await streamStructured(refined, msgs, innerSchema, toolName, action);
|