Skip to content

Show earliest credential retry in model cooldown errors - #6845

Open
kakcil wants to merge 3 commits into
router-for-me:devfrom
kakcil:feature/cooldown-next-retry
Open

kakcil wants to merge 3 commits into
router-for-me:devfrom
kakcil:feature/cooldown-next-retry

Conversation

@kakcil

@kakcil kakcil commented Oct 21, 2026

Copy link
Copy Markdown

Summary

When every credential for a model is cooling down, add the earliest known retry time to the human-readable 429 message. Claude Code and other clients that display only error.message can then show when the proxy will next try a credential. Keep the existing reset_time, reset_seconds, and Retry-After behavior, and add structured next_retry_at (UTC) for clients that parse the JSON.

Include a short credential prefix such as claude-1234abcd in the message when the credential ID has the standard generated form. This matches the visible credential filename while omitting the account email and file path. The structured next_auth_index is emitted only when the index is a 16-character lowercase hex value. Unknown or malformed identities are omitted.

The timestamp is the proxy's earliest next retry, not a guarantee that the upstream provider will accept a request then. Preserve the selected retry time and credential through route-model restoration, and cover the scheduler, mixed-provider, and selector paths.

Validation

  • go test ./sdk/cliproxy/auth passed.
  • CGO_ENABLED=0 go build -o /tmp/cliproxyapi-cooldown-next-retry-check ./cmd/server passed.
  • Added focused tests for earliest credential selection, client-facing time, identity redaction, and route-model restoration. No live model requests or reset credits were used for validation.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T11:24:50.444283Z 13217c6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kakcil

kakcil commented Nov 6, 2026

Copy link
Copy Markdown
Author

This PR remains mergeable with all checks passing and no open review threads. I checked current main and the next-retry detail is still absent there. Could a maintainer review this when convenient?

kakcil and others added 2 commits November 12, 2026 14:14
Resolve cooldown error conflicts by keeping upstream's Claude cooldown
metadata (newModelCooldownErrorForCandidates) and chaining withNextRetry
onto it, so cooldown errors carry both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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: 13217c6095

ℹ️ 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".

NextHint string `json:"next_credential_hint"`
} `json:"error"`
}
if errUnmarshal := json.Unmarshal([]byte(err.Error()), &payload); errUnmarshal != nil {

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 Parse the cooldown payload with ojson

This newly added assertion decodes JSON with the standard encoding/json package, while the repository requires github.com/MoeForge/moego/ojson for all JSON operations. Rework the assertion to validate and inspect the payload with ojson instead of extending the prohibited API usage.

AGENTS.md reference: AGENTS.md:L53-L53

Useful? React with 👍 / 👎.

errorBody["provider"] = e.provider
}
if !e.retryAt.IsZero() {
errorBody["next_retry_at"] = e.retryAt.UTC().Format(time.RFC3339)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve fractional precision in next_retry_at

When a cooldown deadline retains nanoseconds, as deadlines created with time.Now().Add(...) normally do, formatting it with time.RFC3339 truncates the fractional part. The new next_retry_at can therefore advertise a time up to almost one second before the credential is actually eligible, causing clients that honor this field to retry while it is still blocked even though Retry-After correctly rounds upward; preserve the fraction with RFC3339Nano or round the timestamp up.

Useful? React with 👍 / 👎.

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