Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

feat(opencode): allow changing model mid-session

Aperta
#143 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
ai, api, backend

Direzione di ricerca

Start in opencode_compat.rs, especially resolve_session_agent(), set_session_overrides(), and the runtime update path shown in the issue. Trace how SessionMessageRequest.model is resolved and how the backing agent process is managed; done means a mid-session model change updates the runtime, handles unsupported native switching, and exposes the change to the frontend.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

When an OpenCode session is created and the first message is sent, the agent/provider/model is locked into the session runtime context. Subsequent messages cannot change the provider or model because the runtime is only set on the first message:

state.opencode.update_runtime(session_id, |runtime| {
    if runtime.session_agent_id.is_none() {
        runtime.session_agent_id = Some(agent);
        runtime.session_provider_id = Some(provider_id);
        runtime.session_model_id = Some(model_id);
    }
});

While SessionMessageRequest accepts a model field on every message, the resolved model from the first message is reused for all subsequent messages. The set_session_overrides() function can update the SessionState, but the OpenCode runtime context does not reflect the change.

This means users cannot switch models mid-conversation (e.g., start with a fast model for simple tasks, then switch to a more capable model for complex reasoning).

Expected Behavior

Users should be able to change the model on any message within an existing session. When a model field is provided in SessionMessageRequest, it should override the session-level model for that message and update the session runtime accordingly.

Proposed Approach

  1. In resolve_session_agent() (opencode_compat.rs), update the runtime even when session_agent_id is already set, if the incoming message specifies a different model.
  2. When the model changes mid-session, terminate the existing backing agent process and start a new one with the updated model, or pass the model switch through to agents that support it natively.
  3. Emit a synthetic event (e.g., session.model_changed) so the frontend can reflect the model switch.
  4. Consider whether changing the agent (not just the model within the same agent) mid-session should also be supported, or scoped out for now.

Considerations

  • Some agents may not support model switching natively — the daemon may need to restart the backing process.
  • The PATCH /opencode/session/{sessionID} endpoint could also be extended to accept model changes, giving the frontend an explicit way to switch before sending the next message.
  • Need to decide how model changes interact with conversation history — the new model should still receive the full conversation context.
Lingua principale
TypeScript
Stelle
1.6k
Fork
131
Merge medio
7h 40m
PR unite (30g)
29

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rivet-dev/agents

Tutte le issue di rivet-dev/agents

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.