@dudousxd/nestjs-agent 0.12.0 → 0.13.0

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.
@@ -223,11 +223,19 @@ interface AgentModuleOptions {
223
223
  durable?: boolean;
224
224
  /**
225
225
  * Dispatch the turn's model call and tool executions as routed durable steps
226
- * (`AgentRunSteps.llm` / `AgentRunSteps.tool`) instead of in-process `ctx.localStep`s.
227
- * DEFAULT `true` under `durable: true` — dispatching moves the run off its pod during the two
228
- * long steps (the correct production posture), and `AgentRunSteps` is always registered so the
229
- * routed groups are never unserved. Set `false` to keep the turn's steps in-process localSteps.
230
- * `true` without `durable: true` throws at module build.
226
+ * (`AgentRunSteps.llm` / `AgentRunSteps.tool`) instead of in-process `ctx.localStep`s. OMITTED
227
+ * keeps them in-process; `true` without `durable: true` throws at module build.
228
+ *
229
+ * WHAT IT BUYS: the run is not pinned to one pod for the two long parts of a turn, so a fleet can
230
+ * scale the model call and tool execution separately from the workflow itself.
231
+ *
232
+ * WHY IT IS NOT A DEFAULT. It relocates the HOST's own code. A tool handler no longer runs inside
233
+ * the turn's workflow body but inside whichever worker serves the routed group, and the `llm`
234
+ * step re-runs the host's tool-visibility callbacks there to rebuild its tool list. A handler
235
+ * that resolves anything per invocation from its caller's execution context — a request-scoped
236
+ * ORM EntityManager, an AsyncLocalStorage tenant, a CLS transaction — finds nothing in that
237
+ * worker, and the library has no way to know which handlers do that. Turn this on once the tools
238
+ * this deployment registers establish whatever context they need themselves.
231
239
  *
232
240
  * The cross-process-sink requirement is a property of `durable: true` itself, not of this flag:
233
241
  * the turn already runs on whichever worker takes `agent.run`, which may not be the pod holding
@@ -383,12 +391,11 @@ interface AgentModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
383
391
  */
384
392
  durable?: boolean;
385
393
  /**
386
- * Dispatch the turn's model call and tool executions as routed durable steps. DEFAULT `true`
387
- * under `durable: true`; set `false` to keep the turn's steps in-process localSteps. Same
388
- * static-wiring reasoning as `durable` above — it lives here (not in the async factory result)
389
- * because it decides how `AgentRunWorkflow` builds its hooks at module build time. `true` without
390
- * `durable: true` throws at module build. See `AgentModuleOptions.dispatchedSteps` for the full
391
- * contract.
394
+ * Dispatch the turn's model call and tool executions as routed durable steps. Omitted keeps the
395
+ * turn's steps in-process localSteps. Same static-wiring reasoning as `durable` above — it lives
396
+ * here (not in the async factory result) because it decides how `AgentRunWorkflow` builds its
397
+ * hooks at module build time. `true` without `durable: true` throws at module build. See
398
+ * `AgentModuleOptions.dispatchedSteps` for the full contract.
392
399
  */
393
400
  dispatchedSteps?: boolean;
394
401
  /**
@@ -223,11 +223,19 @@ interface AgentModuleOptions {
223
223
  durable?: boolean;
224
224
  /**
225
225
  * Dispatch the turn's model call and tool executions as routed durable steps
226
- * (`AgentRunSteps.llm` / `AgentRunSteps.tool`) instead of in-process `ctx.localStep`s.
227
- * DEFAULT `true` under `durable: true` — dispatching moves the run off its pod during the two
228
- * long steps (the correct production posture), and `AgentRunSteps` is always registered so the
229
- * routed groups are never unserved. Set `false` to keep the turn's steps in-process localSteps.
230
- * `true` without `durable: true` throws at module build.
226
+ * (`AgentRunSteps.llm` / `AgentRunSteps.tool`) instead of in-process `ctx.localStep`s. OMITTED
227
+ * keeps them in-process; `true` without `durable: true` throws at module build.
228
+ *
229
+ * WHAT IT BUYS: the run is not pinned to one pod for the two long parts of a turn, so a fleet can
230
+ * scale the model call and tool execution separately from the workflow itself.
231
+ *
232
+ * WHY IT IS NOT A DEFAULT. It relocates the HOST's own code. A tool handler no longer runs inside
233
+ * the turn's workflow body but inside whichever worker serves the routed group, and the `llm`
234
+ * step re-runs the host's tool-visibility callbacks there to rebuild its tool list. A handler
235
+ * that resolves anything per invocation from its caller's execution context — a request-scoped
236
+ * ORM EntityManager, an AsyncLocalStorage tenant, a CLS transaction — finds nothing in that
237
+ * worker, and the library has no way to know which handlers do that. Turn this on once the tools
238
+ * this deployment registers establish whatever context they need themselves.
231
239
  *
232
240
  * The cross-process-sink requirement is a property of `durable: true` itself, not of this flag:
233
241
  * the turn already runs on whichever worker takes `agent.run`, which may not be the pod holding
@@ -383,12 +391,11 @@ interface AgentModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
383
391
  */
384
392
  durable?: boolean;
385
393
  /**
386
- * Dispatch the turn's model call and tool executions as routed durable steps. DEFAULT `true`
387
- * under `durable: true`; set `false` to keep the turn's steps in-process localSteps. Same
388
- * static-wiring reasoning as `durable` above — it lives here (not in the async factory result)
389
- * because it decides how `AgentRunWorkflow` builds its hooks at module build time. `true` without
390
- * `durable: true` throws at module build. See `AgentModuleOptions.dispatchedSteps` for the full
391
- * contract.
394
+ * Dispatch the turn's model call and tool executions as routed durable steps. Omitted keeps the
395
+ * turn's steps in-process localSteps. Same static-wiring reasoning as `durable` above — it lives
396
+ * here (not in the async factory result) because it decides how `AgentRunWorkflow` builds its
397
+ * hooks at module build time. `true` without `durable: true` throws at module build. See
398
+ * `AgentModuleOptions.dispatchedSteps` for the full contract.
392
399
  */
393
400
  dispatchedSteps?: boolean;
394
401
  /**
@@ -662,9 +662,9 @@ function runnerProviders() {
662
662
  {
663
663
  provide: AGENT_DISPATCHED_STEPS,
664
664
  useFactory: /* @__PURE__ */ __name((options, sink) => {
665
- const enabled = options.durable === true && options.dispatchedSteps !== false;
665
+ const enabled = options.durable === true && options.dispatchedSteps === true;
666
666
  if (enabled && sink instanceof InProcessTokenStreamSink) {
667
- logger.warn("Dispatched steps are active (the default under durable: true) with the default InProcessTokenStreamSink, which only buffers tokens in-process. A dispatched `llm` step served by a different worker cannot stream into this buffer. Wire a cross-process TokenStreamSink (e.g. a Redis pub/sub sink) via AgentModule.forRoot({ sink }) before running multi-pod, or set dispatchedSteps: false to keep the turn in-process localSteps.");
667
+ logger.warn("dispatchedSteps: true with the default InProcessTokenStreamSink, which only buffers tokens in-process. A dispatched `llm` step served by a different worker cannot stream into this buffer. Wire a cross-process TokenStreamSink (e.g. a Redis pub/sub sink) via AgentModule.forRoot({ sink }) before running multi-pod, or drop dispatchedSteps to keep the turn in-process localSteps.");
668
668
  }
669
669
  return enabled;
670
670
  }, "useFactory"),