feat(runner): support fallback candidates
Resolve fallbackModels as preset references or explicit inline provider configs so failover uses complete model settings without exposing fallback logic to the agent loop. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+36
-1
@@ -672,7 +672,8 @@ Existing configs do not need to change. If you do not set `modelPresets` or `age
|
||||
"maxTokens": 8192,
|
||||
"contextWindowTokens": 128000,
|
||||
"temperature": 0.1,
|
||||
"modelPreset": null
|
||||
"modelPreset": "fast",
|
||||
"fallbackModels": ["deep"]
|
||||
}
|
||||
},
|
||||
"modelPresets": {
|
||||
@@ -708,6 +709,40 @@ Existing configs do not need to change. If you do not set `modelPresets` or `age
|
||||
|
||||
`default` is reserved and always means the implicit preset built from `agents.defaults.*`; do not define `modelPresets.default`. Use `/model default` to switch back to `agents.defaults.*`.
|
||||
|
||||
### Model Fallbacks
|
||||
|
||||
`agents.defaults.fallbackModels` defines an ordered failover chain for the active model configuration. The primary model is still selected by `agents.defaults.modelPreset` (or the implicit default config when no preset is active).
|
||||
|
||||
Each fallback candidate can be either:
|
||||
|
||||
- A preset name from `modelPresets`, such as `"deep"`. The preset's full model, provider, generation, and context-window config is used.
|
||||
- An inline fallback object with at least `provider` and `model`. Optional `maxTokens`, `contextWindowTokens`, and `temperature` fields inherit from the active primary config when omitted. `reasoningEffort` does not inherit; omit it to leave reasoning off for that fallback, or set it explicitly for models that support reasoning.
|
||||
|
||||
```json
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"modelPreset": "fast",
|
||||
"fallbackModels": [
|
||||
"deep",
|
||||
{
|
||||
"provider": "deepseek",
|
||||
"model": "deepseek-v4-pro",
|
||||
"maxTokens": 4096,
|
||||
"contextWindowTokens": 262144
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
String entries are preset names, not raw model names. If you want to use a model that is not already a preset, use the inline object form.
|
||||
|
||||
Failover only runs when the primary provider returns a retryable model/provider error before any answer text has been streamed. Typical fallback cases include timeouts, connection errors, 5xx server errors, 429 rate limits, overloads, and quota/balance exhaustion. It does not run for malformed requests, authentication/permission errors, content filtering/refusals, or context-length/message-format errors.
|
||||
|
||||
If fallback candidates use smaller `contextWindowTokens` values, nanobot builds context using the smallest window in the active chain so every candidate can receive the same prompt.
|
||||
|
||||
Set `agents.defaults.modelPreset` to start with a named preset:
|
||||
|
||||
```json
|
||||
|
||||
Reference in New Issue
Block a user