fix(embeddings): clean up CodexOAuthEmbeddings token-refresh follow-up#1809
Merged
Conversation
- Drop unused CodexRefreshExpiredError import in CodexOAuthEmbeddings.encode - Make CodexAuthManager.load_refresh_token_from_file a staticmethod taking the auth_file path, so CodexLLM._load_codex_refresh_token no longer needs a duplicate file-read branch for the pre-_auth_manager init path - Patch Path.home() in the embeddings tests instead of monkeypatching HOME and manually overriding _auth_manager._auth_file post-construction; the prior shape worked on CI but could read the developer's real ~/.codex on local runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1712 — small cleanups surfaced during review.
CodexOAuthEmbeddings.encode()(CodexRefreshExpiredErrorwas imported but never referenced — it propagates naturally fromrefresh_tokens)._load_codex_refresh_token: makeCodexAuthManager.load_refresh_token_from_filea@staticmethodtaking theauth_filepath.CodexLLM._load_codex_refresh_tokennow calls the same code path both pre- and post-__init__instead of duplicating the file-read in ahasattrfallback.CodexOAuthEmbeddingstests intest_codex_oauth_refresh.pysetmonkeypatch.setenv("HOME", tmp_path)and then manually overrodeemb._auth_manager._auth_filepost-construction. That works on CI but on a developer machine with a real~/.codex/auth.jsonthe construction step could still read the real file (depending onPath.home()resolution). Switched tomonkeypatch.setattr(Path, "home", lambda: tmp_path)soCodexAuthManager.from_file()resolves to the tmp file directly, and dropped the manual_auth_fileoverride.Test plan
uv run pytest tests/test_codex_oauth_refresh.py— 25 passeduv run pytest tests/test_codex_tool_choice.py tests/test_codex_base_url.py— 5 passed (verifies the_load_codex_*patch surface still works for callers that mock these methods)uv run ruff check .,uv run ruff format --check .,uv run ty check hindsight_api/— clean