Skip to content

feat: raise default per-step LLM retry budget to 10 attempts - #1740

Merged
sailist merged 2 commits into
MoonshotAI:mainfrom
sailist:feat/default-max-retries-10
Jul 15, 2026
Merged

feat: raise default per-step LLM retry budget to 10 attempts#1740
sailist merged 2 commits into
MoonshotAI:mainfrom
sailist:feat/default-max-retries-10

Conversation

@sailist

@sailist sailist commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

When the provider is rate-limited or overloaded (HTTP 429 "The engine is currently overloaded"), the agent does retry, but the default budget of 3 attempts only spans ~1.5s of backoff (0.5s, 1s). Sustained overload windows last far longer, so the turn fails and surfaces [provider.rate_limit] 429 to the user almost immediately — looking as if no retry happened at all. Session logs confirm this: three attempts within ~20s, all 429, then turn failure.

What changed

  • Raise the default per-step LLM retry budget from 3 to 10 attempts in both engines: agent-core (chatWithRetry) and agent-core-v2 (stepRetry service), keeping them aligned.
  • With the existing exponential ramp (500ms base, ×2, 32s cap, 25% jitter, plus server Retry-After honoring), 10 attempts yield roughly 2–3 minutes of total wait — enough to ride out typical multi-minute overload windows instead of failing after ~1.5s.
  • loop_control.max_retries_per_step in config.toml still overrides the default (docs updated, en + zh).
  • Tests updated for the new default, plus a new test asserting the full default budget is exhausted (10 attempts, 9 step.retrying events) before the turn fails.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

The default of 3 attempts only produced ~1.5s of backoff (0.5s/1s), so
sustained provider overload (429) surfaced to the user almost
immediately. With 10 attempts the exponential ramp (500ms base, x2,
32s cap, 25% jitter) waits out multi-minute overload windows before
failing the turn. Applies to both agent-core (chatWithRetry) and
agent-core-v2 (stepRetry service); loop_control.max_retries_per_step
still overrides.
@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4bf9dea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@4bf9dea
npx https://pkg.pr.new/@moonshot-ai/kimi-code@4bf9dea

commit: 4bf9dea

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c087503f24

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +9 to +12
// Default retry budget per step: 10 attempts (9 retries). Kept in sync with
// v1 (`agent-core/loop/retry.ts`): the exponential ramp below climbs 0.5s,
// 1s, 2s … up to the 32s cap, giving roughly 2–3 minutes of total wait to
// ride out a typical provider overload window (sustained 429s).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move retry-budget note into the file header

For files under packages/agent-core-v2, packages/agent-core-v2/AGENTS.md requires comments to live only in the top-of-file /** */ block and never beside functions, methods, or statements. This newly added standalone comment sits next to the exported constant, so please either fold this rationale into the existing module header or remove it from the v2 file.

Useful? React with 👍 / 👎.

- error-paths: the warn-log attempt field now reads 1/10 with the
  default 10-attempt budget
- goal-session pause tests: every LLM call throws a retryable error, so
  the default 10-attempt backoff (~2min) blew the 5s test timeout; pin
  maxRetriesPerStep=1 since the pause behavior does not depend on the
  retry count
@sailist
sailist merged commit a74ab44 into MoonshotAI:main Jul 15, 2026
14 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant