fix(agent,gateway): don't overwrite ModelName with protocol-stripped modelID
Previously, after CreateProvider returned, the code would overwrite
cfg.Agents.Defaults.ModelName with modelID (the second return value).
The modelID is the protocol-stripped model identifier returned by
ExtractProtocol.
For example, if model_list has:
- model_name: "openrouter-free"
- model: "openrouter/free"
Then CreateProvider would return modelID="free" (after stripping the
"openrouter/" protocol), and the code would set ModelName="free".
This broke the fallback mechanism because:
1. The agent's Model field became "free" instead of "openrouter-free"
2. ParseModelRef("free", "openrouter") would create a candidate with
Provider="openrouter", Model="free"
3. When Chat() failed, the error would show provider=openrouter model=free
4. The actual model name "openrouter-free" was lost, breaking fallback
The fix is to NOT overwrite ModelName with modelID. The ModelName
should remain as the model_list entry name (like "openrouter-free")
for proper fallback resolution. The modelID is only used internally by
the provider implementation.
This fixes the issue where changing config and restarting gateway
wouldn't pick up the new model because the model name was being
overwritten with just the model ID part.
Fixes config changes not being applied after gateway restart.
This commit is contained in:
parent
8a1fb03974
commit
fb8617cfa9
2 changed files with 6 additions and 8 deletions
|
|
@ -42,10 +42,9 @@ func agentCmd(message, sessionKey, model string, debug bool) error {
|
|||
return fmt.Errorf("error creating provider: %w", err)
|
||||
}
|
||||
|
||||
// Use the resolved model ID from provider creation
|
||||
if modelID != "" {
|
||||
cfg.Agents.Defaults.ModelName = modelID
|
||||
}
|
||||
// Don't overwrite ModelName with modelID - modelID is just the protocol-stripped
|
||||
// model identifier, but ModelName should remain as the model_list entry name
|
||||
// for proper fallback resolution.
|
||||
|
||||
msgBus := bus.NewMessageBus()
|
||||
agentLoop := agent.NewAgentLoop(cfg, msgBus, provider)
|
||||
|
|
|
|||
|
|
@ -43,10 +43,9 @@ func gatewayCmd(debug bool) error {
|
|||
return fmt.Errorf("error creating provider: %w", err)
|
||||
}
|
||||
|
||||
// Use the resolved model ID from provider creation
|
||||
if modelID != "" {
|
||||
cfg.Agents.Defaults.ModelName = modelID
|
||||
}
|
||||
// Don't overwrite ModelName with modelID - modelID is just the protocol-stripped
|
||||
// model identifier, but ModelName should remain as the model_list entry name
|
||||
// for proper fallback resolution.
|
||||
|
||||
msgBus := bus.NewMessageBus()
|
||||
agentLoop := agent.NewAgentLoop(cfg, msgBus, provider)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue