0xPlaygrounds / 0xPlaygrounds/rig
feat(openrouter): model fallbacks and routed-model exposure
- Lingua principale
- Rust
- Stelle
- 8.6k
- Fork
- 959
- Merge medio
- 4h 32m
- PR unite (30g)
- 117
Descrizione
## Summary
Add typed OpenRouter model fallback routing via a `ModelFallbacks` helper and expose the provider-reported routed model through completion, streaming, and agent response surfaces.
## Motivation
OpenRouter supports a `models` fallback array for chat completions. Rig currently has no typed API for this (unlike `ProviderPreferences`), and the response `model` field (which may differ from the requested primary when fallbacks fire) is not surfaced to generic callers or agent `.prompt()` users.
## Proposed scope
- `ModelFallbacks::new([...])`, `to_json()`, and `CompletionModel::with_model_fallbacks()`
- Serialize `{ "model": "", "models": ["", ...] }` with documented precedence rules
- Populate `CompletionResponse.response_model` and propagate to agent `CompletionCall` / `PromptResponse` / streaming `FinalResponse`
- Unit tests for serialization/precedence; ignored live smoke tests for OpenRouter
Embeddings/transcription fallbacks are out of scope.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Look for the OpenRouter provider implementation and the CompletionModel struct. The work involves adding a ModelFallbacks helper, integrating it with CompletionModel::with_model_fallbacks, and ensuring the response model field is propagated through CompletionResponse and agent surfaces like PromptResponse. Check existing tests for serialization patterns and add unit tests for the new fallback logic. A live smoke test for OpenRouter should be marked as ignored.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- ai-infra-agents, backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 65/100