Fix MiniMax M3 effort vocabulary and make agent recovery the single rate-limit retry owner - #7
Merged
Merged
Conversation
…retry owner MiniMax M3 now advertises its documented effort contract (none..high) as a model family, so xhigh requests clamp to high at plan level and the Kilo Responses wire never sends the undocumented xhigh. The plan compiler resolves the emitted reasoning control once: suppression omits the reasoning payload on the Responses wire (matching chat completions), and out-of-vocabulary efforts clamp to the route vocabulary, which also corrects the meta muse wire to its documented efforts. Agent streams now own rate-limit waits end to end: streamWithProvider accepts retryRateLimits and the turn loop opts out of router-level 429 sleeps while keeping key rotation, endpoint rotation, provider fallback, and the effort ladder. Provider reset metadata (x-ratelimit-reset / ratelimit-reset headers and structured error bodies, epoch seconds/milliseconds/HTTP dates/relative values) feeds the recovery planner, which waits out the longer of the provider window and the 10/20/30/40/60s schedule, capped at 60s. Repairs the effort-ladder regression from the wire-true key change: reasoningWireKey falls back to the style mapping when the route profile does not govern the wire, and a ladder with no wire-distinct rung rethrows unattributed failures instead of stripping reasoning and falsely marking the route, while attributed rejections still strip after rungs exhaust. Co-authored-by: Aniket Pandey <aniket00736@gmail.com>
…ontract The documented family vocabulary is a floor, not a cap: when the live catalog advertises reasoning.supported_efforts for the route, ingest registers them and the wire follows the catalog instead of the family. Pins that the Kilo Responses wire sends xhigh when the catalog advertises it for M3. Co-authored-by: Aniket Pandey <aniket00736@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On the Kilo free gateway, MiniMax M3 (
free-2/minimax/minimax-m3:free) acceptshighbut rate-limits/rejects undocumentedxhigh, and when a rate limit did occur the agent surfaced nested 2s/6s/18s/54s delays from the router instead of the intended 10s/20s/30s/40s/60s schedule, continuing through hidden retry layers before stopping.Changes
Route-true effort vocabulary
src/llm/model-families.ts: MiniMax M3 now has a model family with its documented effort contract (none/minimal/low/medium/high), soxhigh/maxrequests clamp tohighat request-shaping time on any gateway (Kilo free, nvidia, tokenrouter) while other free models keep the broad gateway vocabulary.src/llm/request-plan.ts: the plan compiler resolves the emitted reasoning control once — out-of-vocabulary efforts clamp to the route vocabulary (no-op when the route has no vocabulary), and the cache fingerprint hashes the emitted control.src/llm/responses-request.ts: the Responses wire now honors plan-level control suppression (omits the reasoning payload on routes that rejected reasoning controls), matching chat completions; raw preferences no longer bypass suppression. This also corrects the meta muse wire to its documented efforts (medium → high,concise → detailed— two goldens updated).One retry owner for rate limits
src/llm/router.ts/src/llm/routing/key-rotation.ts: newretryRateLimitsoption. The agent turn loop opts out of router-level 429 sleeps (src/agent/turn/loop/round-request.ts), so a 429 on a keyless free route surfaces immediately to the agent recovery schedule instead of nesting 2s/6s/18s/54s waits. Key rotation (one attempt per key), endpoint rotation, provider fallback, non-rate-limit retries, and the effort ladder are unchanged.Provider reset metadata
src/llm/wire/response-errors.ts: centralized parsing ofx-ratelimit-reset/ratelimit-resetheaders and structured error bodies (error.metadata.headers), handling epoch seconds, epoch milliseconds, HTTP dates, and relative seconds; precedence isRetry-After→ reset metadata → body hints.src/agent/stream-recovery.ts: the recovery planner waits out the longer of the provider reset window and the authoritative 10/20/30/40/60s schedule, capped at 60s, and reports the actual delay.Effort-ladder regression repair (from
a10b7281)reasoningWireKeynow falls back to the style mapping when the route profile does not govern the wire, restoring distinct rungs for style-mapped providers (reasoning-degradationhad regressed to stripping reasoning).Verification
npm run typecheckclean.test/llm/minimax-m3-route.test.ts(Kilo wire sendshighforxhigh/max, other free models keepxhigh, learned facts override the documented contract),test/llm/router-retry-ownership.test.ts(single-slot 429 rethrows after 1 call, two keys rotate once each, 5xx still retries ×7, default ownership retries ×7),test/llm/reset-metadata.test.ts(10 cases: header/body/epoch/date/precedence),test/llm/responses-control.test.ts, and exact 10/20/30/40/60s + provider-reset assertions intest/stream-recovery.test.ts.test/llm,test/admission,test/profiles,test/conformance, plus routing/recovery/provider suites), including the previously regressedtest/reasoning-degradation.test.ts(all 26) — repaired in source, without weakening those tests; only the two meta golden snapshots were updated to the documented meta effort contract.