Skip to content

fix(codex): return remote auth refresh to external home - #11095

Open
Oldrich333 wants to merge 1 commit into
paperclipai:masterfrom
Oldrich333:fix/codex-auth-source-copyback
Open

fix(codex): return remote auth refresh to external home#11095
Oldrich333 wants to merge 1 commit into
paperclipai:masterfrom
Oldrich333:fix/codex-auth-source-copyback

Conversation

@Oldrich333

Copy link
Copy Markdown

Thinking Path

  • Paperclip manages AI agents and their execution runtimes.
  • The Codex adapter can run an agent on a remote SSH or sandbox target.
  • An external CODEX_HOME can bind an agent to an independent Codex subscription and session store.
  • A remote run stages that external home, but teardown sends every OAuth refresh to the shared host credential.
  • The same-account guard protects the shared account, but the external account keeps stale OAuth data.
  • This pull request returns the refresh to the credential source that supplied the remote run.
  • The benefit is safe use of separate Codex subscription identities without an auth pool or a custom token manager.

Linked Issues or Issue Description

Fixes: #11094

Refs: #9621

Refs: #10005

Refs: #5952

What Changed

  • Select the shared auth source for managed Codex homes.
  • Select the external auth source for a remote run with an external CODEX_HOME.
  • Resolve an external auth.json symlink before the atomic copy-back. This preserves the symlink.
  • Keep the existing strictly-newer and same-account decision guard.
  • Add end-to-end regression cases for regular and symlink-backed external auth sources.
  • Document remote OAuth refresh ownership for external homes.

Verification

  • pnpm exec vitest run packages/adapters/codex-local/src/server/execute.test.ts packages/adapters/codex-local/src/server/codex-auth-copyback.test.ts packages/adapters/codex-local/src/server/codex-home.test.ts
  • Result: 3 test files passed. 66 tests passed.
  • pnpm --filter @paperclipai/adapter-codex-local typecheck
  • Result: passed.
  • pnpm run check:tokens
  • Result: passed.
  • Independent review checked auth ownership, atomic writes, file mode, identity isolation, and token-safe logs.

Risks

Low risk.

The change only selects the copy-back destination for a remote run. Managed homes keep the existing shared destination. External homes already own their auth state. The existing decision predicate still refuses older data, unusable data, API-key data, and a different account identity.

No schema, API, migration, or local-run behavior changes.

Model Used

  • OpenAI Codex gpt-5.6-sol with medium reasoning, tool use, and code execution produced the change. The harness did not disclose its context window size.
  • Google Gemini gemini-3-pro-preview performed independent full reviews of the frozen commit.

Checklist

  • I have included a thinking path that traces from project context to this change
  • I have specified the model used (with version and capability details)
  • I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work
  • I have searched GitHub for duplicate or related PRs and linked them above
  • I have either (a) linked existing issues with Fixes: # / Closes # / Refs # OR (b) described the issue in-PR following the relevant issue template
  • I have not referenced internal/instance-local Paperclip issues or links (only public GitHub #NNN / github.com/paperclipai/paperclip URLs)
  • My branch name describes the change (e.g. docs/..., fix/...) and contains no internal Paperclip ticket id or instance-derived details
  • I have run tests locally and they pass
  • I have added or updated tests where applicable
  • I have updated relevant documentation to reflect my changes
  • I have considered and documented any risks above
  • All Paperclip CI gates are green
  • Greptile is 5/5 with no open P2s, recommendations, or follow-ups
  • I will address all Greptile and reviewer comments before requesting merge

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.

Codex remote runs do not return OAuth refreshes to external CODEX_HOME

1 participant