@rallycry/conveyor-agent 6.0.8 → 6.1.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.
|
@@ -1387,11 +1387,12 @@ async function emitResultEvent(event, host, context, startTime, lastAssistantUsa
|
|
|
1387
1387
|
function handleRateLimitEvent(event, host) {
|
|
1388
1388
|
const { rate_limit_info } = event;
|
|
1389
1389
|
const status = rate_limit_info.status;
|
|
1390
|
-
|
|
1390
|
+
const utilization = rate_limit_info.utilization ?? (status === "rejected" ? 1 : void 0);
|
|
1391
|
+
if (utilization !== void 0 && rate_limit_info.rateLimitType) {
|
|
1391
1392
|
host.connection.sendEvent({
|
|
1392
1393
|
type: "rate_limit_update",
|
|
1393
1394
|
rateLimitType: rate_limit_info.rateLimitType,
|
|
1394
|
-
utilization
|
|
1395
|
+
utilization,
|
|
1395
1396
|
status
|
|
1396
1397
|
});
|
|
1397
1398
|
}
|
|
@@ -1403,8 +1404,8 @@ function handleRateLimitEvent(event, host) {
|
|
|
1403
1404
|
safeVoid(host.callbacks.onEvent({ type: "error", message }), "rateLimitRejected");
|
|
1404
1405
|
return resetsAt;
|
|
1405
1406
|
} else if (status === "allowed_warning") {
|
|
1406
|
-
const
|
|
1407
|
-
const message = `Rate limit warning: ${
|
|
1407
|
+
const utilizationLabel = rate_limit_info.utilization ? `${Math.round(rate_limit_info.utilization * 100)}%` : "high";
|
|
1408
|
+
const message = `Rate limit warning: ${utilizationLabel} utilization (type: ${rate_limit_info.rateLimitType ?? "unknown"})`;
|
|
1408
1409
|
host.connection.sendEvent({ type: "thinking", message });
|
|
1409
1410
|
safeVoid(host.callbacks.onEvent({ type: "thinking", message }), "rateLimitWarning");
|
|
1410
1411
|
}
|
|
@@ -1491,13 +1492,7 @@ var API_ERROR_PATTERN2 = /API Error: [45]\d\d/;
|
|
|
1491
1492
|
function stopTypingIfNeeded(host, isTyping) {
|
|
1492
1493
|
if (isTyping) host.connection.sendTypingStop();
|
|
1493
1494
|
}
|
|
1494
|
-
function
|
|
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;
|
|
1495
|
+
function flushPendingToolCalls(host, turnToolCalls) {
|
|
1501
1496
|
if (turnToolCalls.length === 0) return;
|
|
1502
1497
|
for (let i = 0; i < turnToolCalls.length; i++) {
|
|
1503
1498
|
if (i < host.pendingToolOutputs.length) {
|
|
@@ -1505,12 +1500,6 @@ function flushPendingToolCalls(host, state) {
|
|
|
1505
1500
|
}
|
|
1506
1501
|
}
|
|
1507
1502
|
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
1503
|
turnToolCalls.length = 0;
|
|
1515
1504
|
host.pendingToolOutputs.length = 0;
|
|
1516
1505
|
}
|
|
@@ -1568,13 +1557,12 @@ async function processEvents(events, context, host) {
|
|
|
1568
1557
|
rateLimitResetsAt: void 0,
|
|
1569
1558
|
staleSession: void 0,
|
|
1570
1559
|
authError: void 0,
|
|
1571
|
-
loopDetected: false,
|
|
1572
1560
|
lastAssistantUsage: void 0,
|
|
1573
1561
|
turnToolCalls: []
|
|
1574
1562
|
};
|
|
1575
1563
|
for await (const event of events) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1564
|
+
if (host.isStopped()) break;
|
|
1565
|
+
flushPendingToolCalls(host, state.turnToolCalls);
|
|
1578
1566
|
const now = Date.now();
|
|
1579
1567
|
if (now - lastStatusEmit >= STATUS_REEMIT_INTERVAL_MS) {
|
|
1580
1568
|
host.connection.emitStatus("running");
|
|
@@ -1604,15 +1592,14 @@ async function processEvents(events, context, host) {
|
|
|
1604
1592
|
break;
|
|
1605
1593
|
}
|
|
1606
1594
|
}
|
|
1607
|
-
flushPendingToolCalls(host, state);
|
|
1595
|
+
flushPendingToolCalls(host, state.turnToolCalls);
|
|
1608
1596
|
stopTypingIfNeeded(host, state.isTyping);
|
|
1609
1597
|
return {
|
|
1610
1598
|
retriable: state.retriable || state.sawApiError,
|
|
1611
1599
|
resultSummary: state.resultSummary,
|
|
1612
1600
|
rateLimitResetsAt: state.rateLimitResetsAt,
|
|
1613
1601
|
...state.staleSession && { staleSession: state.staleSession },
|
|
1614
|
-
...state.authError && { authError: state.authError }
|
|
1615
|
-
...state.loopDetected && { loopDetected: state.loopDetected }
|
|
1602
|
+
...state.authError && { authError: state.authError }
|
|
1616
1603
|
};
|
|
1617
1604
|
}
|
|
1618
1605
|
|
|
@@ -5073,17 +5060,6 @@ function handleProcessResult(result, context, host, options) {
|
|
|
5073
5060
|
if (result.authError) {
|
|
5074
5061
|
return { action: "return_promise", promise: handleAuthError(context, host, options) };
|
|
5075
5062
|
}
|
|
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
5063
|
if (!result.retriable) return { action: "return" };
|
|
5088
5064
|
return {
|
|
5089
5065
|
action: "continue",
|
|
@@ -5153,38 +5129,6 @@ var CostTracker = class {
|
|
|
5153
5129
|
}
|
|
5154
5130
|
};
|
|
5155
5131
|
|
|
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
5132
|
// src/runner/plan-sync.ts
|
|
5189
5133
|
import { readdirSync, statSync, readFileSync } from "fs";
|
|
5190
5134
|
import { join as join3 } from "path";
|
|
@@ -5536,7 +5480,6 @@ function buildQueryHost(deps) {
|
|
|
5536
5480
|
callbacks: deps.callbacks,
|
|
5537
5481
|
setupLog: deps.setupLog,
|
|
5538
5482
|
costTracker: deps.costTracker,
|
|
5539
|
-
loopDetector: deps.loopDetector,
|
|
5540
5483
|
get agentMode() {
|
|
5541
5484
|
return deps.getEffectiveAgentMode();
|
|
5542
5485
|
},
|
|
@@ -5584,7 +5527,6 @@ var AgentRunner = class {
|
|
|
5584
5527
|
taskContext = null;
|
|
5585
5528
|
planSync;
|
|
5586
5529
|
costTracker = new CostTracker();
|
|
5587
|
-
loopDetector = new LoopDetector();
|
|
5588
5530
|
worktreeActive = false;
|
|
5589
5531
|
agentMode = null;
|
|
5590
5532
|
hasExitedPlanMode = false;
|
|
@@ -5988,7 +5930,6 @@ var AgentRunner = class {
|
|
|
5988
5930
|
callbacks: this.callbacks,
|
|
5989
5931
|
setupLog: this.setupLog,
|
|
5990
5932
|
costTracker: this.costTracker,
|
|
5991
|
-
loopDetector: this.loopDetector,
|
|
5992
5933
|
planSync: this.planSync,
|
|
5993
5934
|
sessionIds: this.sessionIds,
|
|
5994
5935
|
getEffectiveAgentMode: () => this.effectiveAgentMode,
|
|
@@ -7604,4 +7545,4 @@ export {
|
|
|
7604
7545
|
ProjectRunner,
|
|
7605
7546
|
FileCache
|
|
7606
7547
|
};
|
|
7607
|
-
//# sourceMappingURL=chunk-
|
|
7548
|
+
//# sourceMappingURL=chunk-EUNUBCGF.js.map
|