@zenera/neo 1.4.3 → 1.4.5

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/runner.d.ts CHANGED
@@ -64,9 +64,12 @@ export interface RunnerOptions<TCtx = unknown> {
64
64
  * Asked when a model call fails, before the run fails with it. Returning a
65
65
  * `SuspendSpec` suspends the run at that call instead (`site: 'llm'` in
66
66
  * `state.suspended`); resuming makes the call again. For refusals that
67
- * something outside the run can cure — a spending limit topped up. Only
68
- * asked on the trunk, never in a fork branch, and only when nothing of the
69
- * answer was streamed yet; an abort is never offered.
67
+ * something outside the run can cure — a spending limit topped up. Also
68
+ * asked when the auto-recall before a model call fails with a provider
69
+ * error (its embedding is refused first); a suspension then waits at that
70
+ * model call and resuming recalls again. Only asked on the trunk, never in
71
+ * a fork branch, and only when nothing of the answer was streamed yet; an
72
+ * abort is never offered.
70
73
  */
71
74
  onModelError?: ModelErrorHandler;
72
75
  /**
@@ -94,7 +97,7 @@ export interface ModelRetryPolicy {
94
97
  export interface ModelErrorContext {
95
98
  /** the suspension's id if it suspends: `llm:<n>`, `n` being the model calls made so far */
96
99
  callId: string;
97
- /** the model's id */
100
+ /** the refused model's id: the model call's, or the recall embedding's */
98
101
  model: string;
99
102
  state: AgentState;
100
103
  }
package/dist/runner.js CHANGED
@@ -2,6 +2,7 @@ import { Agent, AgentRegistry } from "./agent.js";
2
2
  import { describeArchitecture } from "./architecture.js";
3
3
  import { classify, retryAfterMs, statusOf } from "./embeddings/rate-limit.js";
4
4
  import { EventQueue, RunStream, } from "./events.js";
5
+ import { ProviderError } from "./failure.js";
5
6
  import { systemClock } from "./ids.js";
6
7
  import * as Kernel from "./kernel.js";
7
8
  import { renderRecollection } from "./memory/render.js";
@@ -248,7 +249,26 @@ export class AgentRunner {
248
249
  }
249
250
  state = await Kernel.applySystemPrompt(state, this.registry, env);
250
251
  state = await this.#preload(state, env);
251
- state = await this.#autoRecall(state, env);
252
+ try {
253
+ state = await this.#autoRecall(state, env);
254
+ }
255
+ catch (err) {
256
+ // The recall's embedding is the turn's first provider call, so a
257
+ // spending limit refuses it before the model call: it may wait like
258
+ // that call. A failed recall leaves no node, so resuming recalls again.
259
+ const spec = branch || signal?.aborted || !(err instanceof ProviderError)
260
+ ? undefined
261
+ : await this.#onModelError?.(err, {
262
+ callId: modelCallId(state),
263
+ model: err.site.model,
264
+ state,
265
+ });
266
+ if (!spec) {
267
+ throw err;
268
+ }
269
+ state = Kernel.applyModelSuspension(state, { callId: modelCallId(state), name: this.#modelFor(state).id }, spec, this.#clock.now());
270
+ return yield* this.#finish(state, branch, 'suspended');
271
+ }
252
272
  yield tag(state, branch, { type: 'before_llm_call', state });
253
273
  const req = await Kernel.buildRequest(state, this.registry, env);
254
274
  const digest = Kernel.requestDigest(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenera/neo",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "A multi-agent runtime for Node.js: agents, models, tools, skills, memory and an append-only trajectory.",
5
5
  "keywords": [
6
6
  "agents",
@@ -62,7 +62,7 @@
62
62
  "prepack": "tsc -b"
63
63
  },
64
64
  "dependencies": {
65
- "@zenera/sandbox": "^1.4.3",
65
+ "@zenera/sandbox": "^1.4.5",
66
66
  "graphology": "^0.26.0",
67
67
  "yaml": "^2.9.1",
68
68
  "zod": "^4.6.7"