Significant-Gravitas/AutoGPT · error · HTTPException

Expert not found

Error message

Expert not found

What it means

A 404 from create_session's expert branch: expert_id was supplied, but experts_db.get_expert(user_id, expert_id) returned None or an expert with is_archived=true. The lookup is scoped to the requesting user, so a valid expert owned by someone else is indistinguishable from a nonexistent one.

Source

Thrown at autogpt_platform/backend/backend/api/features/chat/routes.py:680

    Returns:
        CreateSessionResponse: Details of the resulting session.
    """
    dry_run = request.dry_run if request else False
    builder_graph_id = request.builder_graph_id if request else None
    expert_id = request.expert_id if request else None

    # The builder branch below ignores expert_id, so accepting both would
    # validate the expert and then silently drop the scoping. Reject upfront.
    if builder_graph_id and expert_id:
        raise HTTPException(
            status_code=422,
            detail="builder_graph_id and expert_id are mutually exclusive",
        )

    if expert_id is not None:
        expert = await experts_db.get_expert(user_id, expert_id)
        if expert is None or expert.is_archived:
            raise HTTPException(status_code=404, detail="Expert not found")

    llm_auth_provider, llm_credential_id = await _resolve_new_session_llm_route(
        user_id, request
    )

    if llm_auth_provider == "platform":
        await enforce_payment_paywall(user_id)

    logger.info(
        f"Creating session with user_id: "
        f"...{user_id[-8:] if len(user_id) > 8 else '<redacted>'}"
        f"{', dry_run=True' if dry_run else ''}"
        f"{f', builder_graph_id={builder_graph_id}' if builder_graph_id else ''}"
        f"{f', expert_id={expert_id}' if expert_id else ''}"
    )

    if builder_graph_id:
        if llm_auth_provider == "codex":

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Refresh the experts list in the client and only allow starting chats with non-archived experts owned by the current user.
  2. If the expert should be usable, un-archive it in the experts management UI first.
  3. Check that the authenticated user actually owns the expert — sharing another user's expert id yields this same 404.

Example fix

// before
createSession({expert_id: cachedExpertId})

// after
const experts = await listExperts(userId);
const active = experts.find(e => e.id === expertId && !e.is_archived);
if (active) createSession({expert_id: active.id});
Defensive patterns

Strategy: try-catch

Validate before calling

const experts = await listExperts(userId);
const usable = experts.find(x => x.id === expertId && !x.is_archived);
if (!usable) { refreshExpertPicker(); return; }
await createSession({expert_id: usable.id});

Type guard

function isStartableExpert(e: {id: string; is_archived: boolean} | null, id: string): boolean {
  return e != null && e.id === id && !e.is_archived;
}

Try / catch

try {
  await createSession({expert_id: expertId});
} catch (e) {
  if (e.status === 404) { refreshExperts(); showExpertUnavailable(); return; }
  throw e;
}

Prevention

When it happens

Trigger: POST /chat/sessions with expert_id that was deleted, archived (is_archived=true), belongs to another user, or came from a different environment.

Common situations: Expert archived in the marketplace/experts UI while the client still shows its card; stale expert id cached from a previous session or another workspace; environment mismatch (dev id against prod API).

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/f42f5bce9dc54bda. Report an issue: GitHub.