fix(anthropic): honor claude_code source suppression in token resolution - #116
Conversation
Follow-up to #115 (codex P2). resolve_anthropic_token()'s Claude-file read (source #3) ignored an explicit user suppression of the claude_code source: hermes auth remove anthropic leaves ~/.claude/.credentials.json in place (Claude Code owns it) and records a suppression marker, but the resolver still read the file and probed Anthropic with the removed credential. Gate the global-cred read on is_source_suppressed(anthropic, claude_code) for every profile including the default. Red-before/green-after regression added.
|
@codex review |
|
Claude encountered an error after 2s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Code Review
This pull request updates the Anthropic adapter to respect explicit user suppression of the claude_code credential source. When claude_code is suppressed via hermes_cli.auth.is_source_suppressed, the global Claude credential file is not read, preventing the resurrection of removed credentials. A corresponding unit test has been added to verify this behavior. I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a11ebee09
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…t of pool isolation Addresses codex review on #116: - Check is_source_suppressed BEFORE read_claude_code_credentials so a suppressed claude_code source never touches the Claude file or the macOS Keychain, and gate source #3 on it too (creds=None alone lets that resolver re-read the global file). - Do NOT fold claude_code suppression into suppress_global_creds: that flag also drives profile_only= on the pool lookup, so folding it in wrongly bypassed the pool's global-root fallback for a named profile that suppressed only the Claude-file source but has a valid inherited/manual OAuth pool entry. Suppression now affects only the Claude-file path. Added a regression asserting the file is never read when suppressed.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 923ffe468a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… during seeding Addresses codex review on #116: _seed_from_singletons built its (source, creds) list by eagerly calling read_claude_code_credentials() before the _is_suppressed() check, so pool seeding (reached via resolve_anthropic_token source #4 -> load_pool) still touched ~/.claude / the macOS Keychain despite the suppression marker. Pair each source with a lazy reader and check suppression first, so a suppressed claude_code source is never read. Regression: red-before/green-after on _seed_from_singletons with a booby-trapped reader.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Merge-ready at b76c7cf. All 3 codex P2 review threads fixed + resolved:
Required CI gate ( |
What
Follow-up to #115 (codex P2 flagged on the merged head).
resolve_anthropic_token()'s Claude-file read (source #3) ignored an explicit user suppression of theclaude_codesource.hermes auth remove anthropicfor a Claude Code login does not delete~/.claude/.credentials.json(Claude Code itself owns that file) — it records a suppression marker so Hermes stops reading it. Butresolve_anthropic_token()only skipped the global Claude-file read for non-default scoped profiles / when a scoped API key was present; it did not consult the suppression marker. So the default profile's/modelAnthropic-catalog fallback (added in #115) would re-read the file and probe Anthropic with a credential the user explicitly removed.Fix
Gate the global-credential read (source #3, plus the
_prefer_refreshable_claude_code_tokenshadowing at sources #1/#2) onis_source_suppressed("anthropic", "claude_code")for every profile, including the default/process-owner. When suppressed,credsis dropped toNoneand the Claude-file fallback is skipped, exactly like the non-default-scope path.Tests
tests/agent/test_anthropic_adapter.py::test_suppressed_claude_code_source_is_not_read: control (unsuppressed) resolves the Claude-file token; suppressed returnsNone. Red-before/green-after verified.TestResolveAnthropicTokensuite: 33 passed. ruff clean.