Skip to content

fix(anthropic): honor claude_code source suppression in token resolution - #116

Merged
exiao merged 3 commits into
live-configfrom
fix/anthropic-respect-claude-code-suppression
Jul 15, 2026
Merged

fix(anthropic): honor claude_code source suppression in token resolution#116
exiao merged 3 commits into
live-configfrom
fix/anthropic-respect-claude-code-suppression

Conversation

@exiao

@exiao exiao commented Jul 15, 2026

Copy link
Copy Markdown
Owner

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 the claude_code source.

hermes auth remove anthropic for 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. But resolve_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 /model Anthropic-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_token shadowing at sources #1/#2) on is_source_suppressed("anthropic", "claude_code") for every profile, including the default/process-owner. When suppressed, creds is dropped to None and 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 returns None. Red-before/green-after verified. TestResolveAnthropicToken suite: 33 passed. ruff clean.

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.
@exiao

exiao commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@claude

claude Bot commented Jul 15, 2026

Copy link
Copy Markdown

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread agent/anthropic_adapter.py Outdated
Comment thread agent/anthropic_adapter.py Outdated
…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.
@exiao

exiao commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread agent/anthropic_adapter.py
… 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.
@exiao

exiao commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: b76c7cfc71

ℹ️ 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".

@exiao

exiao commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

Merge-ready at b76c7cf. All 3 codex P2 review threads fixed + resolved:

  1. Check suppression before reading Claude credentials — claude_code_suppressed is now computed BEFORE the first read_claude_code_credentials(), so a suppressed source never touches ~/.claude/Keychain.
  2. Keep Claude suppression out of pool isolation — claude_code_suppressed is no longer folded into suppress_global_creds, so profile_only/root-pool fallback is unaffected for a claude_code-only suppression.
  3. Avoid re-reading Claude Code during pool resolution — _seed_from_singletons now checks suppression before the lazy read, closing the source-fix(signal): drop empty metadata events and surface reactions #4 leak of the "not even read" contract.

Required CI gate (All required checks pass) is green; 284 anthropic+pool tests pass with red-before/green-after regressions. The claude-review check is the known Claude Code Review workflow infra failure (empty API key, dies ~2s in) — non-required, non-blocking, consistent across recent PRs.

@exiao
exiao merged commit 2f6a301 into live-config Jul 15, 2026
35 of 36 checks passed
@exiao
exiao deleted the fix/anthropic-respect-claude-code-suppression branch July 15, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant