@codebolt/agent 6.1.4 → 6.1.6

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.
@@ -26,6 +26,7 @@ class Agent {
26
26
  this.maxTurns = (_f = runtimeConfig.maxTurns) !== null && _f !== void 0 ? _f : 25;
27
27
  }
28
28
  async execute(reqMessage) {
29
+ var _a;
29
30
  if (!reqMessage) {
30
31
  return {
31
32
  success: false,
@@ -58,6 +59,7 @@ class Agent {
58
59
  while (!stepResult) {
59
60
  try {
60
61
  const nextStepResult = await agentStep.executeStep(reqMessage, prompt);
62
+ this.compactionOrchestrator.updateModelTokenLimit((_a = nextStepResult.rawLLMResponse) === null || _a === void 0 ? void 0 : _a.tokenLimit);
61
63
  const recoverableResponseError = this.getRecoverableResponseError(nextStepResult.rawLLMResponse);
62
64
  if (!recoverableResponseError) {
63
65
  stepResult = nextStepResult;
@@ -71,6 +71,7 @@ class CodeboltAgent {
71
71
  };
72
72
  }
73
73
  async processMessage(message, context) {
74
+ var _a;
74
75
  try {
75
76
  const reqMessage = typeof message === 'string'
76
77
  ? this.createDefaultUserMessage(message)
@@ -107,6 +108,7 @@ class CodeboltAgent {
107
108
  while (!stepResult) {
108
109
  try {
109
110
  const nextStepResult = await agentStep.executeStep(reqMessage, prompt);
111
+ this.compactionOrchestrator.updateModelTokenLimit((_a = nextStepResult.rawLLMResponse) === null || _a === void 0 ? void 0 : _a.tokenLimit);
110
112
  const recoverableResponseError = this.getRecoverableResponseError(nextStepResult.rawLLMResponse);
111
113
  if (!recoverableResponseError) {
112
114
  stepResult = nextStepResult;
@@ -45,6 +45,7 @@ export declare class AutoCompact implements CompactionLayer {
45
45
  reset(): void;
46
46
  getTracking(): AutoCompactTracking | undefined;
47
47
  getConsecutiveFailures(): number;
48
+ updateModelTokenLimit(modelTokenLimit: number): void;
48
49
  private compactConversation;
49
50
  private findSplitIndex;
50
51
  private generateSummary;
@@ -106,6 +106,11 @@ class AutoCompact {
106
106
  getConsecutiveFailures() {
107
107
  return this.consecutiveFailures;
108
108
  }
109
+ updateModelTokenLimit(modelTokenLimit) {
110
+ if (Number.isFinite(modelTokenLimit) && modelTokenLimit > 0) {
111
+ this.options.modelTokenLimit = modelTokenLimit;
112
+ }
113
+ }
109
114
  // ─── Core Compaction Logic ────────────────────────────────────────
110
115
  async compactConversation(messages, ctx) {
111
116
  const estimator = new types_1.TokenEstimator();
@@ -61,6 +61,7 @@ export declare class CompactionOrchestrator {
61
61
  * Get the number of consecutive auto-compact failures.
62
62
  */
63
63
  getConsecutiveFailures(): number;
64
+ updateModelTokenLimit(modelTokenLimit: number | undefined): void;
64
65
  /**
65
66
  * Reset the reactive compact's per-turn guard.
66
67
  * Call at the start of each new turn.
@@ -200,6 +200,15 @@ class CompactionOrchestrator {
200
200
  getConsecutiveFailures() {
201
201
  return this.auto.getConsecutiveFailures();
202
202
  }
203
+ updateModelTokenLimit(modelTokenLimit) {
204
+ if (!Number.isFinite(modelTokenLimit) || !modelTokenLimit || modelTokenLimit <= 0) {
205
+ return;
206
+ }
207
+ this.options.modelTokenLimit = modelTokenLimit;
208
+ this.collapse.updateModelTokenLimit(modelTokenLimit);
209
+ this.auto.updateModelTokenLimit(modelTokenLimit);
210
+ this.reactive.updateModelTokenLimit(modelTokenLimit);
211
+ }
203
212
  /**
204
213
  * Reset the reactive compact's per-turn guard.
205
214
  * Call at the start of each new turn.
@@ -56,6 +56,7 @@ export declare class ContextCollapse implements CompactionLayer {
56
56
  */
57
57
  isAtBlockingLimit(messages: MessageObject[]): boolean;
58
58
  reset(): void;
59
+ updateModelTokenLimit(modelTokenLimit: number): void;
59
60
  private findSplitPoint;
60
61
  private buildSummaryMessages;
61
62
  private generateGranularSummary;
@@ -158,6 +158,11 @@ class ContextCollapse {
158
158
  this.store = [];
159
159
  this.staged = [];
160
160
  }
161
+ updateModelTokenLimit(modelTokenLimit) {
162
+ if (Number.isFinite(modelTokenLimit) && modelTokenLimit > 0) {
163
+ this.options.modelTokenLimit = modelTokenLimit;
164
+ }
165
+ }
161
166
  // ─── Private Helpers ──────────────────────────────────────────────
162
167
  findSplitPoint(messages, tokensToArchive, estimator) {
163
168
  var _a, _b;
@@ -41,6 +41,7 @@ export declare class ReactiveCompact implements CompactionLayer {
41
41
  * Reset per-turn guard (call at the start of each turn).
42
42
  */
43
43
  resetForTurn(): void;
44
+ updateModelTokenLimit(modelTokenLimit: number): void;
44
45
  /**
45
46
  * Check if an error message indicates a recoverable context error.
46
47
  */
@@ -61,6 +61,11 @@ class ReactiveCompact {
61
61
  resetForTurn() {
62
62
  this.hasAttemptedThisTurn = false;
63
63
  }
64
+ updateModelTokenLimit(modelTokenLimit) {
65
+ if (Number.isFinite(modelTokenLimit) && modelTokenLimit > 0) {
66
+ this.options.modelTokenLimit = modelTokenLimit;
67
+ }
68
+ }
64
69
  /**
65
70
  * Check if an error message indicates a recoverable context error.
66
71
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/agent",
3
- "version": "6.1.4",
3
+ "version": "6.1.6",
4
4
  "description": "CodeBolt Agent utilities for building and managing AI agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",