Skip to content

fix(models): inherit baseUrl and api from provider config#2740

Merged
gumadeiras merged 4 commits intoopenclaw:mainfrom
lploc94:fix/inherit-baseurl-api-from-provider
Jan 27, 2026
Merged

fix(models): inherit baseUrl and api from provider config#2740
gumadeiras merged 4 commits intoopenclaw:mainfrom
lploc94:fix/inherit-baseurl-api-from-provider

Conversation

@lploc94
Copy link
Contributor

@lploc94 lploc94 commented Jan 27, 2026

Summary

  • Fix bug where custom provider's baseUrl and api were not inherited by
    inline model definitions
  • Models now correctly use the provider's endpoint and API format

Problem

When configuring a custom provider with baseUrl and api at the provider
level:

"myProvider": {                                                                  
  "baseUrl": "http://localhost:10000",                                           
  "api": "anthropic-messages",                                                   
  "models": [{ "name": "claude-opus-4.5" }]                                      
}                                                                                
The individual models did not inherit these settings, causing requests to fail   
with 401 or be sent to wrong endpoints.                                          
                                                                                 
Test plan                                                                        
                                                                                 
- Lint passes (npm run lint)                                                     
- Unit tests pass (vitest run src/agents/pi-embedded-runner/model.test.ts)       
- Manual test with custom provider pointing to local server 

Copilot AI review requested due to automatic review settings January 27, 2026 11:57
@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Jan 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where custom provider configurations (baseUrl and api) were not being inherited by inline model definitions. When users configured a custom provider with these settings at the provider level, individual models within that provider would fail to inherit these configurations, causing requests to fail with 401 errors or be sent to incorrect endpoints.

Changes:

  • Updated buildInlineProviderModels to inherit baseUrl and api from provider configuration to inline models
  • Modified InlineModelEntry type to include baseUrl field
  • Updated resolveModel fallback model creation to include baseUrl from provider config

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +24
return (entry?.models ?? []).map((model) => ({
...model,
provider: trimmed,
baseUrl: entry?.baseUrl,
api: model.api ?? entry?.api,
}));
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The existing test for buildInlineProviderModels does not verify the new behavior introduced in this fix. The test should be updated to verify that baseUrl and api are correctly inherited from the provider configuration.

Consider adding a test case that verifies:

  1. baseUrl is inherited from the provider when models don't specify it
  2. api is inherited from the provider when models don't specify it
  3. Model-level api takes precedence over provider-level api when both are present

Copilot uses AI. Check for mistakes.
@lploc94 lploc94 force-pushed the fix/inherit-baseurl-api-from-provider branch from 2cd7dd0 to 79e4cf8 Compare January 27, 2026 12:08
@lploc94
Copy link
Contributor Author

lploc94 commented Jan 27, 2026

CI is failing due to the workspace dependency issue (clawdbot@workspace:* in extensions/googlechat). Waiting for #2739 to be merged, then I'll rebase this PR. The actual code changes pass lint and tests locally.

@gumadeiras gumadeiras self-requested a review January 27, 2026 21:33
lploc94 and others added 4 commits January 27, 2026 16:38
When using custom providers with inline model definitions, the baseUrl
and api properties from the provider config were not being passed to
the individual models. This caused requests to be sent to the wrong
endpoint or with the wrong API format.

Changes:
- buildInlineProviderModels now copies baseUrl from provider to models
- buildInlineProviderModels now inherits api from provider if not set on model
- resolveModel fallback path now includes baseUrl from provider config

Co-Authored-By: Claude (claude-opus-4.5) <noreply@anthropic.com>
Add test cases to verify:
- baseUrl is inherited from provider when model does not specify it
- api is inherited from provider when model does not specify it
- model-level api takes precedence over provider-level api
- both baseUrl and api can be inherited together

Co-Authored-By: Claude (claude-opus-4.5) <noreply@anthropic.com>
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
@gumadeiras gumadeiras force-pushed the fix/inherit-baseurl-api-from-provider branch from 79e4cf8 to db40dca Compare January 27, 2026 21:47
@gumadeiras gumadeiras merged commit 9b16a6b into openclaw:main Jan 27, 2026
21 of 23 checks passed
gumadeiras added a commit that referenced this pull request Jan 27, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
@gumadeiras
Copy link
Member

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: db40dca
  • Merge commit: 9b16a6b

Thanks @lploc94!

@lploc94 lploc94 deleted the fix/inherit-baseurl-api-from-provider branch January 28, 2026 15:41
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
bestNiu pushed a commit to bestNiu/clawdbot that referenced this pull request Feb 5, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
bestNiu pushed a commit to bestNiu/clawdbot that referenced this pull request Feb 5, 2026
julius2016 pushed a commit to julius2016/openclaw that referenced this pull request Feb 13, 2026
`buildInlineProviderModels()` reads `baseUrl` and `api` from the
provider config but omits `headers`. This causes custom HTTP headers
(e.g. User-Agent overrides) configured in `models.providers` to be
silently ignored for all chat/reply API requests.

The pi-ai Anthropic provider already supports `model.headers` via
`mergeHeaders()`, and the runner entry already reads
`providerConfig?.headers` — only the main reply path was missing it.

This is a follow-up to openclaw#2740 which fixed the same class of bug for
`baseUrl` but missed `headers`.

Fixes openclaw#15682
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Co-authored-by: lploc94 <lploc94@users.noreply.github.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants