{"record":{"id":"48918b08173ec81f","repo":"HKUDS/Vibe-Trading","slug":"oauth-cli-kit-is-not-installed-run-pip-install-o","errorCode":null,"errorMessage":"oauth-cli-kit is not installed. Run: pip install oauth-cli-kit","messagePattern":"oauth-cli-kit is not installed\\. Run: pip install oauth-cli-kit","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/src/providers/openai_codex.py","lineNumber":105,"sourceCode":"\n    def __init__(self, detail: str, *, status_code: int | None, permanent: bool) -> None:\n        super().__init__(detail)\n        self.status_code = status_code\n        self.permanent = permanent\n\n\ndef _build_codex_token_storage(path: Path | None = None) -> Any:\n    \"\"\"Build the Vibe-owned Codex token store.\n\n    The path deliberately does not use oauth-cli-kit's default storage, because\n    that backend imports and copies ``~/.codex/auth.json``. A copied rotating\n    refresh token gives two processes ownership of one OAuth session and causes\n    the ``token_invalidated`` / ``refresh_token_reused`` failure in issue #975.\n    \"\"\"\n    try:\n        from oauth_cli_kit.storage import FileTokenStorage\n    except ImportError as exc:\n        raise RuntimeError(\"oauth-cli-kit is not installed. Run: pip install oauth-cli-kit\") from exc\n\n    token_path = path or (get_runtime_root() / \"auth\" / _CODEX_TOKEN_FILENAME)\n\n    class VibeCodexTokenStorage(FileTokenStorage):\n        def get_token_path(self) -> Path:\n            return token_path\n\n    return VibeCodexTokenStorage(\n        token_filename=_CODEX_TOKEN_FILENAME,\n        app_name=\"vibe-trading\",\n        import_codex_cli=False,\n    )\n\n\ndef _clear_codex_token(storage: Any) -> None:\n    \"\"\"Remove only Vibe's invalid credential cache.\"\"\"\n    try:\n        storage.get_token_path().unlink(missing_ok=True)","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/providers/openai_codex.py#L87-L123","documentation":"_build_codex_token_storage imports FileTokenStorage from oauth_cli_kit to build the Vibe-owned token cache; the ImportError is re-raised with an install command. Every Codex OAuth token operation needs this storage class.","triggerScenarios":"Calling login_openai_codex or any token read/refresh (_get_codex_token) when oauth-cli-kit is not installed in the environment.","commonSituations":"Running the agent's Codex login or streaming flow in an env where only core deps were installed; dependency pruning in Docker images removed the OAuth kit.","solutions":["pip install oauth-cli-kit","Confirm the install exposes storage: python -c \"from oauth_cli_kit.storage import FileTokenStorage\"","Re-run the login command afterwards"],"exampleFix":"# before\nRuntimeError: oauth-cli-kit is not installed. Run: pip install oauth-cli-kit\n\n# after\npip install oauth-cli-kit","handlingStrategy":"try-catch","validationCode":"try:\n    from oauth_cli_kit.storage import FileTokenStorage  # noqa: F401\nexcept ImportError:\n    raise SystemExit('pip install oauth-cli-kit')","typeGuard":null,"tryCatchPattern":"try:\n    storage = _build_codex_token_storage()\nexcept RuntimeError as e:\n    if 'oauth-cli-kit' in str(e):\n        print('Run: pip install oauth-cli-kit'); sys.exit(1)\n    raise","preventionTips":["Include oauth-cli-kit in the deployment image when Codex OAuth is used","Add a preflight check before login/streaming flows"],"tags":["oauth","codex","missing-dependency","pip"],"backgroundTag":"missing-optional-dependency","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}