mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 21:03:19 +00:00
fix(coding-agent): reset retry counter after each successful LLM response
Previously, within a single tool-use turn, rate limit retries would accumulate across separate LLM calls. For example, if each of 3 tool calls hit a 429 and retried once, the counter would show '3/3' and fail even though each individual retry succeeded. Now the counter resets immediately when a successful (non-error) assistant message arrives, so each LLM call gets a fresh set of retries. Fixes #1019
This commit is contained in:
parent
25707f9ad4
commit
4f004adefa
2 changed files with 14 additions and 10 deletions
|
|
@ -354,6 +354,19 @@ export class AgentSession {
|
|||
// Track assistant message for auto-compaction (checked on agent_end)
|
||||
if (event.message.role === "assistant") {
|
||||
this._lastAssistantMessage = event.message;
|
||||
|
||||
// Reset retry counter immediately on successful assistant response
|
||||
// This prevents accumulation across multiple LLM calls within a turn
|
||||
const assistantMsg = event.message as AssistantMessage;
|
||||
if (assistantMsg.stopReason !== "error" && this._retryAttempt > 0) {
|
||||
this._emit({
|
||||
type: "auto_retry_end",
|
||||
success: true,
|
||||
attempt: this._retryAttempt,
|
||||
});
|
||||
this._retryAttempt = 0;
|
||||
this._resolveRetry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -366,16 +379,6 @@ export class AgentSession {
|
|||
if (this._isRetryableError(msg)) {
|
||||
const didRetry = await this._handleRetryableError(msg);
|
||||
if (didRetry) return; // Retry was initiated, don't proceed to compaction
|
||||
} else if (this._retryAttempt > 0) {
|
||||
// Previous retry succeeded - emit success event and reset counter
|
||||
this._emit({
|
||||
type: "auto_retry_end",
|
||||
success: true,
|
||||
attempt: this._retryAttempt,
|
||||
});
|
||||
this._retryAttempt = 0;
|
||||
// Resolve the retry promise so waitForRetry() completes
|
||||
this._resolveRetry();
|
||||
}
|
||||
|
||||
await this._checkCompaction(msg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue