lemura 1.4.2 → 1.4.4

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as IProviderAdapter, T as TranscriptionRequest, d as TranscriptionResponse, e as SynthesisRequest, A as AudioChunk, V as VisionRequest, f as VisionResponse, g as ImageGenRequest, h as ImageGenResponse, M as ModelInfo, C as ContextWindow, i as Turn, j as ContentBlock, I as IToolDefinition } from './adapters-CVcfWf85.js';
2
2
  export { k as CompletionChunk, l as CompletionRequest, m as CompletionResponse, b as IContextStrategy, c as IScratchpadAdapter, n as IStorageAdapter, N as NormalizedMessage, o as STMItem, p as STMRegistryConfig, S as ShortTermMemoryRegistry, q as TokenUsage, r as ToolCall, s as ToolContext, t as ToolResult } from './adapters-CVcfWf85.js';
3
- import { S as SessionConfig, I as IToolResponseProcessor, T as ToolResponseEvaluation, M as MCPServerConfig, a as MCPToolDefinition } from './agent-DTcDIKIn.js';
4
- export { b as MCPJsonRpcRequest, c as MCPJsonRpcResponse, d as MCPTransportType, e as MediaConfig, f as ToolDecision, g as ToolExecutionBudget, h as ToolFirewallConfig, i as ToolFirewallRule, j as TraceEvent } from './agent-DTcDIKIn.js';
3
+ import { S as SessionConfig, I as IToolResponseProcessor, T as ToolResponseEvaluation, M as MCPServerConfig, a as MCPToolDefinition } from './agent-BH_uE2nT.js';
4
+ export { b as MCPJsonRpcRequest, c as MCPJsonRpcResponse, d as MCPTransportType, e as MediaConfig, f as ToolDecision, g as ToolExecutionBudget, h as ToolFirewallConfig, i as ToolFirewallRule, j as TraceEvent } from './agent-BH_uE2nT.js';
5
5
  export { LemuraAdapterError, LemuraContextOverflowError, LemuraError, LemuraMCPConnectionError, LemuraMCPError, LemuraMCPTimeoutError, LemuraMaxIterationsError, LemuraSkillInjectionError, LemuraToolNotFoundError, LemuraToolTimeoutError, LemuraToolValidationError } from './types/index.js';
6
6
  import { I as ILogger } from './logger-DxvKliuk.js';
7
7
  export { L as LogLevel, a as LogMetadata, S as Severity } from './logger-DxvKliuk.js';
@@ -30,67 +30,6 @@ declare class MediaBridge {
30
30
  supportsVision(): boolean;
31
31
  }
32
32
 
33
- interface Goal {
34
- id: string;
35
- statement: string;
36
- /** High-level sub-goals decomposed from the main statement */
37
- decomposition: string[];
38
- successCriteria: string[];
39
- injectionFrequency: 'always' | 'every_N_turns' | 'on_compression';
40
- injectionPosition: 'system_prompt' | 'pre_turn';
41
- /** Sub-goals already completed — updated via `markSubGoalDone()` */
42
- completedSubGoals?: string[];
43
- }
44
- /**
45
- * GoalInjector keeps the original task objective visible throughout the ReAct loop,
46
- * preventing goal drift after many tool calls and context compressions.
47
- *
48
- * Usage in SessionManager:
49
- * - For `system_prompt` position: call `injectInto(prompt)` which appends the goal block.
50
- * - For `pre_turn` position: call `getFormattedBlock()` and push as a system message.
51
- */
52
- declare class GoalInjector {
53
- private goal;
54
- private turnsSinceInjection;
55
- constructor(goal: Goal);
56
- /**
57
- * Returns the formatted `[CURRENT GOAL]` block string — without caring about
58
- * where it will be placed. Callers decide whether to append to a system prompt
59
- * or push as a separate message.
60
- */
61
- getFormattedBlock(): string;
62
- /**
63
- * Appends the goal block to the given prompt string (for `system_prompt` position).
64
- * For `pre_turn` position, use `getFormattedBlock()` directly.
65
- *
66
- * @param prompt - The existing system prompt to append to.
67
- */
68
- injectInto(prompt: string): string;
69
- /**
70
- * Returns true when the goal should be re-injected this turn,
71
- * based on `injectionFrequency`.
72
- *
73
- * @param turnIndex - The current turn index in the ReAct loop (0-based)
74
- * @param compressionOccurred - Whether context was compressed this iteration
75
- * @param injectionN - The N for 'every_N_turns' frequency (default: 3)
76
- */
77
- shouldInjectThisTurn(turnIndex: number, compressionOccurred?: boolean, injectionN?: number): boolean;
78
- /**
79
- * Updates the goal with new sub-goal decomposition and success criteria,
80
- * typically populated by the mini-planning LLM call.
81
- */
82
- updateDecomposition(decomposition: string[], successCriteria?: string[]): void;
83
- /**
84
- * Marks a sub-goal as completed so it moves to the "completed" section
85
- * in subsequent injections.
86
- */
87
- markSubGoalDone(subGoal: string): void;
88
- /** Returns a snapshot of the current goal state (safe to store in context.metadata). */
89
- getGoal(): Goal;
90
- /** Increments the internal turn counter (used for `every_N_turns` frequency). */
91
- incrementTurn(): void;
92
- }
93
-
94
33
  /**
95
34
  * An optional condition that gates a step's execution on the output of a prior step.
96
35
  * When the condition is not met, the step is automatically marked `skipped`.
@@ -101,6 +40,44 @@ interface StepCondition {
101
40
  /** Substring that must be present in the prior step's output to allow this step to run */
102
41
  outputContains: string;
103
42
  }
43
+ /**
44
+ * Result returned by a `StepVerifier.check` function.
45
+ * - `pass` — the sub-goal is achieved; the step is marked `done`.
46
+ * - `fail` — the sub-goal failed; the step is marked `failed` and BFS propagates to dependants.
47
+ * - `retry` — the output is unsatisfactory but retriable; the step is reset to `pending`.
48
+ */
49
+ interface StepVerifierResult {
50
+ status: 'pass' | 'fail' | 'retry';
51
+ reason?: string;
52
+ }
53
+ /**
54
+ * Optional semantic verifier attached to a `ContinuationStep`.
55
+ * Called after the tool executes successfully to confirm the sub-goal is actually met.
56
+ *
57
+ * @example
58
+ * verify: {
59
+ * maxRetries: 2,
60
+ * check: (output) => {
61
+ * const data = JSON.parse(output);
62
+ * return data.rows?.length > 0
63
+ * ? { status: 'pass' }
64
+ * : { status: 'retry', reason: 'Empty result set' };
65
+ * }
66
+ * }
67
+ */
68
+ interface StepVerifier {
69
+ /**
70
+ * Inspects the tool output and decides whether the sub-goal is satisfied.
71
+ * @param output - Serialised tool result string
72
+ * @param args - The resolved arguments that were passed to the tool
73
+ */
74
+ check: (output: string, args: Record<string, unknown>) => Promise<StepVerifierResult> | StepVerifierResult;
75
+ /**
76
+ * Maximum number of `retry` verdicts allowed before the step is forced to `failed`.
77
+ * Defaults to 0 (no retries — a `retry` verdict immediately becomes `failed`).
78
+ */
79
+ maxRetries?: number;
80
+ }
104
81
  interface ContinuationStep {
105
82
  stepId: string;
106
83
  toolName: string;
@@ -124,6 +101,14 @@ interface ContinuationStep {
124
101
  * contains the given substring. When the condition is not met, the step is skipped.
125
102
  */
126
103
  condition?: StepCondition;
104
+ /**
105
+ * Optional semantic verifier: called after the tool executes to confirm the
106
+ * sub-goal is actually satisfied. Supports `pass / fail / retry` verdicts
107
+ * with a configurable `maxRetries` count.
108
+ *
109
+ * @since 1.4.4
110
+ */
111
+ verify?: StepVerifier;
127
112
  }
128
113
  interface ContinuationPlan {
129
114
  steps: ContinuationStep[];
@@ -152,7 +137,13 @@ interface ContinuationPlan {
152
137
  declare class ContinuationPlanner {
153
138
  private plan;
154
139
  private outputs;
155
- constructor(plan: ContinuationPlan);
140
+ private retryCount;
141
+ private onStepSkipped;
142
+ private onStepFailed;
143
+ constructor(plan: ContinuationPlan, callbacks?: {
144
+ onStepSkipped?: (stepId: string, reason: string) => void;
145
+ onStepFailed?: (stepId: string, reason: string) => void;
146
+ });
156
147
  /** Returns the current plan (deep copy) */
157
148
  getPlan(): ContinuationPlan;
158
149
  /** Returns a human-readable status string with icons (injected before each iteration) */
@@ -172,11 +163,18 @@ declare class ContinuationPlanner {
172
163
  /**
173
164
  * Marks a step as failed and propagates `skipped` to all transitively dependent steps.
174
165
  */
175
- markStepFailed(stepId: string): void;
166
+ markStepFailed(stepId: string, reason?: string): void;
176
167
  /**
177
168
  * Marks a step as skipped (e.g., condition not met) and propagates to its dependants.
178
169
  */
179
- markStepSkipped(stepId: string): void;
170
+ markStepSkipped(stepId: string, reason?: string): void;
171
+ /**
172
+ * Resets a step back to `pending` for a retry attempt.
173
+ * Increments the internal retry counter for the step.
174
+ */
175
+ markStepPending(stepId: string): void;
176
+ /** Returns how many times a step has been retried. */
177
+ getRetryCount(stepId: string): number;
180
178
  /** Retrieves an output stored by `outputKey` from a completed step */
181
179
  getOutput(key: string): string | undefined;
182
180
  /**
@@ -190,6 +188,67 @@ declare class ContinuationPlanner {
190
188
  private _advanceIndex;
191
189
  }
192
190
 
191
+ interface Goal {
192
+ id: string;
193
+ statement: string;
194
+ /** High-level sub-goals decomposed from the main statement */
195
+ decomposition: string[];
196
+ successCriteria: string[];
197
+ injectionFrequency: 'always' | 'every_N_turns' | 'on_compression';
198
+ injectionPosition: 'system_prompt' | 'pre_turn';
199
+ /** Sub-goals already completed — updated via `markSubGoalDone()` */
200
+ completedSubGoals?: string[];
201
+ }
202
+ /**
203
+ * GoalInjector keeps the original task objective visible throughout the ReAct loop,
204
+ * preventing goal drift after many tool calls and context compressions.
205
+ *
206
+ * Usage in SessionManager:
207
+ * - For `system_prompt` position: call `injectInto(prompt)` which appends the goal block.
208
+ * - For `pre_turn` position: call `getFormattedBlock()` and push as a system message.
209
+ */
210
+ declare class GoalInjector {
211
+ private goal;
212
+ private turnsSinceInjection;
213
+ constructor(goal: Goal);
214
+ /**
215
+ * Returns the formatted `[CURRENT GOAL]` block string — without caring about
216
+ * where it will be placed. Callers decide whether to append to a system prompt
217
+ * or push as a separate message.
218
+ */
219
+ getFormattedBlock(): string;
220
+ /**
221
+ * Appends the goal block to the given prompt string (for `system_prompt` position).
222
+ * For `pre_turn` position, use `getFormattedBlock()` directly.
223
+ *
224
+ * @param prompt - The existing system prompt to append to.
225
+ */
226
+ injectInto(prompt: string): string;
227
+ /**
228
+ * Returns true when the goal should be re-injected this turn,
229
+ * based on `injectionFrequency`.
230
+ *
231
+ * @param turnIndex - The current turn index in the ReAct loop (0-based)
232
+ * @param compressionOccurred - Whether context was compressed this iteration
233
+ * @param injectionN - The N for 'every_N_turns' frequency (default: 3)
234
+ */
235
+ shouldInjectThisTurn(turnIndex: number, compressionOccurred?: boolean, injectionN?: number): boolean;
236
+ /**
237
+ * Updates the goal with new sub-goal decomposition and success criteria,
238
+ * typically populated by the mini-planning LLM call.
239
+ */
240
+ updateDecomposition(decomposition: string[], successCriteria?: string[]): void;
241
+ /**
242
+ * Marks a sub-goal as completed so it moves to the "completed" section
243
+ * in subsequent injections.
244
+ */
245
+ markSubGoalDone(subGoal: string): void;
246
+ /** Returns a snapshot of the current goal state (safe to store in context.metadata). */
247
+ getGoal(): Goal;
248
+ /** Increments the internal turn counter (used for `every_N_turns` frequency). */
249
+ incrementTurn(): void;
250
+ }
251
+
193
252
  /**
194
253
  * Core entry point for lemura agent sessions.
195
254
  *
@@ -320,6 +379,22 @@ declare class SessionManager {
320
379
  * ```
321
380
  */
322
381
  setPlan(steps: ContinuationStep[], strategy?: ContinuationPlan['strategy']): void;
382
+ /**
383
+ * Returns a snapshot of the current continuation plan, or `null` if no plan
384
+ * has been set via `setPlan()`.
385
+ *
386
+ * Use this after `run()` to inspect which steps completed, failed, or were skipped.
387
+ *
388
+ * @since 1.4.4
389
+ *
390
+ * @example
391
+ * ```typescript
392
+ * await session.run('Run the pipeline');
393
+ * const plan = session.getPlan();
394
+ * const failed = plan?.steps.filter(s => s.status === 'failed');
395
+ * ```
396
+ */
397
+ getPlan(): ContinuationPlan | null;
323
398
  /**
324
399
  * Manually sets the agent's goal, bypassing the automatic mini-planning LLM call.
325
400
  *
@@ -612,4 +687,4 @@ declare class MCPClientRegistry {
612
687
  private _bridge;
613
688
  }
614
689
 
615
- export { AudioChunk, ContentBlock, ContextWindow, type ContinuationPlan, ContinuationPlanner, type ContinuationStep, FinalResponseFormatter, type Goal, GoalInjector, ILogger, IProviderAdapter, IToolDefinition, IToolResponseProcessor, ImageGenRequest, ImageGenResponse, MCPClient, MCPClientRegistry, MCPServerConfig, MCPToolDefinition, MediaBridge, ModelInfo, SessionConfig, SessionManager, SkillInjector, type StepCondition, StepCounter, SynthesisRequest, ToolRegistry, ToolResponseEvaluation, ToolResponseProcessor, type ToolResponseProcessorConfig, TranscriptionRequest, TranscriptionResponse, Turn, VisionRequest, VisionResponse };
690
+ export { AudioChunk, ContentBlock, ContextWindow, type ContinuationPlan, ContinuationPlanner, type ContinuationStep, FinalResponseFormatter, type Goal, GoalInjector, ILogger, IProviderAdapter, IToolDefinition, IToolResponseProcessor, ImageGenRequest, ImageGenResponse, MCPClient, MCPClientRegistry, MCPServerConfig, MCPToolDefinition, MediaBridge, ModelInfo, SessionConfig, SessionManager, SkillInjector, type StepCondition, StepCounter, type StepVerifier, type StepVerifierResult, SynthesisRequest, ToolRegistry, ToolResponseEvaluation, ToolResponseProcessor, type ToolResponseProcessorConfig, TranscriptionRequest, TranscriptionResponse, Turn, VisionRequest, VisionResponse };
package/dist/index.js CHANGED
@@ -1925,8 +1925,13 @@ ${block}` : block;
1925
1925
  var ContinuationPlanner = class {
1926
1926
  plan;
1927
1927
  outputs = /* @__PURE__ */ new Map();
1928
- constructor(plan) {
1928
+ retryCount = /* @__PURE__ */ new Map();
1929
+ onStepSkipped;
1930
+ onStepFailed;
1931
+ constructor(plan, callbacks) {
1929
1932
  this.plan = { ...plan, steps: plan.steps.map((s) => ({ ...s })) };
1933
+ this.onStepSkipped = callbacks?.onStepSkipped;
1934
+ this.onStepFailed = callbacks?.onStepFailed;
1930
1935
  }
1931
1936
  // -------------------------------------------------------------------------
1932
1937
  // State queries
@@ -2007,17 +2012,31 @@ var ContinuationPlanner = class {
2007
2012
  /**
2008
2013
  * Marks a step as failed and propagates `skipped` to all transitively dependent steps.
2009
2014
  */
2010
- markStepFailed(stepId) {
2015
+ markStepFailed(stepId, reason = "step failed") {
2011
2016
  this._updateStep(stepId, { status: "failed" });
2017
+ this.onStepFailed?.(stepId, reason);
2012
2018
  this._skipDependants(stepId);
2013
2019
  }
2014
2020
  /**
2015
2021
  * Marks a step as skipped (e.g., condition not met) and propagates to its dependants.
2016
2022
  */
2017
- markStepSkipped(stepId) {
2023
+ markStepSkipped(stepId, reason = "condition not met") {
2018
2024
  this._updateStep(stepId, { status: "skipped" });
2025
+ this.onStepSkipped?.(stepId, reason);
2019
2026
  this._skipDependants(stepId);
2020
2027
  }
2028
+ /**
2029
+ * Resets a step back to `pending` for a retry attempt.
2030
+ * Increments the internal retry counter for the step.
2031
+ */
2032
+ markStepPending(stepId) {
2033
+ this._updateStep(stepId, { status: "pending" });
2034
+ this.retryCount.set(stepId, (this.retryCount.get(stepId) ?? 0) + 1);
2035
+ }
2036
+ /** Returns how many times a step has been retried. */
2037
+ getRetryCount(stepId) {
2038
+ return this.retryCount.get(stepId) ?? 0;
2039
+ }
2021
2040
  // -------------------------------------------------------------------------
2022
2041
  // Output / input mapping helpers
2023
2042
  // -------------------------------------------------------------------------
@@ -2059,6 +2078,7 @@ var ContinuationPlanner = class {
2059
2078
  for (const step of this.plan.steps) {
2060
2079
  if (step.status === "pending" && step.dependsOn.some((d) => toSkip.has(d))) {
2061
2080
  this._updateStep(step.stepId, { status: "skipped" });
2081
+ this.onStepSkipped?.(step.stepId, `dependency '${failedStepId}' failed or was skipped`);
2062
2082
  toSkip.add(step.stepId);
2063
2083
  changed = true;
2064
2084
  }
@@ -2587,6 +2607,21 @@ var SessionManager = class {
2587
2607
  }
2588
2608
  this.media = new MediaBridge(this.adapter);
2589
2609
  this.stepCounter = new StepCounter(config.maxSteps ?? 20);
2610
+ if (config.maxSteps !== void 0 && config.maxIterations === void 0) {
2611
+ const defaultMaxIts = 10;
2612
+ if (config.maxSteps > defaultMaxIts) {
2613
+ this.logger.warn(
2614
+ `[Config] maxSteps=${config.maxSteps} is set but maxIterations is not. The default maxIterations=${defaultMaxIts} may stop the agent before maxSteps is reached. Consider setting maxIterations to at least Math.ceil(maxSteps / avgToolCallsPerTurn).`
2615
+ );
2616
+ }
2617
+ }
2618
+ if (config.maxSteps !== void 0 && config.maxIterations !== void 0) {
2619
+ if (config.maxSteps > config.maxIterations * 10) {
2620
+ this.logger.warn(
2621
+ `[Config] maxSteps (${config.maxSteps}) is much larger than maxIterations (${config.maxIterations}). The agent will be stopped by maxIterations before maxSteps is ever reached.`
2622
+ );
2623
+ }
2624
+ }
2590
2625
  this.toolResponseProcessor = config.toolResponseProcessor instanceof ToolResponseProcessor ? config.toolResponseProcessor : config.toolResponseProcessor ? config.toolResponseProcessor : new ToolResponseProcessor();
2591
2626
  for (const strategy of config.compressionStrategies || []) {
2592
2627
  this.contextManager.registerStrategy(strategy);
@@ -2786,16 +2821,39 @@ var SessionManager = class {
2786
2821
  * ```
2787
2822
  */
2788
2823
  setPlan(steps, strategy = "sequential") {
2789
- this.continuationPlanner = new ContinuationPlanner({
2790
- steps,
2791
- currentStepIndex: 0,
2792
- strategy
2793
- });
2824
+ this.continuationPlanner = new ContinuationPlanner(
2825
+ { steps, currentStepIndex: 0, strategy },
2826
+ {
2827
+ onStepFailed: (stepId, reason) => this.emitTrace("planning", "step_failed", { stepId, reason }),
2828
+ onStepSkipped: (stepId, reason) => this.emitTrace("planning", "step_skipped", { stepId, reason })
2829
+ }
2830
+ );
2794
2831
  this.context.metadata["continuationPlan"] = this.continuationPlanner.getPlan();
2795
2832
  this.logger.debug(`[ContinuationPlanner] Plan set with ${steps.length} steps (strategy: ${strategy})`);
2796
2833
  this.emitTrace("planning", "plan_set", { stepCount: steps.length, strategy });
2797
2834
  }
2798
2835
  // -----------------------------------------------------------------------
2836
+ // Plan inspection API
2837
+ // -----------------------------------------------------------------------
2838
+ /**
2839
+ * Returns a snapshot of the current continuation plan, or `null` if no plan
2840
+ * has been set via `setPlan()`.
2841
+ *
2842
+ * Use this after `run()` to inspect which steps completed, failed, or were skipped.
2843
+ *
2844
+ * @since 1.4.4
2845
+ *
2846
+ * @example
2847
+ * ```typescript
2848
+ * await session.run('Run the pipeline');
2849
+ * const plan = session.getPlan();
2850
+ * const failed = plan?.steps.filter(s => s.status === 'failed');
2851
+ * ```
2852
+ */
2853
+ getPlan() {
2854
+ return this.continuationPlanner ? this.continuationPlanner.getPlan() : null;
2855
+ }
2856
+ // -----------------------------------------------------------------------
2799
2857
  // Goal planning API
2800
2858
  // -----------------------------------------------------------------------
2801
2859
  /**
@@ -2887,7 +2945,7 @@ Respond ONLY with valid JSON (no markdown, no explanations):
2887
2945
  const response = await this.adapter.complete({
2888
2946
  model: this.config.model,
2889
2947
  messages: [{ role: "user", content: planningPrompt }],
2890
- maxTokens: this.config.maxCompletionTokens ?? 2e3
2948
+ maxTokens: this.config.maxCompletionTokens ?? 4e3
2891
2949
  });
2892
2950
  const raw = response.content.replace(/```json|```/g, "").trim();
2893
2951
  const parsed = JSON.parse(raw);
@@ -3204,6 +3262,36 @@ ${planStatus}`;
3204
3262
  (s) => s.toolName === tc.name && s.status === "running"
3205
3263
  );
3206
3264
  if (runningStep) {
3265
+ if (runningStep.verify) {
3266
+ const maxRetries = runningStep.verify.maxRetries ?? 0;
3267
+ const retryCount = this.continuationPlanner.getRetryCount(runningStep.stepId);
3268
+ let verdict;
3269
+ try {
3270
+ verdict = await runningStep.verify.check(content, args);
3271
+ } catch (verifyErr) {
3272
+ verdict = { status: "fail", reason: `Verifier threw: ${verifyErr.message}` };
3273
+ }
3274
+ if (verdict.status === "fail" || verdict.status === "retry" && retryCount >= maxRetries) {
3275
+ this.continuationPlanner.markStepFailed(runningStep.stepId);
3276
+ this.context.metadata["continuationPlan"] = this.continuationPlanner.getPlan();
3277
+ this.emitTrace("planning", "step_failed", {
3278
+ stepId: runningStep.stepId,
3279
+ reason: verdict.reason ?? "verifier returned fail",
3280
+ retryCount
3281
+ });
3282
+ return content;
3283
+ }
3284
+ if (verdict.status === "retry") {
3285
+ this.continuationPlanner.markStepPending(runningStep.stepId);
3286
+ this.context.metadata["continuationPlan"] = this.continuationPlanner.getPlan();
3287
+ this.emitTrace("planning", "step_retry", {
3288
+ stepId: runningStep.stepId,
3289
+ reason: verdict.reason,
3290
+ retryCount: this.continuationPlanner.getRetryCount(runningStep.stepId)
3291
+ });
3292
+ return content;
3293
+ }
3294
+ }
3207
3295
  this.continuationPlanner.markStepDone(runningStep.stepId, content);
3208
3296
  if (runningStep.outputKey) {
3209
3297
  const outputs = this.context.metadata["toolOutputs"] ?? {};
@@ -3274,7 +3362,7 @@ ${planStatus}`;
3274
3362
  const maxIts = this.config.maxIterations || 10;
3275
3363
  this.iterations = 0;
3276
3364
  this.stepCounter = new StepCounter(this.config.maxSteps ?? 20);
3277
- const maxCompletionTokens = this.config.maxCompletionTokens ?? 2e3;
3365
+ const maxCompletionTokens = this.config.maxCompletionTokens ?? 4e3;
3278
3366
  while (this.iterations < maxIts) {
3279
3367
  this.iterations++;
3280
3368
  this.logger.debug(`ReAct Iteration ${this.iterations}/${maxIts}`);
@@ -3471,7 +3559,7 @@ ${planStatus}`;
3471
3559
  const maxIts = this.config.maxIterations || 10;
3472
3560
  this.iterations = 0;
3473
3561
  this.stepCounter = new StepCounter(this.config.maxSteps ?? 20);
3474
- const maxCompletionTokens = this.config.maxCompletionTokens ?? 2e3;
3562
+ const maxCompletionTokens = this.config.maxCompletionTokens ?? 4e3;
3475
3563
  while (this.iterations < maxIts) {
3476
3564
  this.iterations++;
3477
3565
  this.logger.debug(`[stream] ReAct Iteration ${this.iterations}/${maxIts}`);