@rallycry/conveyor-agent 6.0.8 → 6.0.9

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.
@@ -1491,13 +1491,7 @@ var API_ERROR_PATTERN2 = /API Error: [45]\d\d/;
1491
1491
  function stopTypingIfNeeded(host, isTyping) {
1492
1492
  if (isTyping) host.connection.sendTypingStop();
1493
1493
  }
1494
- function shouldBreakEventLoop(host, state) {
1495
- if (host.isStopped()) return true;
1496
- if (state.loopDetected) return true;
1497
- return false;
1498
- }
1499
- function flushPendingToolCalls(host, state) {
1500
- const { turnToolCalls } = state;
1494
+ function flushPendingToolCalls(host, turnToolCalls) {
1501
1495
  if (turnToolCalls.length === 0) return;
1502
1496
  for (let i = 0; i < turnToolCalls.length; i++) {
1503
1497
  if (i < host.pendingToolOutputs.length) {
@@ -1505,12 +1499,6 @@ function flushPendingToolCalls(host, state) {
1505
1499
  }
1506
1500
  }
1507
1501
  host.connection.sendEvent({ type: "turn_end", toolCalls: [...turnToolCalls] });
1508
- if (host.loopDetector.recordTurn(turnToolCalls)) {
1509
- state.loopDetected = true;
1510
- host.connection.postChatMessage(
1511
- "Loop detected: the agent has been repeating the same tool pattern. Intervening to change strategy..."
1512
- );
1513
- }
1514
1502
  turnToolCalls.length = 0;
1515
1503
  host.pendingToolOutputs.length = 0;
1516
1504
  }
@@ -1568,13 +1556,12 @@ async function processEvents(events, context, host) {
1568
1556
  rateLimitResetsAt: void 0,
1569
1557
  staleSession: void 0,
1570
1558
  authError: void 0,
1571
- loopDetected: false,
1572
1559
  lastAssistantUsage: void 0,
1573
1560
  turnToolCalls: []
1574
1561
  };
1575
1562
  for await (const event of events) {
1576
- flushPendingToolCalls(host, state);
1577
- if (shouldBreakEventLoop(host, state)) break;
1563
+ if (host.isStopped()) break;
1564
+ flushPendingToolCalls(host, state.turnToolCalls);
1578
1565
  const now = Date.now();
1579
1566
  if (now - lastStatusEmit >= STATUS_REEMIT_INTERVAL_MS) {
1580
1567
  host.connection.emitStatus("running");
@@ -1604,15 +1591,14 @@ async function processEvents(events, context, host) {
1604
1591
  break;
1605
1592
  }
1606
1593
  }
1607
- flushPendingToolCalls(host, state);
1594
+ flushPendingToolCalls(host, state.turnToolCalls);
1608
1595
  stopTypingIfNeeded(host, state.isTyping);
1609
1596
  return {
1610
1597
  retriable: state.retriable || state.sawApiError,
1611
1598
  resultSummary: state.resultSummary,
1612
1599
  rateLimitResetsAt: state.rateLimitResetsAt,
1613
1600
  ...state.staleSession && { staleSession: state.staleSession },
1614
- ...state.authError && { authError: state.authError },
1615
- ...state.loopDetected && { loopDetected: state.loopDetected }
1601
+ ...state.authError && { authError: state.authError }
1616
1602
  };
1617
1603
  }
1618
1604
 
@@ -5073,17 +5059,6 @@ function handleProcessResult(result, context, host, options) {
5073
5059
  if (result.authError) {
5074
5060
  return { action: "return_promise", promise: handleAuthError(context, host, options) };
5075
5061
  }
5076
- if (result.loopDetected) {
5077
- host.loopDetector.reset();
5078
- return {
5079
- action: "return_promise",
5080
- promise: runSdkQuery(
5081
- host,
5082
- context,
5083
- "You've been repeating the same tool pattern for several consecutive turns. Step back, analyze why your current approach is failing, and try a fundamentally different strategy. Do NOT repeat the same sequence of actions."
5084
- )
5085
- };
5086
- }
5087
5062
  if (!result.retriable) return { action: "return" };
5088
5063
  return {
5089
5064
  action: "continue",
@@ -5153,38 +5128,6 @@ var CostTracker = class {
5153
5128
  }
5154
5129
  };
5155
5130
 
5156
- // src/execution/loop-detector.ts
5157
- var DEFAULT_MAX_CONSECUTIVE_REPEATS = 3;
5158
- var LoopDetector = class _LoopDetector {
5159
- fingerprints = [];
5160
- maxConsecutiveRepeats;
5161
- constructor(maxConsecutiveRepeats = DEFAULT_MAX_CONSECUTIVE_REPEATS) {
5162
- this.maxConsecutiveRepeats = maxConsecutiveRepeats;
5163
- }
5164
- /** Build a fingerprint from a turn's tool calls: sorted unique tool names joined by comma. */
5165
- static fingerprint(toolCalls) {
5166
- const names = [...new Set(toolCalls.map((tc) => tc.tool))].sort();
5167
- return names.join(",");
5168
- }
5169
- /** Record a completed turn and return whether a loop is detected. */
5170
- recordTurn(toolCalls) {
5171
- if (toolCalls.length === 0) return false;
5172
- const fp = _LoopDetector.fingerprint(toolCalls);
5173
- this.fingerprints.push(fp);
5174
- if (this.fingerprints.length < this.maxConsecutiveRepeats) return false;
5175
- const recent = this.fingerprints.slice(-this.maxConsecutiveRepeats);
5176
- return recent.every((f) => f === fp);
5177
- }
5178
- /** Reset state (e.g. after a successful intervention breaks the loop). */
5179
- reset() {
5180
- this.fingerprints.length = 0;
5181
- }
5182
- /** Number of recorded turns. */
5183
- get turnCount() {
5184
- return this.fingerprints.length;
5185
- }
5186
- };
5187
-
5188
5131
  // src/runner/plan-sync.ts
5189
5132
  import { readdirSync, statSync, readFileSync } from "fs";
5190
5133
  import { join as join3 } from "path";
@@ -5536,7 +5479,6 @@ function buildQueryHost(deps) {
5536
5479
  callbacks: deps.callbacks,
5537
5480
  setupLog: deps.setupLog,
5538
5481
  costTracker: deps.costTracker,
5539
- loopDetector: deps.loopDetector,
5540
5482
  get agentMode() {
5541
5483
  return deps.getEffectiveAgentMode();
5542
5484
  },
@@ -5584,7 +5526,6 @@ var AgentRunner = class {
5584
5526
  taskContext = null;
5585
5527
  planSync;
5586
5528
  costTracker = new CostTracker();
5587
- loopDetector = new LoopDetector();
5588
5529
  worktreeActive = false;
5589
5530
  agentMode = null;
5590
5531
  hasExitedPlanMode = false;
@@ -5988,7 +5929,6 @@ var AgentRunner = class {
5988
5929
  callbacks: this.callbacks,
5989
5930
  setupLog: this.setupLog,
5990
5931
  costTracker: this.costTracker,
5991
- loopDetector: this.loopDetector,
5992
5932
  planSync: this.planSync,
5993
5933
  sessionIds: this.sessionIds,
5994
5934
  getEffectiveAgentMode: () => this.effectiveAgentMode,
@@ -7604,4 +7544,4 @@ export {
7604
7544
  ProjectRunner,
7605
7545
  FileCache
7606
7546
  };
7607
- //# sourceMappingURL=chunk-T6IASOS2.js.map
7547
+ //# sourceMappingURL=chunk-R6BFXUS7.js.map