Skip to content

feat(providers): add model request transport overrides - #60200

Merged
vincentkoc merged 3 commits into
mainfrom
refactor/provider-request-surface
Apr 3, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
refactor/provider-request-surface

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • Problem: models.providers.* had no first-class request transport surface, so generic model-provider overrides could not express shared headers/auth/proxy/TLS and SecretRefs there were not runtime-real.
  • Why it matters: provider request policy was centralized internally, but model-provider config still lagged behind media/tooling and OpenRouter attribution still leaked onto custom proxy routes.
  • What changed: added models.providers.*.request, wired it through embedded model resolution, resolved and documented provider request SecretRefs end to end, and host-gated OpenRouter attribution to native/default routes.
  • What did NOT change (scope boundary): no new plugin SDK surface, no broader provider auth redesign, no additional provider-family routing cleanup beyond OpenRouter attribution gating.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Root Cause / Regression History (if applicable)

  • Root cause: the request-policy refactor had internal transport resolution, but models.providers.* still only exposed legacy headers/authHeader knobs and the secrets runtime only collected the older provider surfaces.
  • Missing detection / guardrail: no schema/runtime/registry parity test covered provider request overrides on model providers, and OpenRouter attribution was still provider-key-gated instead of host-gated.
  • Prior context (git blame, prior PR, issue, or refactor if known): follows the recent provider request policy centralization work on main.
  • Why this regressed now: the internal abstraction moved faster than the public config/runtime surfaces, leaving a half-wired path.
  • If unknown, what was ruled out: N/A.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/pi-embedded-runner/model.test.ts, src/secrets/runtime.test.ts, src/secrets/runtime.coverage.test.ts, src/secrets/target-registry.test.ts, src/agents/provider-attribution.test.ts.
  • Scenario the test should lock in: model-provider request overrides validate, resolve SecretRefs, shape runtime request headers, and only apply OpenRouter attribution on native/default routes.
  • Why this is the smallest reliable guardrail: the bug spans schema, runtime secret resolution, and request policy, so unit + runtime coverage is the narrowest combination that proves the full path.
  • Existing test that already covers this (if any): the provider request config tests already cover the sanitizer and merge behavior; this PR extends coverage to the model-provider and registry/runtime surfaces.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

  • models.providers.<id>.request.{headers,auth,proxy,tls} is now a supported config surface.
  • SecretRefs under that surface resolve correctly at runtime and appear in schema-driven config consumers.
  • provider: "openrouter" no longer injects OpenRouter attribution headers when baseUrl points at a custom proxy/self-hosted endpoint.

Diagram (if applicable)

Before:
models.providers.<id>.request.* -> schema gap / runtime gap -> overrides missing or unresolved
provider=openrouter + proxy baseUrl -> OpenRouter headers still injected

After:
models.providers.<id>.request.* -> schema + secrets runtime + request policy -> resolved transport overrides
provider=openrouter + proxy baseUrl -> no OpenRouter attribution headers

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): Yes
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any Yes, explain risk + mitigation: this expands SecretRef-capable config on model providers; mitigation is explicit runtime resolution, snapshot redaction, target-registry coverage, and host-gating OpenRouter attribution off custom proxy routes.

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node 25 / pnpm
  • Model/provider: OpenAI/OpenRouter config surfaces
  • Integration/channel (if any): N/A
  • Relevant config (redacted): models.providers.<id>.request.*

Steps

  1. Configure models.providers.openai.request with SecretRefs for headers/auth/proxy/TLS.
  2. Run config validation and secrets runtime snapshot prep.
  3. Resolve inline/provider-backed models and inspect request shaping.
  4. Configure provider: openrouter with a custom proxy baseUrl and inspect attribution policy.

Expected

  • Provider request overrides validate, resolve, redact, and flow through model resolution.
  • OpenRouter attribution headers only appear for native/default OpenRouter routes.

Actual

  • Verified by scoped tests and gates below.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: scoped tests for provider request config, model resolution, config schema, redaction, runtime secret resolution, secret target registry, exec-ref parity, and OpenRouter attribution policy.
  • Edge cases checked: unresolved SecretRefs fail closed, provider request SecretRefs resolve under model providers, custom proxy OpenRouter routes do not inherit attribution, generated base schema includes the new fields.
  • What you did not verify: full pnpm test suite.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): Yes
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: secret-target registry expansion also updates published SecretRef inventory.
    • Mitigation: synced docs/reference/secretref-user-supplied-credentials-matrix.json and docs/reference/secretref-credential-surface.md, plus registry tests.
  • Risk: provider request surface could drift from runtime shaping again.
    • Mitigation: model-path, runtime snapshot, registry coverage, schema/help, and redaction tests now cover the same surface.

@vincentkoc vincentkoc self-assigned this Apr 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Apr 3, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review April 3, 2026 09:29
@vincentkoc
vincentkoc requested a review from a team as a code owner April 3, 2026 09:29
@greptile-apps

greptile-apps Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR wires models.providers.*.request transport overrides (headers, auth, proxy, TLS) end-to-end: schema definition, Zod validation, three model-resolution call sites, runtime SecretRef collectors, and an 11-entry target-registry expansion. It also host-gates OpenRouter attribution headers to native/default endpoints so custom proxy baseUrl routes no longer inherit them.

All changes are backed by targeted unit tests covering schema acceptance, runtime secret resolution, snapshot redaction, exec-ref parity, and attribution policy. No breaking changes to existing config surfaces.

Confidence Score: 5/5

Safe to merge — all new surfaces are additive, backward-compatible, and covered by targeted tests.

All changes are either schema additions (new optional field on ModelProviderConfig), a clean hoist of existing schema definitions, or well-understood bug fixes (OpenRouter attribution host-gating). The runtime secret collector correctly removes the early continue and adds the parallel request path. Eleven new target-registry entries match the schema and use the correct providerIdPathSegmentIndex. Tests cover schema acceptance, runtime resolution, redaction, exec-ref parity, and attribution policy. No P0/P1 findings.

No files require special attention.

Reviews (1): Last reviewed commit: "Merge branch 'main' into refactor/provid..." | Re-trigger Greptile

@vincentkoc
vincentkoc force-pushed the refactor/provider-request-surface branch from 2c93d92 to 759399d Compare April 3, 2026 09:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c93d922f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/pi-embedded-runner/model.ts Resolved
@vincentkoc
vincentkoc merged commit 61f1317 into main Apr 3, 2026
26 of 49 checks passed
@vincentkoc
vincentkoc deleted the refactor/provider-request-surface branch April 3, 2026 10:00
steipete pushed a commit to duncanita/openclaw that referenced this pull request Apr 4, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
Lianjinfeng123 pushed a commit to Lianjinfeng123/openclaw that referenced this pull request Apr 6, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
* feat(providers): add model request transport overrides

* chore(providers): finalize request override follow-ups

* fix(providers): narrow model request overrides
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant