Skip to content

Fix MiniMax M3 effort vocabulary and make agent recovery the single rate-limit retry owner - #7

Merged
pentoshi007 merged 2 commits into
mainfrom
hoplite/korkyra-ef60ee85
Sep 5, 2026
Merged

Fix MiniMax M3 effort vocabulary and make agent recovery the single rate-limit retry owner#7
pentoshi007 merged 2 commits into
mainfrom
hoplite/korkyra-ef60ee85

Conversation

@usehoplite

@usehoplite usehoplite Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

On the Kilo free gateway, MiniMax M3 (free-2/minimax/minimax-m3:free) accepts high but rate-limits/rejects undocumented xhigh, 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), so xhigh/max requests clamp to high at 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: new retryRateLimits option. 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 of x-ratelimit-reset/ratelimit-reset headers and structured error bodies (error.metadata.headers), handling epoch seconds, epoch milliseconds, HTTP dates, and relative seconds; precedence is Retry-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)

  • reasoningWireKey now falls back to the style mapping when the route profile does not govern the wire, restoring distinct rungs for style-mapped providers (reasoning-degradation had regressed to stripping reasoning).
  • A ladder with no wire-distinct rung rethrows unattributed failures instead of stripping reasoning and falsely marking the route; attributed rejections still strip after rungs exhaust.

Verification

  • npm run typecheck clean.
  • Focused new tests: test/llm/minimax-m3-route.test.ts (Kilo wire sends high for xhigh/max, other free models keep xhigh, 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 in test/stream-recovery.test.ts.
  • Broad sweep green: 1,178 tests across 81 files (test/llm, test/admission, test/profiles, test/conformance, plus routing/recovery/provider suites), including the previously regressed test/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.

Open in Hoplite

usehoplite Bot and others added 2 commits September 4, 2026 17:08
…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>
@pentoshi007
pentoshi007 merged commit 5825d0d into main Sep 5, 2026
8 checks passed
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