aaif-goose/goose · error

Cannot resume with provider or model changes because provide

Error message

Cannot resume with provider or model changes because provider '{}' manages its own conversation context. Start a new session to use this provider or model.

What it means

You asked goose to resume an existing session while also changing the provider or model, but the session was created with a provider whose manages_own_context() is true (the claude_code and gemini_cli providers). Those providers store the conversation inside their own CLI backend, so goose has no transcript it can transplant into a different provider/model; resuming with a change is therefore refused. This also fires when no saved provider/model metadata exists but the session config explicitly sets one.

Source

Thrown at crates/goose-cli/src/session/builder.rs:253

fn validate_provider_override_context(
    session_config: &SessionBuilderConfig,
    saved_provider: Option<&str>,
    saved_model: Option<&str>,
    provider_name: &str,
    model_name: &str,
    provider_manages_own_context: bool,
) -> anyhow::Result<()> {
    let provider_changed = saved_provider
        .map(|saved| saved != provider_name)
        .unwrap_or_else(|| session_config.provider.is_some());
    let model_changed = saved_model
        .map(|saved| saved != model_name)
        .unwrap_or_else(|| session_config.model.is_some());

    if session_config.resume && provider_manages_own_context && (provider_changed || model_changed)
    {
        anyhow::bail!(
            "Cannot resume with provider or model changes because provider '{}' manages its own conversation context. Start a new session to use this provider or model.",
            provider_name
        );
    }

    Ok(())
}

async fn resolve_provider_and_model(
    session_config: &SessionBuilderConfig,
    config: &Config,
    saved_provider: Option<String>,
    saved_model_config: Option<goose_providers::model::ModelConfig>,
) -> ResolvedProviderConfig {
    let recipe_settings = session_config
        .recipe
        .as_ref()
        .and_then(|r| r.settings.as_ref());

View on GitHub (pinned to 3810898a74)

Solutions

  1. Resume without changing provider or model — drop the --provider/--model flags and unset GOOSE_PROVIDER/GOOSE_MODEL overrides.
  2. If you need the other provider/model, start a new session (goose session new / fresh `goose run`) instead of resuming.
  3. If you believe nothing changed, check saved session metadata for the original provider/model and match it exactly.

Example fix

# before
$ goose session resume --provider openai
Error: Cannot resume with provider or model changes because provider 'claude_code' manages its own conversation context. ...

# after
$ unset GOOSE_PROVIDER GOOSE_MODEL
$ goose session resume                 # same provider/model as saved
# or start fresh with the other provider:
$ goose session new --provider openai
Defensive patterns

Strategy: validation

Validate before calling

# before resuming, confirm no provider/model override differs from the saved session
saved_provider=$(jq -r '.metadata.provider // empty' ~/.config/goose/sessions/${SESSION}.json 2>/dev/null)
[ -z "${GOOSE_PROVIDER:-}" ] || [ "${GOOSE_PROVIDER}" = "$saved_provider" ] \
  || echo "refusing: managed-context session + provider change"

Try / catch

match resume_session(&id, &opts).await {
    Err(e) if e.to_string().contains("manages its own conversation context") => {
        // hard rule: start a new session with the desired provider/model
        new_session(&opts).await
    }
    r => r,
}

Prevention

When it happens

Trigger: `goose session resume` (or headless resume) with --provider/--model differing from the saved session while the session used claude_code or gemini_cli; or GOOSE_PROVIDER/GOOSE_MODEL env overrides taking effect on resume of such a session.

Common situations: Switching from a managed-context CLI provider to a direct API provider (or vice versa) mid-project; stale GOOSE_MODEL exports in the shell causing an unintended 'change' on resume.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/742360147e99d64e. Report an issue: GitHub.