Skip to content

feat(providers): add Baseten Model APIs preset - #653

Open
olddonkey wants to merge 1 commit into
lidge-jun:devfrom
olddonkey:codex/572-baseten-model-apis
Open

feat(providers): add Baseten Model APIs preset#653
olddonkey wants to merge 1 commit into
lidge-jun:devfrom
olddonkey:codex/572-baseten-model-apis

Conversation

@olddonkey

@olddonkey olddonkey commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add baseten as a first-class API-key preset for the shared Baseten Model APIs endpoint at https://inference.baseten.co/v1.
  • Enable bounded live /models discovery through the contract in feat(providers): add bounded model discovery contract #652, with a 1 MiB response limit, a 256-row limit, and same-named custom-provider destination preservation.
  • Preserve provider-native model IDs, including embedded slashes, while supporting the existing flattened Codex selector aliases.
  • Add conservative, officially documented per-model reasoning and input-modality metadata without advertising unverified capabilities.
  • Add fixture-only provider tests and synchronized provider documentation across all maintained locales.

This PR is a pilot provider consumer under umbrella issue #572. The umbrella issue must remain open for the remaining provider batches.

Dependency And Review Order

This is stacked on #652 and targets dev. Until #652 merges, GitHub will show both the contract commit and the Baseten commit in this PR. The Baseten-specific change is the final commit in this stack; after #652 merges, the PR diff will automatically reduce to that provider commit.

Scope

  • Covers Baseten shared Model APIs using OpenAI-compatible bearer-key authentication.
  • Excludes dedicated Truss model and chain predict endpoints, which use different hosts, authentication, and arbitrary schemas.
  • Does not add Baseten OAuth; that would be a separate authentication and token-storage security scope.
  • Documents personal keys for local use and appropriately scoped team keys for shared or production use.

Security

This adds a credential-bearing provider preset. It uses the contract's redirect denial and preserveCustomDestination protection, does not persist discovery trust policy, and introduces no key logging. Explicit maintainer security review is requested before merge.

Verification

  • bun run typecheck
  • Contract full suite after review fixes: 5,743 passed, 1 skipped, 0 failed across 418 test files
  • Stacked Baseten, discovery-contract, registry-parity, and connection-probe integration: 69 passed, 0 failed
  • bun run privacy:scan
  • bun run lint:gui
  • Docs Astro build: 141 pages

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. Maintainer security review is explicitly requested.

Summary by CodeRabbit

  • New Features

    • Added Baseten Model APIs as a built-in provider preset.
    • Expanded the built-in provider/preset catalog to 61 presets.
    • Introduced trusted, provider-specific live model discovery with eligibility filtering and bounded parsing (including richer model metadata like capabilities).
  • Bug Fixes

    • Prevented oversized, malformed, or invalid discovery responses from being cached or silently truncated.
    • Improved transport-aware registry behavior and strengthened same-name fixed-preset destination preservation.
    • Hardened model listing and API-key validation by deriving discovery endpoints more safely and blocking unexpected redirects.
  • Documentation

    • Updated quickstart, providers, and configuration reference (all supported languages), including Baseten scope/permissions and discovery/allowlist limits.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds bounded, registry-driven provider model discovery, transport-aware registry matching, and the Baseten Model APIs preset. It integrates discovery into catalog loading, API-key validation, routing, management probes, tests, and multilingual documentation.

Changes

Provider discovery and registry integration

Layer / File(s) Summary
Registry contracts and Baseten preset
src/providers/registry.ts, src/codex/catalog/parsing.ts
Adds typed discovery policies, transport matching, collision preservation, normalized capabilities, and the Baseten registry configuration.
Bounded discovery parsing and catalog enrichment
src/providers/model-discovery.ts, src/codex/catalog/provider-fetch.ts
Adds bounded JSON handling, URL resolution, predicate filtering, row validation, deduplication, and richer provider metadata normalization.
Discovery-aware requests and transport-gated behavior
src/oauth/..., src/providers/derive.ts, src/router.ts, src/server/...
Uses resolved discovery URLs for model requests and validation, rejects redirects, and applies registry data only when configured transports match.
Baseten and discovery contract verification
tests/baseten-provider.test.ts, tests/provider-model-discovery-contract.test.ts, tests/provider-connection-test.test.ts, tests/fixtures/*, tests/umans-provider.test.ts, tests/codex-catalog.test.ts, tests/provider-registry-parity.test.ts
Adds Baseten routing and metadata tests, bounded discovery edge-case coverage, fixtures, connectivity-probe assertions, and updated validation callers.
Runtime and localized documentation
structure/01_runtime.md, docs-site/src/content/docs/**
Documents live discovery limits, fallback behavior, collision preservation, updated preset counts, and Baseten Model APIs across supported locales.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: wibias, ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding the Baseten Model APIs provider preset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the enhancement New feature or request label Jul 29, 2026
@olddonkey
olddonkey marked this pull request as ready for review July 29, 2026 00:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs-site/src/content/docs/ru/reference/configuration.md (1)

166-166: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Russian docs missing the new collision-preservation baseUrl behavior that zh-cn received.

docs-site/src/content/docs/zh-cn/reference/configuration.md was updated in this same PR (lines 138 and 184-190) to document that newly-added, collision-protected fixed API-key presets (like Baseten) preserve an existing same-named custom provider's baseUrl/adapter instead of redirecting it to the new registry host. This Russian page's baseUrl row (line 166) and its "fixed provider endpoints" section (unchanged lines 209-278) were not updated to match, leaving ru readers with an incomplete/outdated description of baseUrl override precedence — directly contradicting the path-instruction requirement that "translated locale pages ... are not left contradicting the English source."

As per path instructions, docs-site/** guidance requires that "translated locale pages (ja, ko, ru, zh-cn) are not left contradicting the English source."

📝 Suggested ru addition (adapt zh-cn wording)
-| `baseUrl` | `string` | Базовый URL вышестоящего API. |
+| `baseUrl` | `string` | Базовый URL вышестоящего API. Большинство встроенных provider с фиксированными конечными точками игнорируют несовпадающий адрес; новые пресеты с ключевой аутентификацией, включающие защиту от коллизий, сохраняют цель ранее существовавшего custom provider с тем же именем. См. [Фиксированные конечные точки провайдера](`#фиксированные-конечные-точки-провайдера`). |

And extend the "fixed endpoint" section (wherever it lives in the unchanged 209-278 range) with a fourth bullet mirroring zh-cn lines 189-190.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs-site/src/content/docs/ru/reference/configuration.md` at line 166, Update
the Russian configuration documentation to match the English and zh-cn
descriptions of collision-protected fixed API-key presets: clarify in the
baseUrl documentation that an existing same-named custom provider preserves its
baseUrl and adapter, then add the corresponding fourth bullet to the fixed
provider endpoints section. Keep the wording consistent with the existing
Russian terminology and zh-cn guidance.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/guides/providers.md`:
- Around line 222-226: Remove the blank line inside the synchronized Baseten
blockquotes at docs-site/src/content/docs/guides/providers.md lines 222-226,
docs-site/src/content/docs/ja/guides/providers.md lines 156-160, and
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, keeping each
blockquote contiguous.

In `@docs-site/src/content/docs/ru/getting-started/quickstart.md`:
- Around line 16-17: Update the provider-selection sentence to use the correct
Russian numeral agreement, changing “один из 61 встроенного пресета” to “один из
61 встроенных пресетов” while preserving the rest of the quickstart content.

In `@src/providers/model-discovery.ts`:
- Around line 273-280: Add documentation to the predicate union declaration in
the registry module describing the `containsAny` and `containsAll` semantics:
string upstream values use substring matching, while array values use exact
element matching. Keep the existing comparison behavior in the `containsAny` and
`containsAll` branches of model discovery unchanged; only make this contract
clear for registry authors.

---

Outside diff comments:
In `@docs-site/src/content/docs/ru/reference/configuration.md`:
- Line 166: Update the Russian configuration documentation to match the English
and zh-cn descriptions of collision-protected fixed API-key presets: clarify in
the baseUrl documentation that an existing same-named custom provider preserves
its baseUrl and adapter, then add the corresponding fourth bullet to the fixed
provider endpoints section. Keep the wording consistent with the existing
Russian terminology and zh-cn guidance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6f2e0626-310e-41e7-b32d-b92ab1438d20

📥 Commits

Reviewing files that changed from the base of the PR and between ca7b104 and 9cdb84c.

📒 Files selected for processing (35)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-cn/reference/configuration.md
  • src/codex/catalog/parsing.ts
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/oauth/key-providers.ts
  • src/oauth/login-cli.ts
  • src/providers/derive.ts
  • src/providers/model-discovery.ts
  • src/providers/registry.ts
  • src/router.ts
  • src/server/auth-cors.ts
  • src/server/management/provider-routes.ts
  • src/server/management/shared.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/codex-catalog.test.ts
  • tests/fixtures/baseten-models.json
  • tests/fixtures/provider-model-discovery.json
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts
  • tests/umans-provider.test.ts

Comment thread docs-site/src/content/docs/guides/providers.md
Comment thread docs-site/src/content/docs/ru/getting-started/quickstart.md
Comment thread src/providers/model-discovery.ts
@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch 2 times, most recently from 7faf2e4 to 124f427 Compare July 29, 2026 05:02

Copy link
Copy Markdown
Contributor Author

Review follow-up for the outside-diff Russian collision-preservation finding: that review was anchored to the old 9cdb84c3 head. The current stacked head includes 4e8e7d5 from #652, which already updates the Russian baseUrl row, adds the fixed-provider-endpoints section, and documents the same-named custom-provider preservation case. No additional code or documentation change is needed for that item.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/codex/catalog/provider-fetch.ts (1)

219-239: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prioritize canonical capability flags before truncation.

If capabilities/features already contributes 32 values, the later supports_tools and supports_reasoning additions are removed by slice(0, 32). A valid upstream boolean can therefore be omitted from the catalog. Add canonical flags before untrusted labels, or cap generic additions while reserving capacity.

Proposed fix
 function modelCapabilities(item: ProviderModelsApiItem): string[] | undefined {
   const metadata = plainRecord(item.metadata);
   const metadataCapabilities = metadata?.capabilities;
   const capabilityRecord = plainRecord(metadataCapabilities) ?? plainRecord(item.capabilities);
   const out = new Set<string>();
+  for (const field of ["supports_tools", "supports_tool_calling", "supports_function_calling"] as const) {
+    if (item[field] === true) out.add("tools");
+  }
+  for (const field of ["supports_reasoning", "reasoning"] as const) {
+    if (item[field] === true) out.add("reasoning");
+  }
   for (const list of [item.capabilities, item.features, item.supported_features, metadataCapabilities]) {
-    for (const capability of normalizedStringList(list) ?? []) out.add(capability);
+    for (const capability of normalizedStringList(list) ?? []) {
+      if (out.size >= 32) break;
+      out.add(capability);
+    }
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/codex/catalog/provider-fetch.ts` around lines 219 - 239, Update the
capability aggregation flow so canonical boolean-derived values from
supports_tools/supports_tool_calling/supports_function_calling and
supports_reasoning/reasoning are added before generic capabilities and metadata
labels. Preserve the 32-value limit while ensuring these canonical “tools” and
“reasoning” values are retained when present, then add untrusted labels only
with remaining capacity.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/ja/guides/providers.md`:
- Around line 156-160: Remove the blank separator between the consecutive
Baseten and Tencent blockquotes in
docs-site/src/content/docs/ja/guides/providers.md lines 156-160 and
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, keeping the
blockquote lines contiguous to satisfy markdownlint MD028.

---

Outside diff comments:
In `@src/codex/catalog/provider-fetch.ts`:
- Around line 219-239: Update the capability aggregation flow so canonical
boolean-derived values from
supports_tools/supports_tool_calling/supports_function_calling and
supports_reasoning/reasoning are added before generic capabilities and metadata
labels. Preserve the 32-value limit while ensuring these canonical “tools” and
“reasoning” values are retained when present, then add untrusted labels only
with remaining capacity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a890a1e3-1a47-4f3d-a121-0a23983f7ff4

📥 Commits

Reviewing files that changed from the base of the PR and between 9cdb84c and 124f427.

📒 Files selected for processing (24)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/providers/registry.ts
  • src/server/management/provider-routes.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/fixtures/baseten-models.json
  • tests/provider-connection-test.test.ts
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts

@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch from 124f427 to f345775 Compare July 29, 2026 07:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/ja/guides/providers.md`:
- Around line 156-160: Remove the blank separator between consecutive blockquote
paragraphs in docs-site/src/content/docs/ja/guides/providers.md lines 156-160,
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, and
docs-site/src/content/docs/ru/guides/providers.md lines 167-171, preserving the
separate blockquote paragraphs.

In `@structure/01_runtime.md`:
- Around line 80-81: Update the discovery-limit guidance in
structure/01_runtime.md lines 80-81,
docs-site/src/content/docs/ru/reference/configuration.md lines 330-334, and
docs-site/src/content/docs/zh-cn/reference/configuration.md lines 287-290 to
state the generic 4 MiB response and 2,000 raw-row defaults, plus the Baseten
preset overrides of 1 MiB and 256 models at every site. Keep all translated
pages synchronized with the runtime behavior.

In `@tests/baseten-provider.test.ts`:
- Around line 273-280: Update the adapter-mismatch test around routeModel and
basetenConfig so it supplies a non-canonical custom baseUrl while retaining
adapter: "anthropic". Assert that customAdapter preserves this destination,
ensuring registry retargeting cannot pass the test by leaving the canonical URL
unchanged; keep the existing provider and authMode assertions.
- Around line 217-225: Update the registry assertion’s reasoning configuration
in the toMatchObject block around noReasoningModels or the model-specific
reasoning map to explicitly include moonshotai/Kimi-K2.6. Ensure the existing
Kimi request assertion in the Kimi route test is backed by that registry entry
and continues suppressing reasoning_effort.

In `@tests/provider-model-discovery-contract.test.ts`:
- Around line 34-69: Ensure discovery-cache cleanup is uniform across temporary
registry mutations. In tests/provider-model-discovery-contract.test.ts lines
34-69, update withRegistryDiscovery to call clearModelCache(providerId) in
finally and export the shared helper as needed; in
tests/provider-connection-test.test.ts lines 153-182, replace the inline
together discovery mutate/restore logic with that helper so the temporary state
is restored and cached rows are cleared before subsequent probes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a4308713-4f36-49b7-adae-bd345c8a28b0

📥 Commits

Reviewing files that changed from the base of the PR and between 124f427 and f345775.

📒 Files selected for processing (36)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-cn/reference/configuration.md
  • src/codex/catalog/parsing.ts
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/oauth/key-providers.ts
  • src/oauth/login-cli.ts
  • src/providers/derive.ts
  • src/providers/model-discovery.ts
  • src/providers/registry.ts
  • src/router.ts
  • src/server/auth-cors.ts
  • src/server/management/provider-routes.ts
  • src/server/management/shared.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/codex-catalog.test.ts
  • tests/fixtures/baseten-models.json
  • tests/fixtures/provider-model-discovery.json
  • tests/provider-connection-test.test.ts
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts
  • tests/umans-provider.test.ts

Comment thread docs-site/src/content/docs/ja/guides/providers.md
Comment thread structure/01_runtime.md
Comment thread tests/baseten-provider.test.ts
Comment thread tests/baseten-provider.test.ts
Comment thread tests/provider-model-discovery-contract.test.ts
@Wibias Wibias linked an issue Jul 29, 2026 that may be closed by this pull request
3 tasks
@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch from f345775 to 879efb2 Compare July 29, 2026 17:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/server/auth-cors.ts (1)

179-182: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the shared admin-token resolver.

Line 179 accepts only the environment token, while src/oauth/login-cli.ts Line 13 sends the file-backed fallback from configuredAdminToken(). With no OPENCODEX_ADMIN_AUTH_TOKEN but a configured token file, proxy-update requests send a token the server rejects. Delegate this helper to configuredAdminToken() and add a file-only-token regression test.

Proposed fix
+import { configuredAdminToken } from "../lib/admin-secrets";
+
 export function configuredAdminAuthToken(): string | undefined {
-  const token = process.env.OPENCODEX_ADMIN_AUTH_TOKEN?.trim();
-  return token || undefined;
+  return configuredAdminToken() ?? undefined;
 }

As per path instructions, “A behavior change in src/ should come with a focused regression test near the existing tests for that subsystem.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/server/auth-cors.ts` around lines 179 - 182, Update
configuredAdminAuthToken() to delegate to the shared configuredAdminToken()
resolver so environment and file-backed tokens use identical precedence. Add a
focused regression test near the existing auth/CORS tests covering a configured
token file when OPENCODEX_ADMIN_AUTH_TOKEN is absent, and assert that the file
token is returned.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/zh-cn/guides/providers.md`:
- Around line 147-151: Update the Baseten Truss sentence in the Chinese provider
documentation to describe dedicated predict endpoints as using different hosts
and request schemas/formats, not different protocols. Preserve the surrounding
wording and keep the blank separator before the Tencent callout unchanged.

In `@src/providers/model-discovery.ts`:
- Around line 87-93: Update the path validation in the spec.path guard to reject
any path segment equal to "..", including repeated or embedded traversal
segments such as "../../internal/models". Preserve acceptance of ordinary
relative paths like "models" and the existing scheme, protocol-relative, query,
fragment, and length checks.

---

Outside diff comments:
In `@src/server/auth-cors.ts`:
- Around line 179-182: Update configuredAdminAuthToken() to delegate to the
shared configuredAdminToken() resolver so environment and file-backed tokens use
identical precedence. Add a focused regression test near the existing auth/CORS
tests covering a configured token file when OPENCODEX_ADMIN_AUTH_TOKEN is
absent, and assert that the file token is returned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bb92fa4f-53dd-4d98-9d51-77b07ecba819

📥 Commits

Reviewing files that changed from the base of the PR and between f345775 and 879efb2.

📒 Files selected for processing (36)
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-cn/reference/configuration.md
  • src/codex/catalog/parsing.ts
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/oauth/key-providers.ts
  • src/oauth/login-cli.ts
  • src/providers/derive.ts
  • src/providers/model-discovery.ts
  • src/providers/registry.ts
  • src/router.ts
  • src/server/auth-cors.ts
  • src/server/management/provider-routes.ts
  • src/server/management/shared.ts
  • structure/01_runtime.md
  • tests/baseten-provider.test.ts
  • tests/codex-catalog.test.ts
  • tests/fixtures/baseten-models.json
  • tests/fixtures/provider-model-discovery.json
  • tests/provider-connection-test.test.ts
  • tests/provider-model-discovery-contract.test.ts
  • tests/provider-registry-parity.test.ts
  • tests/umans-provider.test.ts

Comment thread docs-site/src/content/docs/zh-cn/guides/providers.md
Comment thread src/providers/model-discovery.ts
@lidge-jun

Copy link
Copy Markdown
Owner

Status after the prerequisite landed: #652 is merged (48f2e8362), so the discovery contract no longer blocks this PR.

I reran the failing Windows job and looked at what it actually reported. The rerun came back cancelled at 12m05s, not failed:

job 90733427766   conclusion: cancelled
started 23:11:50Z   completed 23:23:55Z   (12m05s)
Test: cancelled     later steps: skipped

That is the test job hitting timeout-minutes: 12, which gh pr checks renders as fail. It is not this preset failing. I filed #717 with the run-by-run evidence — the last green Windows run took 11 minutes against the 12-minute ceiling, and every dev run after it was cancelled too, so this is repository-wide rather than specific to #653.

Your code checks out locally on my side:

bun test tests/baseten*.test.ts tests/provider-registry-parity.test.ts tests/model-discovery-contract.test.ts
  38 pass / 0 fail
bun x tsc --noEmit   clean

So this is waiting on CI capacity, not on a change from you. Two things worth doing when you get a chance:

  1. Rebase onto current dev. feat(providers): add bounded model discovery contract #652 has landed, and rebasing lets the discovery contract you build on be the merged version rather than the PR-branch version. Worth re-checking whether any modelDiscovery declaration here should now use a lower per-provider limit from the merged contract instead of a local constant.
  2. Nothing else — once CI: windows-latest test job cancelled at the 12-minute ceiling, reported as a failing check #717 is sorted and CI can finish, this should go green as-is.

One note for the remaining batches in #572: the first failure on this PR was a genuine Test failure before the rerun, so please do not read this comment as "Windows failures are always timeouts." The distinction is in gh api repos/lidge-jun/opencodex/commits/<sha>/check-runsconclusion: failure means look at the logs, conclusion: cancelled means the job ran out of time.

lidge-jun added a commit that referenced this pull request Jul 30, 2026
The `test` job ran with `timeout-minutes: 12` while a green Windows run
takes 11.8 minutes, leaving about 12 seconds of margin. Runner variance,
not the code under review, decided the outcome: PR #711's rerun finished
at 11.8min and passed, PR #653's was killed at 12.0min with `Test`
cancelled and every later step skipped.

That flakiness is expensive to review around, because `gh pr checks`
renders a cancelled job as `fail`. A red Windows check could mean a real
failure, a `cancel-in-progress` concurrency cancel, or this timeout, and
telling them apart requires reading `conclusion` from the check-runs API
plus per-job timings.

Measured on run 30459554635 (same suite, same commit):

  ubuntu-latest    4.6 min
  macos-latest     5.6 min
  windows-latest  11.8 min

20 minutes keeps a green Windows run green with margin. It does not
address why Windows needs ~2.5x Linux on an identical suite; the comment
says so explicitly, because the ceiling has already been raised once
(8 -> 12) for this same reason and chasing it again is not a fix. The
`npm-global-smoke` job is untouched at 8 minutes: it completes in 1-2
minutes and was never near its limit.

Refs #717
@olddonkey
olddonkey force-pushed the codex/572-baseten-model-apis branch from 879efb2 to fe283d6 Compare July 30, 2026 06:29

Copy link
Copy Markdown
Contributor Author

Review follow-up is complete for the current head (7e0f7793):

  • Baseten-scoped fixes are on this PR, including exact Kimi reasoning allowlist assertions, a non-tautological custom-destination test, zh-CN wording, and documented 1 MiB / 256-row discovery limits across maintained locales.
  • Shared contract hardening was intentionally split into fix(providers): harden discovery contract cleanup #743 now that feat(providers): add bounded model discovery contract #652 is merged. It covers .. path-segment rejection plus deterministic registry/cache cleanup in tests.
  • I did not apply the out-of-diff auth-cors.ts suggestion because its reported failure mode does not exist: file-backed admin tokens are loaded into management auth state and accepted by requireManagementAuth, while their required ocx_admin_... format is already blocked from provider forwarding by the proxy-admission secret prefix guard.

Local verification for this PR: typecheck, privacy scan, focused tests, docs build, and the full suite all pass (6036 pass / 2 skip / 0 fail).

Copy link
Copy Markdown
Contributor Author

CI note: the only remaining red check is the Windows matrix job. Its single failure is unrelated to this PR's diff: storage-mutation-race.test.ts completed the test body, then Windows failed to remove its temporary directory with EBUSY: resource busy or locked during teardown. The same job passed 6033 tests, and Ubuntu/macOS plus both npm-global Windows checks are green.

I attempted both the single-job and failed-jobs rerun APIs, but GitHub requires upstream repository admin rights for this run. A maintainer will need to re-run the failed Windows job: https://github.com/lidge-jun/opencodex/actions/runs/30522540376/job/90805964297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Provider] Promote a verified batch of OpenAI-compatible inference providers

2 participants