Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@aj47
Copy link
Contributor

@aj47 aj47 commented Jan 22, 2026

TLDR

Openai OAuth didnt use the workspace/team usage when you select workspace, it would always use your personal usage/plan. this fixes that

Problem

When authenticating with OpenAI Codex and selecting a workspace, Clawdbot ignores the account_id field stored in ~/.codex/auth.json. This causes API calls to be attributed to the user's personal ChatGPT account instead of the selected workspace.

Solution

This PR updates the Codex CLI credential reading to:

  1. Add accountId field to CodexCliCredential type - Now includes optional accountId for ChatGPT account/workspace ID

  2. Read account_id from ~/.codex/auth.json - The readCodexCliCredentials function now extracts tokens.account_id from the Codex CLI auth file

  3. Read account_id from macOS Keychain - The readCodexKeychainCredentials function also extracts the account_id when reading from keychain

The accountId automatically flows through to the auth profile store since OAuthCredentials from pi-ai already includes this field.

Testing

  • Build passes (pnpm build)
  • All tests pass (pnpm test)

How to verify

  1. Ensure you have authenticated with Codex CLI on the gateway host (verify ~/.codex/auth.json has the correct tokens.account_id)
  2. Sync credentials using one of:
    • clawdbot onboard --auth-choice codex-cli (reuse existing Codex CLI login)
    • clawdbot models status (triggers sync)
    • Restart the gateway (credentials sync automatically on startup)
  3. Run clawdbot doctor to verify the codex-cli profile is synced
  4. Check that ~/.clawdbot/agents/main/agent/auth-profiles.json now contains accountId for the openai-codex:codex-cli profile

@aj47 aj47 changed the title fix: read account_id from Codex CLI auth for workspace billing fix openai oauth to work with workspace/team plans Jan 22, 2026
steipete added a commit that referenced this pull request Jan 22, 2026
@steipete
Copy link
Contributor

Thanks @aj47 — landed on main after rebasing onto current main.

Commits:

Tests: pnpm lint && pnpm build && pnpm test

@steipete steipete closed this Jan 22, 2026
@aj47
Copy link
Contributor Author

aj47 commented Jan 22, 2026

Np aw I don't get contributor status this way it seems :(

@steipete
Copy link
Contributor

Oh you do! I made sure you are in the graph!

@steipete
Copy link
Contributor

Landed manually on main:

  • 862f34a fix: read account_id from Codex CLI auth for workspace billing
  • 40b7447 docs: update clawtributors (added @aj47)

Resolved the rebase conflict in the Telegram mention test (kept the timestamp helper).

Tests: pnpm lint && pnpm build && pnpm test

Thanks @aj47!

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.

2 participants