4.1 KiB
4.1 KiB
summary, read_when
| summary | read_when | ||
|---|---|---|---|
| Proposal: model config, auth profiles, and fallback behavior |
|
Model config proposal
Goals
- Multi OAuth + multi API key per provider
- Model selection via
/modelwith sensible fallback - Global (not per-session) fallback logic
- Keep last-known-good auth profile when switching models
- Profile override only when explicitly requested
- Image routing override only when explicitly configured
Non-goals (v1)
- Auto-discovery of provider capabilities beyond catalog input tags
- Per-model auth profile order (see open questions)
Proposed config shape
{
"auth": {
"profiles": {
"anthropic:default": {
"provider": "anthropic",
"mode": "oauth"
},
"anthropic:work": {
"provider": "anthropic",
"mode": "api_key"
},
"openai:default": {
"provider": "openai",
"mode": "oauth"
}
},
"order": {
"anthropic": ["anthropic:default", "anthropic:work"],
"openai": ["openai:default"]
}
},
"agent": {
"models": {
"anthropic/claude-opus-4-5": {
"alias": "Opus"
},
"openai/gpt-5.2": {
"alias": "gpt52"
}
},
"model": {
"primary": "anthropic/claude-opus-4-5",
"fallbacks": ["openai/gpt-5.2"]
},
"imageModel": {
"primary": "openai/gpt-5.2",
"fallbacks": ["anthropic/claude-opus-4-5"]
}
}
}
Notes
- Canonical model keys are full
provider/model. aliasoptional; used by/modelresolution.auth.profilesis keyed. Default CLI login createsprovider:default.auth.order[provider]controls rotation order for that provider.
CLI / UX
Login
clawdbot login anthropic→ create/replaceanthropic:default.clawdbot login anthropic --profile work→ create/replaceanthropic:work.
Model selection
/model Opus→ resolve alias to full id./model anthropic/claude-opus-4-5→ explicit.- Optional:
/model Opus@anthropic:work(explicit profile override for session only).
Model listing
/modellist shows:- model id
- alias
- provider
- auth order (from
auth.order) - auth source for the current provider (auth-profiles.json/env/shell env/models.json)
Fallback behavior (global)
Fallback list
- Use
agent.model.fallbacksglobally. - No per-session fallback list; last-known-good is per-session but uses global ordering.
Auth profile rotation
- If provider auth error (401/403/invalid refresh):
- advance to next profile in
auth.order[provider]. - if all fail, fall back to next model.
- advance to next profile in
Rate limiting
- If rate limit / quota error:
- rotate auth profile first (same provider)
- if still failing, fall back to next model.
Model not found / capability mismatch
- immediate model fallback.
Image routing
Rule
- Only use
agent.imageModelwhen explicitly configured. - If
agent.imageModelis configured and the current text model lacks image input, use it.
Support detection
- From model catalog
inputtags when available (e.g.imagein models.json). - If unknown: treat as text-only and use
agent.imageModel.
Migration (doctor + gateway auto-run)
Inputs
- Legacy keys (pre-migration):
agent.model(string)agent.modelFallbacks(string[])agent.imageModel(string)agent.imageModelFallbacks(string[])agent.allowedModels(string[])agent.modelAliases(record)
Outputs
agent.modelsmap with keys for all referenced modelsagent.model.primary/fallbacksagent.imageModel.primary/fallbacks- Auth profile store seeded from current auth-profiles.json/auth.json + oauth.json + env (as
provider:default) auth.orderseeded with["provider:default"]when config is updated
Auto-run
- Gateway start detects legacy keys and runs doctor migration.
Decisions
- Auth order is per-provider (
auth.order). - Doctor migration is required; gateway will auto-run on startup when legacy keys detected.
/model Opus@profileis explicit session override only.- Image routing override only when
agent.imageModelis explicitly configured.