Skip to content

[Bug]: Docker Codex conversation credentials diverge from stored secret after refresh #6533

Open

Description

@Just-Insane

Observed behavior

In an Agent Canvas Docker deployment, an automation-created Codex ACP conversation fails immediately with ACPAuthRequired: [-32000] Authentication required, while a separate interactive Codex conversation using the same profile and ChatGPT account works. The review automation reported its worker run as completed after creating the failed conversation.

The agent server reports OpenHands SDK v1.59.0, with codex-acp 2.2.2. The failed conversation was created on 2026-11-06 at 01:55 UTC and produced the same error on subsequent attempts. Its runtime was no longer available for inspection; the recorded event does not include the underlying provider error.

Credential evidence

The active profile configures CODEX_AUTH_JSON as the Codex auth.json file secret in a per-conversation CODEX_HOME. Without printing credentials, we compared the stored secret and the working interactive conversation's local file:

  • Both refer to the same account.
  • The stored secret recorded last_refresh at 02:03 UTC; the conversation-local file recorded 02:15 UTC.
  • Both the access tokens and refresh tokens differed. The local file is a regular file, not a symlink.

This establishes that the running conversation's credential changed without the credential exposed through the settings secret endpoint converging at the time of inspection. It does not establish whether the failed conversation used that exact stale generation, whether the provider rejected a reused token, or whether concurrent refresh occurred. The UI-visible error is insufficient to distinguish these cases.

Expected behavior

Isolated conversations using one ChatGPT login should receive current credentials after a refresh, and concurrent processes must not race the same rotating refresh token. Alternatively, unsupported concurrent use should be detected and explained. Automation runs should report a failed child conversation as a failure rather than success.

Relevant existing work

Suggested investigation

  1. Reproduce on the affected Docker topology with two isolated conversations and a real or test-controlled token rotation; inspect only sanitized refresh outcomes and credential generations.
  2. Verify that a new conversation receives the latest credential, including across runtime restart, and that simultaneous refreshes cannot race at the provider.
  3. Preserve a sanitized underlying authentication reason such as refresh_token_reused when available; do not log credentials.
  4. Check why the automation worker reported success after its child entered error.

This report was prepared by an AI assistant on behalf of the user.


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Scope grounded in this repository (SDK + Agent Server), maintainer precedent on the directly analogous closed issues (#4170, #4171, #4268 — closed not_planned with the caveat that this Docker topology was "unobserved, not disproven"), and the code cited in the report: ConversationService._resolve_credential_bindings (openhands-agent-server/openhands/agent_server/conversation_service.py) activates LocalVersionedCredentialBinding only when the local secret store holds the Codex credential; otherwise ACPAgent._materialise_file_secrets (openhands-sdk/openhands/sdk/agent/acp_agent.py) materializes a plain conversation-local copy of CODEX_AUTH_JSON with no write-back, so a Codex rotation converges on nothing. The binding path is the existing authoritative convergence mechanism for local deployments: it resolves the credential from the server-side store at materialization and performs versioned compare-and-swap write-back (FileSecretsStore.replace_versioned_secret) when Codex rotates, reusing the mechanism confirmed deployed for the SaaS equivalent (#4124/#4198). The reporting path must fail the parent automation run when the child conversation errors.

Acceptance Criteria

  • Given an Agent Server (local or Docker topology) whose secret store holds CODEX_AUTH_JSON, a newly created Codex ACP conversation activates the versioned credential binding (LocalVersionedCredentialBinding) rather than the plain per-conversation file-secret fallback; the activation and the reason any fallback was taken are verifiable from server-side diagnostics.
  • When Codex rotates credentials in a bound conversation, the successor generation is written back to the agent server's secret store, and a subsequently created Codex conversation materializes the current generation rather than the pre-rotation one.
  • The agent server's stored secret reflects the latest rotation after a bound conversation stops, restarts, or is paused and resumed.
  • An ACP authentication failure on a Codex conversation surfaces a sanitized underlying reason (e.g., refresh_token_reused) in conversation events or server logs, without credentials or tokens in any log, event payload, or error message.
  • When an automation-created child conversation reaches the error execution status, the parent run reports failure rather than completion. (Observed on the OpenHands/automation side; any SDK/agent-server contribution here is limited to making the child's error status observable through the public conversation API.)
  • The concurrency race is explicitly out of scope for this issue: simultaneous refreshes across conversations are not fenced in this change (per Phase 2: coordinate concurrent Codex credential refresh across ACP conversations #4171's closed, evidence-based deferral); if unsupported concurrent use is detected during this work, its behavior is documented in the PR but no fencing is required.

Activity

  1. added
    bug
    priority:medium
    acp
    ready-for-dev
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acpbugpriority:mediumready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions