You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes Codex OAuth credential-pool isolation for multi-profile/multi-account setups.
A labelled Codex OAuth re-auth now updates only the intended profile entry and does not rewrite, relabel, or clear status on non-target Codex profiles. Unlabelled singleton refreshes keep the existing legacy-alias behavior, but when the provider singleton has a label, the refresh is scoped to that matching labelled pool entry instead of blindly updating the first device_code row.
This also prevents provider-singleton sync/seed paths from overwriting a device_code pool entry when the singleton label belongs to a different profile.
🐛 Bug fix (non-breaking change that fixes an issue)
✅ Tests (adding or improving test coverage)
Changes Made
hermes_cli/auth.py: labelled Codex token saves now target only the matching pool label; duplicate labels fail closed; labelled writes guard non-target entries against accidental mutation.
agent/credential_pool.py: Codex provider singleton sync/seed paths now respect label mismatches before adopting token material.
tests/hermes_cli/test_auth_codex_provider.py: added regressions for generic profile isolation, duplicate-label fail-closed behavior, and unlabelled refresh targeting.
tests/agent/test_credential_pool.py: added regression for provider singleton label mismatch.
Reviewed the Codex OAuth profile isolation changes across credential_pool.py and auth.py. A few things that stand out as well-done:
Snapshot guard pattern — _codex_non_target_snapshot + _assert_codex_non_targets_unchanged is a strong safety net. Taking a tuple snapshot of all non-target entries before mutation and asserting equality after prevents silent cross-profile corruption. This is the right primitive for auth state where a bad write can invalidate independent accounts.
Duplicate label detection — Failing closed with AuthError on ambiguous labels before writing auth.json prevents a nasty edge case where two entries with the same label get different token material.
Label-aware legacy fallback — The unlabelled path correctly checks for a provider singleton label and routes to the matching pool entry instead of blindly updating the first device_code row. This preserves backward compat while closing the cross-profile overwrite gap.
Test coverage — The three new test cases (label-scoped update, duplicate refusal, singleton label fallback) cover the critical state transitions. The assertion that non-target entries remain byte-identical to original is the right level of strictness.
No issues found. The safety-guard + snapshot pattern here is a good template for any future multi-profile auth state mutations.
Thanks for the careful credential-isolation regression work. Current main already provides this behavior, so this is superseded.
Automated hermes-sweeper review verified 761b744abbc6 (fix(auth): preserve independent Codex pool entries on re-auth): hermes_cli/auth.py:3355-3363 refreshes a manual:device_code entry only when it matches the prior singleton token; independent entries remain untouched.
c78b3e1d3ccc (fix(auth): add Codex OAuth accounts as distinct pool entries) moved hermes auth add openai-codex to a pool-only path. hermes_cli/auth_commands.py:310-344 creates a fresh labelled manual:device_code entry per OAuth login rather than routing through _save_codex_tokens().
tests/hermes_cli/test_auth_commands.py:401-468 verifies two consecutive Codex OAuth additions retain distinct labels and token pairs.
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
area/authAuthentication, OAuth, credential poolscodexcomp/cliCLI entry point, hermes_cli/, setup wizardP3Low — cosmetic, nice to havesweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working
4 participants
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.
What does this PR do?
Fixes Codex OAuth credential-pool isolation for multi-profile/multi-account setups.
A labelled Codex OAuth re-auth now updates only the intended profile entry and does not rewrite, relabel, or clear status on non-target Codex profiles. Unlabelled singleton refreshes keep the existing legacy-alias behavior, but when the provider singleton has a label, the refresh is scoped to that matching labelled pool entry instead of blindly updating the first
device_coderow.This also prevents provider-singleton sync/seed paths from overwriting a
device_codepool entry when the singleton label belongs to a different profile.Related Issue
Refs #42102
Refs #39236
Complements #42110
Type of Change
Changes Made
hermes_cli/auth.py: labelled Codex token saves now target only the matching pool label; duplicate labels fail closed; labelled writes guard non-target entries against accidental mutation.agent/credential_pool.py: Codex provider singleton sync/seed paths now respect label mismatches before adopting token material.tests/hermes_cli/test_auth_codex_provider.py: added regressions for generic profile isolation, duplicate-label fail-closed behavior, and unlabelled refresh targeting.tests/agent/test_credential_pool.py: added regression for provider singleton label mismatch.How to Test
Focused pytest:
python -m pytest -q -o addopts='' tests/hermes_cli/test_auth_codex_provider.py tests/agent/test_credential_pool.py tests/hermes_cli/test_auth_commands.pyCanonical per-file runner for touched suites:
Static checks:
Checklist
Code
Documentation
Testing
git diff --checkpassedSecurity / Privacy
profile-one,profile-two,profile-three)Screenshots / Logs
Not applicable. This is a credential-store behavior fix covered by regression tests with synthetic generic credential data only.