T3 Code: managed ChatGPT token stays cached after 401 token_expired#29927

opened28d agobySsfls1397

Expected

When the Responses API rejects the managed ChatGPT token with HTTP 401 and token_expired, invalidate that access-token cache, renew through T3's existing locked refresh-token flow, and retry the failed request once. Do not retry other 401 errors or loop if renewal or that one retry fails. Preserve the provider, model and thread. Never log either token.

Observed on November 2, 2026 (America/Chicago)

  • A managed ChatGPT connection refreshed successfully at 7:03:59 PM CT.
  • From about 7:04 PM, Responses requests returned 401 token_expired.
  • The cached access token's stated expiry was about 8:04 PM. Requests continued using it, including multiple threads' immediate resume failures.
  • By 8:21 PM, a new ChatGPT connection used a fresh token; a subsequent test returned HTTP 200 and OK. These times come from the incident investigation; no credential values are included here.

Installed-code evidence (read-only inspection)

Installed desktop version: T3 Code (Beta) 0.1.5.

The bundled server's source-labelled src/provider/CodexChatGptAuth.ts has access return the saved record when record.expiresAt - now > 6e4. It does not accept an invalidation/force-refresh argument. CodexManagedTokenBroker invokes that same access and accepts only version, instanceId, environmentId and profileKey; it rejects excess request properties. Calling the helper again therefore does not force renewal before the local expiry threshold.

Codex's app-server account/read documentation in the bundle explicitly says refreshToken is ignored for external auth. T3 supplies this managed provider through an external token-helper command, so that is not a force-refresh escape hatch. No supported force-refresh setting or command was found. The installed application, credentials and provider settings were not modified or restarted.

Suggested upstream regression tests

  1. A token whose local expiry is still an hour away receives 401 token_expired: renew once, then retry once using the newly returned token.
  2. Concurrent rejections share the existing refresh lock/single-flight flow.
  3. A second 401 terminates normally; other 401 errors do not trigger this path.
  4. Credential replacement, earliestRefreshAt constraints and revoked sharing remain respected. Logs and failure reports contain no credential values.