{"record":{"id":"e3659c5817bf07ad","repo":"langchain-ai/deepagents","slug":"not-signed-in-to-chatgpt-run-auth-and-select-o","errorCode":null,"errorMessage":"Not signed in to ChatGPT. Run `/auth` and select openai_codex to sign in with your ChatGPT account.","messagePattern":"Not signed in to ChatGPT\\. Run `/auth` and select openai_codex to sign in with your ChatGPT account\\.","errorType":"exception","errorClass":"MissingCredentialsError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/config.py","lineNumber":5794,"sourceCode":"\n    from deepagents_code.model_config import CODEX_PROVIDER\n\n    # Early credential check — fail fast with an actionable message instead of\n    # letting the provider SDK raise an opaque auth error on first invocation.\n    # Providers that support implicit auth (e.g., Vertex AI ADC) are excluded\n    # because their env-var mapping is not a reliable indicator.\n    if provider and provider not in IMPLICIT_AUTH_PROVIDERS:\n        cred_status = has_provider_credentials(provider)\n        if cred_status is False:\n            from deepagents_code.model_config import MissingCredentialsError\n\n            if provider == CODEX_PROVIDER:\n                # No env var to set; point the user at `/auth` instead.\n                msg = (\n                    \"Not signed in to ChatGPT. Run `/auth` and select \"\n                    \"openai_codex to sign in with your ChatGPT account.\"\n                )\n                raise MissingCredentialsError(msg, provider=provider, env_var=None)\n            env_var = get_credential_env_var(provider)\n            display_env = env_var or f\"<{provider} API key>\"\n            msg = (\n                f\"No credentials found for provider '{provider}'. \"\n                f\"Please set the {display_env} environment variable.\"\n            )\n            raise MissingCredentialsError(msg, provider=provider, env_var=env_var)\n\n    # Provider-specific kwargs (with per-model overrides)\n    kwargs = _get_provider_kwargs(provider, model_name=model_name)\n\n    # Compose under existing kwargs: profile < config.toml < --model-params\n    # (applied below). The app's OpenRouter profile is stacked on top of the\n    # built-in SDK profile so its `pre_init` (version check) and factory\n    # (app attribution) compose into a single `apply_provider_profile` call.\n    if provider:\n        from deepagents.profiles.provider import apply_provider_profile\n","sourceCodeStart":5776,"sourceCodeEnd":5812,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L5776-L5812","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the `/auth` slash command inside dcode and select `openai_codex` to complete ChatGPT sign-in.","Re-run the model request; the retry flow re-attempts automatically after successful `/auth`.","If you intend to use an API key instead, switch to an `openai` model and set OPENAI_API_KEY."],"exampleFix":"// before: launching with a codex model while unauthenticated\ndcode -m openai_codex:gpt-5-codex\n// MissingCredentialsError: Not signed in to ChatGPT...\n// after: authenticate first, then launch\n# inside dcode: /auth -> select openai_codex -> sign in\ndcode -m openai_codex:gpt-5-codex","handlingStrategy":"validation","validationCode":"from deepagents_code.config import MissingCredentialsError\nfrom deepagents_code import codex as _codex\n\ndef codex_signed_in() -> bool:\n    try:\n        return _codex.has_auth_token()  # token file exists\n    except FileNotFoundError:\n        return False\n\nif provider == \"openai_codex\" and not codex_signed_in():\n    prompt_user_to_run_auth()  # /auth before building the model","typeGuard":null,"tryCatchPattern":"try:\n    model = build_model(provider, model_name)\nexcept MissingCredentialsError as exc:\n    if exc.provider == \"openai_codex\" and exc.env_var is None:\n        prompt_user_to_run_auth()  # interactive sign-in is the only fix\n        model = build_model(provider, model_name)  # retry after /auth","preventionTips":["Complete `/auth` with openai_codex once per machine/user before selecting Codex models.","In scripts/CI, check for the Codex token file as a preflight and fail fast with a sign-in instruction.","Run under the same HOME/user where authentication was performed."],"tags":["authentication","oauth","chatgpt","codex","config"],"backgroundTag":"oauth-not-signed-in","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}