Skip to content

Recover provider request limits and preserve tool history - #1957

Merged
elie222 merged 5 commits into
mainfrom
codex/model-request-recovery
Oct 23, 2026
Merged

elie222 merged 5 commits into
mainfrom
codex/model-request-recovery

Conversation

@elie222

@elie222 elie222 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Groq reasoning models could receive a developer-role instruction that their chat template rejected. Requests could also exceed an account's token allowance or reserve more output than its available OpenRouter credit, even when a smaller request could run. Switching to a Google model after a tool call could also replay history without the signature its API requires.

Use system instructions for Groq. Before any output, recover once from either of two specific provider rejections: rebuild a Groq request within its reported token ceiling using the existing context policy, or reduce an OpenRouter output reservation to its reported positive allowance. Keep adjustments local to the run/model, preserve saved settings and output ceilings, and share the original request deadline. Both primary and helper calls use this path. Empty balances, key limits, unrelated errors, local reservation failures, and partial text/tool output retain their existing behavior.

For transferred tool history, use Google's documented transfer marker only on foreign calls whose signatures Pi discarded. Preserve native signatures, unsigned native parallel parts, original history, and existing payload hooks; keep completed results so tools are not repeated. An offline SDK test checks the literal outgoing wire format for both Google-to-Google and cross-provider transfers.

Recovery emits model.context_limit.reduced or model.output_reservation.reduced with provider/model, run correlation, and numeric limits only. It records no prompts, responses, tool arguments, account identifiers, or credentials. No UI copy or layout changes.

Validation: offline outgoing-wire tests reproduce Groq's previous instruction role. Runtime, limit, protocol, and offline integration tests pass, including actual context reduction, subsequent tool turns, bounded retries, deadlines, local reservations, partial output, and credential isolation. Workspace type checks and lint pass with existing warnings. Independent reuse, quality, and efficiency review completed; shared policy construction was consolidated. All fixtures are synthetic and no paid inference was used.

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
rakazo-www Skipped Skipped Oct 23, 2026 1:54pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

The PR adds bounded recovery for Groq request limits and OpenRouter output allowances. It also uses system instructions for Groq and preserves transferred Google tool history.

  • Model requests recover from specific Groq and OpenRouter limits.
  • Google requests keep transferred tool history usable.
  • Groq requests send instructions as system messages.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Prepare model request] --> B[Send request]
  B --> C{Provider rejects before output?}
  C -->|Supported Groq limit| D[Reduce context for this run]
  C -->|Supported OpenRouter allowance| E[Reduce output reservation]
  D --> F[Retry once within original deadline]
  E --> F
  C -->|Other error or partial output| G[Keep existing error behavior]
  B --> H[Continue model and tool turns]
  F --> H
Loading

Reviews (3) · Last reviewed commit: "Use SDK JSON types in Google history fix..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Playwright screenshots

No new feature frames; gallery is suite-vs-main drift.

Open screenshot gallery · Dashboard · CI run

Updated for commit 13df367.

@elie222 elie222 changed the title Recover output reservations and use supported Groq instruction roles Recover provider request budgets and use supported Groq roles Oct 23, 2026
@elie222 elie222 changed the title Recover provider request budgets and use supported Groq roles Recover provider request limits and preserve tool history Oct 23, 2026
@elie222
elie222 merged commit 7fb9bee into main Oct 23, 2026
26 checks passed
@elie222
elie222 deleted the codex/model-request-recovery branch October 23, 2026 17:58

This branch was previously deployed

1 inactive deployment
Preview — 13df367a Deployed Oct 23, 2026 by vercel[bot]
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