bug(gator): Codex auth refresh failures cause missing-sentinel retries
Personne n'a encore pris cette issue.
- Langage dominant
- Rust
- Étoiles
- 8.7k
- Forks
- 1.3k
- Merge moyen
- 2 j 7 h
- PR mergées (30 j)
- 243
Description
Agent Diagnostic
- Skills used:
create-github-issue; gator debugging was performed from the local launcher/sandbox logs rather than GitHub checks. - OpenShell version tested: current local CLI reports
openshell 0.0.88. The observed gator launch used the localopenshellgateway, which earlier reported0.0.75during preflight beforemainwas updated. - Current branch state checked: local
mainis clean and trackingorigin/main. - Known fixes reviewed: current
mainincludes the gator payload readability fix in the Docker build path, but the Codex harness still writes fallback/placeholder auth material when provider credentials do not include complete Codex auth fields. - Possible duplicate issues checked with
gh api: no open issues matchedgator Codex refresh,CODEX_AUTH_ACCESS_TOKEN refresh, orOPENSHELL_AGENT_RESULT token_expired. - Findings:
- A supervised gator run against PR #2421 had early Codex cycles fail with websocket
401 Unauthorizedfollowed byFailed to refresh token: 401 Unauthorized/token_expired. - The harness exited without emitting
OPENSHELL_AGENT_RESULT, so the wrapper treated the cycle as a transient upstream transport failure and retried. - Later cycles recovered and completed successfully (
merge_ready, thenpr_merged), so the immediate PR watcher did not remain stuck. scripts/agents/runtime/harnesses/codex/exec.shcreates/sandbox/home/.codex/auth.json, but whenCODEX_AUTH_ID_TOKENorCODEX_AUTH_REFRESH_TOKENare absent it currently falls back to synthetic/placeholder values.scripts/agents/gator/agent.yamlandscripts/agents/gator/providers/codex-gator.yamlprovide access token/account ID fields but do not provideCODEX_AUTH_ID_TOKEN; refresh material is gateway-managed rather than placed in the sandbox.
- A supervised gator run against PR #2421 had early Codex cycles fail with websocket
- Reason for filing: the run eventually succeeded, but the current behavior makes long-lived supervised gator watchers vulnerable to intermittent or expired Codex auth state. A few bad refresh attempts can consume retries, delay review cycles, or leave the failure looking like a generic missing-sentinel harness crash.
Description
Supervised gator runs that use the Codex harness can fail early cycles when the Codex access token expires or cannot be refreshed from the auth material written into the sandbox. In the observed PR #2421 run, Codex failed to connect to the websocket with 401 Unauthorized, then failed refresh with token_expired, and exited before writing the required OPENSHELL_AGENT_RESULT sentinel.
The supervisor wrapper did detect this as a transient upstream transport failure and retry. That was enough for this specific run to recover, post merge_ready, and later complete after the PR merged. However, the behavior is still fragile: the sandbox receives enough auth material to start Codex, but not necessarily enough valid material for Codex's own refresh path, while the gateway owns provider refresh outside the already-running process environment.
Expected behavior:
- Gator should either receive complete, usable Codex auth material for the harness lifecycle, or refresh Codex auth through a gateway-mediated mechanism before each Codex cycle.
- Missing unsupported auth fields should fail fast with an actionable preflight error instead of writing synthetic values into
auth.json. - If a transient upstream auth/transport failure does happen, the wrapper should continue to emit a clear structured/sentinel result so the failure mode is not indistinguishable from a generic harness crash.
Reproduction Steps
-
Configure a local
openshellgateway with thecodex-gatorprovider and run gator through the Codex harness. -
Launch a supervised PR watcher, for example:
./scripts/agents/run.sh --agent gator --gateway openshell --name gator-pr-2421-supervised --watch --background "Review and monitor PR #2421 through the gator-gate workflow. Scope this invocation only to PR #2421." -
Inspect the sandbox/launcher log at
scripts/agents/gator/logs/<name>.log. -
When Codex auth is stale, the cycle fails with websocket
401 Unauthorized, then refreshtoken_expired, then exits withoutOPENSHELL_AGENT_RESULT. -
The wrapper retries the cycle as a transient watch failure. In the PR #2421 run, later cycles recovered and completed.
Environment
- OS: Linux local development workstation.
- OpenShell CLI:
openshell 0.0.88on current localmain. - Gateway: local
openshellgateway athttps://127.0.0.1:17670using mTLS. - Agent:
scripts/agents/gator. - Harness: Codex, model
gpt-5.5, reasoninghigh. - Latest release checked: not checked against public releases in this session; investigation was against updated
origin/main. - Possible duplicate issues checked: yes, no open matching issues found.
Logs
Sanitized excerpts from scripts/agents/gator/logs/gator-pr-2421-supervised.log:
ERROR codex_api::endpoint::responses_websocket: failed to connect to websocket: HTTP error: 401 Unauthorized, url: wss://chatgpt.com/backend-api/codex/responses
ERROR codex_login::auth::manager: Failed to refresh token: 401 Unauthorized: {
"detail": {
"message": "Your authentication token has expired. Please sign in again to continue.",
"code": "token_expired"
}
}
ERROR: Your access token could not be refreshed. Please log out and sign in again.
openshell-agent: transient watch failure 1 (missing OPENSHELL_AGENT_RESULT after harness exit 1; upstream transport failure detected); retrying in 30s
The same supervised run later recovered:
OPENSHELL_AGENT_RESULT {"status":"waiting","next_poll_seconds":900,"reason":"merge_ready"}
OPENSHELL_AGENT_RESULT {"status":"complete","reason":"pr_merged"}
Suggested Direction
- Extend the
codex-gatorprovider schema and gator agent manifest to include the realCODEX_AUTH_ID_TOKENif Codex requires it for stable operation. - Stop fabricating fallback ID tokens in
scripts/agents/runtime/harnesses/codex/exec.sh; fail preflight with a clear message when required Codex auth fields are unavailable. - Keep the real refresh token gateway-owned. Do not copy it into the sandbox unless there is a deliberate security decision to do so.
- Add a gateway-brokered refresh hook for supervised agents, such as a small
openshell agent provider-env refreshhelper, so long-lived watcher loops can request fresh provider env before each Codex invocation without exposing refresh tokens inside the sandbox. - Add a regression test or smoke path that verifies stale/expired Codex auth produces an actionable structured failure rather than a missing-sentinel harness exit.
Checklist
- I have searched for existing related issues.
- I included an agent diagnostic section.
- I included the relevant sanitized logs.
- I described the expected behavior and suggested implementation direction.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par scripts/agents/runtime/harnesses/codex/exec.sh, puis examinez scripts/agents/gator/agent.yaml et scripts/agents/gator/providers/codex-gator.yaml pour identifier les champs d’authentification transmis au sandbox. Examinez le comportement du watcher supervisé lorsque OPENSHELL_AGENT_RESULT est absent ainsi que les logs assainis. La tâche est terminée lorsque des informations d’authentification Codex obsolètes ou incomplètes produisent une erreur structurée exploitable ou un chemin de renouvellement pris en charge, avec un test de régression ou un chemin de smoke test.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- rust, shell, yaml
- Domaine
- authentication, devops, security
- Type d'issue
- Bug
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 42/100