mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-15 14:22:43 +00:00
fix(agent): reapply provider headers after model switch
switch_model() rebuilds _client_kwargs from scratch (api_key + base_url) but does not call _apply_client_headers_for_base_url(), so provider- specific headers like OpenRouter HTTP-Referer and X-Title are lost. Subsequent requests show "Unknown" in OpenRouter dashboard logs. Call _apply_client_headers_for_base_url() after rebuilding _client_kwargs and before creating the new client. Fixes #61099
This commit is contained in:
parent
a801046669
commit
0a4b4d6df5
1 changed files with 5 additions and 0 deletions
|
|
@ -1953,6 +1953,11 @@ def switch_model(agent, new_model, new_provider, api_key='', base_url='', api_mo
|
|||
_sm_timeout = get_provider_request_timeout(agent.provider, agent.model)
|
||||
if _sm_timeout is not None:
|
||||
agent._client_kwargs["timeout"] = _sm_timeout
|
||||
# Reapply provider-specific headers (e.g. OpenRouter HTTP-Referer,
|
||||
# X-Title) that were lost when _client_kwargs was rebuilt from
|
||||
# scratch. Without this, model switches clear attribution headers
|
||||
# and OpenRouter logs show "Unknown" for subsequent requests.
|
||||
agent._apply_client_headers_for_base_url(effective_base)
|
||||
agent.client = agent._create_openai_client(
|
||||
dict(agent._client_kwargs),
|
||||
reason="switch_model",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue