You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good targeted addition. classifyAgentRecovery in agent-recovery.ts cleanly separates retryable transient failures (network, idle-timeout, 429/5xx) from aborts/auth/4xx, and the unit tests in agent-recovery.test.ts cover the boundary cases well (401/403 vs 400, explicit isRetryable signal, abort). The integration test in loop-agent-steps.test.ts demonstrates the retry actually recovers mid-loop and tags the injected message with AGENT_RECOVERY, which is the right level of test for this kind of change.
A few things worth double-checking before this lands in the private tree:
Cost/credit accounting.creditsBefore/childrenBefore are captured once before the retry loop in run-agent-step.ts, but if the failed first attempt already streamed partial tokens/tool calls before throwing, it's unclear whether that usage is reflected in currentAgentState by the time the retry succeeds. Worth confirming the diff computed after the loop doesn't silently drop or double-count the failed attempt's partial cost.
MAX_AGENT_STEP_RECOVERY_ATTEMPTS = 1 vs. the exponential backoff design.getAgentRecoveryDelayMs supports many attempts (tested up to 20), but with the cap at 1 it will only ever be called with attempt=1 in production, so the backoff curve is currently dead code. Either bump the cap slightly or simplify the delay function to match actual usage — as written it reads like it's designed for more retries than the code allows.
Worth confirming that partial/successful side effects on currentAgentState from a failed runAgentStep call (if any exist internally) are not carried into the retry, since the loop reuses the same currentAgentState reference across attempts.
None of these are blocking correctness issues from what's visible in the diff, just things the maintainer porting this by hand should verify against the private tree's actual runAgentStep internals, which aren't shown here.
Thanks for the review. I addressed the three points in c488f2e:
Each recovery attempt now snapshots and restores the message history, partial output, and context before retrying, so failed-attempt side effects are not carried into the successful attempt.
Credits and child run IDs are preserved from the failed attempt and merged without double-counting usage.
MAX_AGENT_STEP_RECOVERY_ATTEMPTS is now 2, so the existing exponential backoff is exercised for two additional bounded attempts.
Validation:
Focused recovery and integration tests: 42 passed, 0 failed.
Typecheck reaches only the same two pre-existing missing agents-graveyard/researcher imports; there are no errors in the changed files.
This keeps aborts, authentication failures, and client 4xx responses non-retryable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation