← Back to PRs

#16766: fix(model): apply provider baseUrl/headers override to registry-found models

by dzianisv open 2026-02-15 02:55 View on GitHub →
docs scripts agents stale size: L
## Summary - Fix `resolveModel()` ignoring `cfg.models.providers[provider].baseUrl` for models found in pi-ai's built-in `ModelRegistry` - Users configuring a proxy URL for a known provider (e.g. `anthropic`) had it silently ignored — the hardcoded `baseUrl` (e.g. `https://api.anthropic.com`) was always used - Now applies `baseUrl` and `headers` overrides from provider config after registry lookup ## Changes **`src/agents/pi-embedded-runner/model.ts`** (18 lines added) - After registry lookup succeeds (line 228), check `cfg.models.providers[provider]` for overrides - Apply `baseUrl` override if present (proxy support) - Merge `headers` from provider config onto the model **`src/agents/pi-embedded-runner/model.test.ts`** (107 lines added) - `applies provider baseUrl override to registry-found models` — verifies configured baseUrl replaces built-in - `applies provider headers override to registry-found models` — verifies custom headers are applied - `does not override baseUrl when no provider config exists` — verifies no regression ## Test Results All 31 model-related tests pass (17 in model.test.ts + 14 in model-compat/model-selection): ``` ✓ src/agents/pi-embedded-runner/model.test.ts (17 tests) ✓ src/agents/model-compat.test.ts (3 tests) ✓ src/agents/model-selection.test.ts (11 tests) Test Files: 3 passed (3) Tests: 31 passed (31) ``` ## Checklist - [x] Tests added covering the fix - [x] All existing tests pass - [x] No new type errors introduced (25 pre-existing ui/ rootDir errors unchanged) - [x] Linter passes (biome: 0 warnings, 0 errors) <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR makes three categories of changes: **1. Provider baseUrl/headers override for registry models (core fix):** Fixes `resolveModel()` to apply `cfg.models.providers[provider].baseUrl` and `headers` overrides to models found in pi-ai's built-in `ModelRegistry`. Previously, users configuring a proxy URL for a known provider (e.g. Anthropic) had it silently ignored. The fix adds a post-registry-lookup override step that shallow-copies the model and applies the configured overrides. Tests are thorough and cover the key scenarios. **2. Azure OpenAI support:** Adds `azure-openai-responses` as a new `ModelApi` type in the type system, Zod schema, transcript policy, and session history sanitization. The actual adapter implementation is delegated to the pi-ai library. New documentation is provided but has an issue (see comment). **3. Kubernetes deployment manifests and scripts:** Adds k8s manifests (`deployment.yaml`, `service.yaml`, `pvc.yaml`, `ingress.yaml`, `secret.yaml`), a deploy script, and a VM bootstrap script for self-hosted deployment. - The core model override fix is well-implemented with proper test coverage - The Azure OpenAI documentation references environment variables (`AZURE_OPENAI_RESOURCE_NAME`, etc.) that are not handled by OpenClaw source code, and the "environment-only" config example omits the required `baseUrl` field which will cause Zod validation errors <h3>Confidence Score: 3/5</h3> - The core model override fix is correct and well-tested, but the Azure OpenAI documentation has a config validation issue that would affect users. - Score of 3 reflects that while the core fix (provider baseUrl/headers override) is solid with good test coverage, the Azure OpenAI documentation contains a config example that will fail Zod validation (missing required `baseUrl`) and references environment variables not handled by the codebase. The k8s manifests and scripts are standard and low-risk. No runtime issues in the TypeScript code. - Pay close attention to `docs/providers/azure-openai.md` — the environment-only config example is missing the required `baseUrl` field and references env vars not implemented in the codebase. <sub>Last reviewed commit: def5506</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs