Skip to content

refactor(provider): share error-body reading, adapter mechanics, protocol sets - #1435

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-10664-provider-de-dupe-error-reader-adapter-decorators-s
Oct 15, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-10664-provider-de-dupe-error-reader-adapter-decorators-s

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Collapses the four provider-side twins (C8–C11) into shared modules while keeping every per-adapter behavior local: a shared error-body reader/walker (error-body.ts) serves both the structured Codex usage-limit parser and the gateway (exact-code vs substring matchers stay strictly separate; a retryFromBody hook lifts Codex resets_in_seconds onto retryAfterMs — Codex-only by construction, non-Codex ignore pinned by test); shared adapter-decorator mechanics (withJsonBodyRewrite/withExtraHeaders/registry wrap) with bail-to-unchanged-request semantics while codex parallel_tool_calls, providerOptions merging, DeepSeek reasoning strip, Bifrost sentinel, session/cache-breakpoint headers stay in the adapters; one Anthropic-protocol identity set + canonical-segment helper replaces two sets + two canonicalizers (byte-equivalent union verified); one /models endpoint parser for the ollama/bounded-catalog pair with per-caller cap behavior preserved.
  • ~310 gross duplicated lines now single-copy; net non-test +92 because the shared modules carry their own documentation — the ticket's −130–150 estimate assumed lighter modules than the why-comments require.
  • One intentional semantics delta, disclosed: a malformed JSON body that previously crashed buildRequest in openai-compatible/deepseek paths now passes through unrewritten to the wire (unreachable in practice — base adapters always emit JSON; lenient beats loud here, and the byte-identity + non-JSON passthrough pins cover it).

Verification

  • bun run check exit 0: 8967 pass / 0 fail across 584 files.
  • Scoped: src/provider 417 pass / 0 fail; openai-responses + grok-responses retry contracts 23 pass / 0 fail; src/inference-gateway-error 74 pass / 0 fail; new tests pin body-wins retry, non-Codex body-reset ignorance, and both decorator bail paths.
  • Independent review verified: retryFromBody leakage structurally impossible (module-private hook + absent 4th argument on the non-Codex normalizer), protocol-set union byte-equivalent, registry freshness semantics preserved, line math reconciled.

Fixes CL-10664

…ocol sets

Four provider-side twins collapse: the usage-limit parser and the
gateway now share one error-body reader/walker (Codex exact-code match
and xAI substring markers stay apart); seven adapters share JSON-rewrite
and extra-header mechanics while per-adapter semantics stay local (the
decorators bail to an unchanged request when nothing applies); a
single Anthropic-protocol identity set + canonical segment replaces two
sets + two canonicalizers; and one /models endpoint parser replaces the
ollama/bounded-catalog pair. A retryFromBody hook lifts Codex
resets_in_seconds onto retryAfterMs but only for Codex.
@linear-code

linear-code Bot commented Oct 14, 2026

Copy link
Copy Markdown

CL-10664

@corbits-triage

corbits-triage Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by the comment below.

@corbits-triage

corbits-triage Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by the comment below.

@corbits-triage

corbits-triage Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

@TheGreatAxios
TheGreatAxios changed the base branch from cl-10665-auth-de-dupe-shared-callbackloginsessionstorelock-h to main October 15, 2026 22:45
@TheGreatAxios
TheGreatAxios merged commit 5ce0bac into main Oct 15, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant