Skip to content

Read one more Codex auth cache#134

Merged
kargnas merged 2 commits into
mainfrom
codex-opencode-anthropic-codex-cache
May 10, 2026
Merged

Read one more Codex auth cache#134
kargnas merged 2 commits into
mainfrom
codex-opencode-anthropic-codex-cache

Conversation

@kargnas
Copy link
Copy Markdown
Member

@kargnas kargnas commented May 10, 2026

Summary

  • Read cached Codex account usage from ~/.config/opencode/opencode-anthropic-auth/codex-accounts.json in addition to codex-lb.
  • Preserve cached Codex usage snapshots as a low-priority OpenAI auth source so live token-based sources still win during dedupe.
  • Map cached primary, secondary, Spark, plan, and credits fields into Codex provider usage details.
  • Add regression coverage for enabled cache entries, disabled-account filtering, and mixed numeric fields.

Root Cause

Codex account discovery only considered token-bearing sources such as codex-lb and oc-chatgpt-multi-auth. The opencode-anthropic-auth codex-accounts.json file stores cached usage snapshots instead of reusable access tokens, so those accounts were previously invisible to OpenCode Bar.

Validation

  • make setup
  • xcodebuild test -project CopilotMonitor/CopilotMonitor.xcodeproj -scheme CopilotMonitor -only-testing:CopilotMonitorTests/TokenManagerTests -destination 'platform=macOS'
  • xcodebuild clean build -project CopilotMonitor/CopilotMonitor.xcodeproj -scheme CopilotMonitor -destination 'platform=macOS'
  • Ran the freshly built app and confirmed provider logs showed OpenAI accounts discovered: 5.
  • Re-ran the targeted test after rebasing onto origin/main; logs included Loaded 4 cached Codex account(s) from opencode-anthropic-auth at /Users/kargnas/.config/opencode/opencode-anthropic-auth/codex-accounts.json.

kargnas added 2 commits May 10, 2026 20:17
Codex accounts cached by opencode-anthropic-auth do not expose reusable OAuth tokens, so discovery now preserves cached usage snapshots as a low-priority fallback source.

Constraint: opencode-anthropic-auth codex-accounts.json contains usage snapshots rather than live credentials.

Rejected: Treating the cache entries as token-bearing accounts | the file does not contain access tokens.

Confidence: high

Scope-risk: moderate

Directive: Keep cache-backed Codex accounts lower priority than live auth sources.

Tested: xcodebuild test -project CopilotMonitor/CopilotMonitor.xcodeproj -scheme CopilotMonitor -only-testing:CopilotMonitorTests/TokenManagerTests -destination 'platform=macOS'

Not-tested: Full app test suite.
The parser now has regression coverage for enabled cache entries, disabled-account filtering, and cached quota fields from opencode-anthropic-auth.

Constraint: The cache file is a local JSON source with mixed numeric field representations.

Confidence: high

Scope-risk: narrow

Directive: Update this test when the opencode-anthropic-auth codex-accounts.json schema changes.

Tested: xcodebuild test -project CopilotMonitor/CopilotMonitor.xcodeproj -scheme CopilotMonitor -only-testing:CopilotMonitorTests/TokenManagerTests -destination 'platform=macOS'

Not-tested: Full app test suite.
@kargnas kargnas changed the title [codex] Read Codex Anthropic auth cache Read Codex Anthropic auth cache May 10, 2026
@kargnas kargnas changed the title Read Codex Anthropic auth cache Read one more Codex auth cache May 10, 2026
@kargnas kargnas marked this pull request as ready for review May 10, 2026 11:19
@kargnas kargnas merged commit c9bc05a into main May 10, 2026
10 of 11 checks passed
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