Skip to content

feat(adapters): endpoint overrides for routing through an LLM gateway - #34

Merged
gjtorikian merged 2 commits into
mainfrom
feat/ai-gateway
Oct 16, 2026
Merged

gjtorikian merged 2 commits into
mainfrom
feat/ai-gateway

Conversation

@gjtorikian

Copy link
Copy Markdown
Collaborator

Summary

  • Container adapters can declare optionalHostEnv: endpoint overrides forwarded into attempt containers only when set (ANTHROPIC_BASE_URL and ANTHROPIC_CUSTOM_HEADERS for claude, OPENAI_BASE_URL for codex). Unset means vendor-direct, exactly as before.
  • The harness adds an override's host to the egress allowlist, retargets the preflight key probe at it, and redacts *_HEADERS from artifacts like a key; base URLs stay diagnostic in transcripts.
  • The codex adapter renders OPENAI_BASE_URL into ~/.codex/config.toml as a custom model provider, because codex 0.149.1 ignores the env var for its built-in provider (verified in the pinned agent-runtime image: it still dialed api.openai.com).
  • AnthropicModelClient (the diagnose analyst) honors ANTHROPIC_BASE_URL via the SDK and ANTHROPIC_CUSTOM_HEADERS via a small Name: Value parser, so diagnosis takes the same route as the agent.
  • Verified live inside quickstudy/agent-runtime against a Cloudflare AI Gateway: Claude Code 2.1.215 and Codex 0.149.1 both completed a prompt through it. The README documents the contract with placeholders only; nothing vendor- or company-specific lands in the harness.

Container adapters can declare `optionalHostEnv`: endpoint overrides
(ANTHROPIC_BASE_URL, ANTHROPIC_CUSTOM_HEADERS; OPENAI_BASE_URL) that are
forwarded into attempt containers only when set, so a gateway or proxy is
an env change rather than a code change. The harness adds an override's
host to the egress allowlist, retargets the preflight key probe at it, and
redacts header bundles from artifacts like a key; base URLs stay
diagnostic.

The codex adapter renders OPENAI_BASE_URL into ~/.codex/config.toml as a
custom model provider: codex 0.149.1 ignores the env var for its built-in
provider (verified in the pinned image). The diagnose analyst honors the
same Anthropic overrides so it takes the agent's route.
@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; all five previous findings are addressed.

Summary

Adds gateway endpoint overrides for Claude, Codex, and the diagnosis analyst.

  • Claude and Codex can route requests through an LLM gateway.
  • The diagnosis analyst can use Claude’s configured gateway route.
  • Gateway header credentials stay out of saved artifacts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  E[Host endpoint overrides] --> P[Gateway preflight probe]
  E --> M[Full endpoint URLs in run identity]
  E --> C[Attempt container environment]
  C --> A[Claude reads environment]
  C --> T[Codex config.toml]
  A --> G[LLM gateway]
  T --> G
  M --> R[Reject resume when route changes]
Loading

Reviews (2) · Last reviewed commit: "fix(gateway): deliver multi-line headers..." · Reviewed by Greptile

Comment thread src/runner/execute.ts Resolved
Comment thread src/runner/execute.ts Resolved
Comment thread src/runner/execute.ts Resolved
Comment thread src/runner/execute.ts Resolved
Comment thread docs/getting-started.md Resolved
…rd routes

Review findings on the endpoint-override contract:

- A header bundle with several lines could not reach the attempt container:
  the env-file channel is line-based and refused newlines. Multi-line values
  now ride the docker CLI's own environment, named on argv by `-e KEY` alone,
  so argv still never carries a value. Covered by a daemon-free split test and
  a Docker round-trip.
- The credentials inside a header bundle (each auth header's value and the
  bare bearer token) are redaction targets of their own, so a transcript that
  prints only the token is scrubbed; hostSecretEnv expands bundles the same way.
- An override's host joins the egress allowlist only under the proxy, where the
  list is live and an IP literal is refused loudly by design; without the proxy
  an IP-based gateway no longer stops an otherwise valid run.
- The non-secret override URLs are recorded in full in the pair environment,
  so a changed gateway route changes both manifest and attempt identity and a
  resume cannot mix routes. Vendor-direct pairs hash exactly as before.
- getting-started states that a gateway still needs the key variable.
@gjtorikian
gjtorikian merged commit 3e16298 into main Oct 16, 2026
13 checks passed
@gjtorikian
gjtorikian deleted the feat/ai-gateway branch October 16, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant