langchain-ai/deepagents · error · MissingCredentialsError

Not signed in to ChatGPT. Run `/auth` and select openai_code

Error message

Not signed in to ChatGPT. Run `/auth` and select openai_codex to sign in with your ChatGPT account.

What it means

deepagents-code raises MissingCredentialsError when the selected provider is `openai_codex` and no ChatGPT OAuth token exists. Unlike API-key providers, Codex authenticates via interactive ChatGPT sign-in (there is no env var to set), so the error points the user at the `/auth` slash command instead of an environment variable. The `env_var=None` kwarg signals to the retry/recovery flow that interactive auth is the only remediation.

Source

Thrown at libs/code/deepagents_code/config.py:5794

    from deepagents_code.model_config import CODEX_PROVIDER

    # Early credential check — fail fast with an actionable message instead of
    # letting the provider SDK raise an opaque auth error on first invocation.
    # Providers that support implicit auth (e.g., Vertex AI ADC) are excluded
    # because their env-var mapping is not a reliable indicator.
    if provider and provider not in IMPLICIT_AUTH_PROVIDERS:
        cred_status = has_provider_credentials(provider)
        if cred_status is False:
            from deepagents_code.model_config import MissingCredentialsError

            if provider == CODEX_PROVIDER:
                # No env var to set; point the user at `/auth` instead.
                msg = (
                    "Not signed in to ChatGPT. Run `/auth` and select "
                    "openai_codex to sign in with your ChatGPT account."
                )
                raise MissingCredentialsError(msg, provider=provider, env_var=None)
            env_var = get_credential_env_var(provider)
            display_env = env_var or f"<{provider} API key>"
            msg = (
                f"No credentials found for provider '{provider}'. "
                f"Please set the {display_env} environment variable."
            )
            raise MissingCredentialsError(msg, provider=provider, env_var=env_var)

    # Provider-specific kwargs (with per-model overrides)
    kwargs = _get_provider_kwargs(provider, model_name=model_name)

    # Compose under existing kwargs: profile < config.toml < --model-params
    # (applied below). The app's OpenRouter profile is stacked on top of the
    # built-in SDK profile so its `pre_init` (version check) and factory
    # (app attribution) compose into a single `apply_provider_profile` call.
    if provider:
        from deepagents.profiles.provider import apply_provider_profile

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Run the `/auth` slash command inside dcode and select `openai_codex` to complete ChatGPT sign-in.
  2. Re-run the model request; the retry flow re-attempts automatically after successful `/auth`.
  3. If you intend to use an API key instead, switch to an `openai` model and set OPENAI_API_KEY.

Example fix

// before: launching with a codex model while unauthenticated
dcode -m openai_codex:gpt-5-codex
// MissingCredentialsError: Not signed in to ChatGPT...
// after: authenticate first, then launch
# inside dcode: /auth -> select openai_codex -> sign in
dcode -m openai_codex:gpt-5-codex
Defensive patterns

Strategy: validation

Validate before calling

from deepagents_code.config import MissingCredentialsError
from deepagents_code import codex as _codex

def codex_signed_in() -> bool:
    try:
        return _codex.has_auth_token()  # token file exists
    except FileNotFoundError:
        return False

if provider == "openai_codex" and not codex_signed_in():
    prompt_user_to_run_auth()  # /auth before building the model

Try / catch

try:
    model = build_model(provider, model_name)
except MissingCredentialsError as exc:
    if exc.provider == "openai_codex" and exc.env_var is None:
        prompt_user_to_run_auth()  # interactive sign-in is the only fix
        model = build_model(provider, model_name)  # retry after /auth

Prevention

When it happens

Trigger: Building a model config with provider == CODEX_PROVIDER (e.g. model spec `openai_codex:...`) when `MissingCredentialsError` is raised because the Codex auth token file is absent — i.e. the user never ran `/auth` or the credentials directory was cleared. Thrown from the credentials check in config.py before any model is constructed.

Common situations: Fresh install of deepagents-code where Codex was never authenticated; selecting an `openai_codex` model in the model selector on a new machine or CI container; wiping `~/.codex` (or the equivalent auth store) while still configured for Codex models.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/e3659c5817bf07ad. Report an issue: GitHub.