aaif-goose/goose · error

provider inventory refresh task panicked

Error message

provider inventory refresh task panicked

What it means

The inventory-refresh task wraps the provider lookup (get_session_agent + provider()) in AssertUnwindSafe(...).catch_unwind(); if that future panicked, the panic is converted into this anyhow error so the background task degrades gracefully instead of tearing down the tokio runtime. The panic itself happened inside session/provider resolution, not in the model fetch.

Source

Thrown at crates/goose/src/acp/server/dispatch.rs:240

                                        AssertUnwindSafe(async {
                                            let session_agent =
                                                agent_bg.get_session_agent(&session_id_bg.0).await?;
                                            let provider = session_agent
                                                .provider()
                                                .await
                                                .map_err(|e| anyhow::anyhow!(e.to_string()))?;
                                            let provider_name = provider.get_name().to_string();
                                            if provider_name != refresh_provider_id {
                                                return Err(anyhow::anyhow!(
                                                    "provider changed before inventory refresh completed"
                                                ));
                                            }
                                            Ok(provider)
                                        })
                                        .catch_unwind()
                                .await
                                .map_err(|_| {
                                    anyhow::anyhow!("provider inventory refresh task panicked")
                                })
                                .and_then(|result| result);

                                let fetch_result = match provider_result {
                                    Ok(provider) => {
                                        match ensure_refresh_identity_current(
                                            &refresh_provider_id,
                                            &refresh_identity,
                                        )
                                        .await
                                        {
                                            Ok(()) => match AssertUnwindSafe(
                                                provider.fetch_recommended_models(
                                                    crate::model_config::global_toolshim(),
                                                ),
                                            )
                                            .catch_unwind()
                                            .await

View on GitHub (pinned to 3810898a74)

Solutions

  1. Check the logs for the panic location and backtrace emitted just before this error — it names the real faulting line
  2. Fix or update the provider implementation that panicked (replace unwrap/expect on Option/Result with proper error returns)
  3. Restart the session/agent to clear any poisoned state, then retry the model refresh

Example fix

// before (provider panics)
let cfg = self.config.as_ref().unwrap();

// after
let cfg = self
    .config
    .as_ref()
    .ok_or_else(|| anyhow::anyhow!("missing provider config"))?;
Defensive patterns

Strategy: try-catch

Try / catch

let provider_result = AssertUnwindSafe(get_provider())
    .catch_unwind()
    .await
    .map_err(|_| anyhow::anyhow!("refresh panicked"));
if provider_result.is_err() {
    tracing::error!("provider lookup panicked; falling back to last known inventory");
}

Prevention

When it happens

Trigger: A panic inside get_session_agent or the provider() call — e.g. a custom provider whose constructor panics, a poisoned or deadlocked lock, or a session that was torn down mid-lookup and unwraps a None.

Common situations: Third-party/custom provider implementations that use unwrap/expect on fallible state; sessions being closed concurrently with a refresh; bugs in provider trait implementations.

Related errors


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