8000 A missing Codex login ends the run; a host failure keeps its spend by iamziyuzhao · Pull Request #129 · Infini-AI-Lab/hermit · GitHub
[go: up one dir, main page]

Skip to content

A missing Codex login ends the run; a host failure keeps its spend - #129

Open
iamziyuzhao wants to merge 6 commits into
mainfrom
fix/codex-signin-and-failed-spend
Open

iamziyuzhao wants to merge 6 commits into
mainfrom
fix/codex-signin-and-failed-spend

Conversation

@iamziyuzhao
@iamziyuzhao iamziyuzhao commented Nov 26, 2026 •
Copy link
Copy Markdown
Collaborator

Change

Two failure paths lost what a run must know. They were found while patching #118 (its simulated user runs on a Codex chat endpoint on the ChatGPT login).

No ChatGPT login to copy. login.prepare raised a plain RuntimeError when there was neither the user's login file nor the run's copy ( 10000 codex login never run, or its file gone). A rollout took it for a task failure and the run went on to the next task, each failing the same way; a chat endpoint answered 502, which its client retried; the Trainer recorded a failed step when the Evolver's own call met it. Its error now carries Hermit's lost-sign-in mark ([hermit_login_failed]) when both the user's login file and the run's shared copy are known to be absent (a file that could not be read, being written or in a folder this process cannot pass, stays that session's failure, as before): a rollout already reads the mark as LoginFailed and ends the run, the chat endpoint answers it 401 with the code hermit_login_failed (ChatEndpoint.answer), and the Trainer ends the run when the Evolver's call raised it (_raise_login_failed). hermit train checks the login only at its start, so this is a login file gone during a run (or never made, for a chat endpoint started otherwise). Restore it (codex -c 'cli_auth_credentials_store="file"' login, as the Codex plan tutorial says) and hermit train resumes after the last finished step; the troubleshooting guide gains that row.

A host failure's spend. A rollout that failed on this machine (an OSError: host_failed, never run again) dropped what its agent said it spent (exc.spent), which every other failure path of environment_rollout keeps.

A container worker (environment.image) runs in a folder of its own: ContainerAgent now hands it a relative login_root made absolute where preflight and a session name it (as it already did the plan's folder), so the worker looks for the shared copy where preflight found it.

Core changes: hermit/agent/base/login.py (prepare, _absent), hermit/agent/base/endpoint.py (ChatEndpoint.answer), hermit/trainer/trainer.py (_raise_login_failed), hermit/trainer/rollout.py, hermit/isolate.py (ContainerAgent); docs/guides/troubleshooting.md. No interface changes; a changelog entry under Unreleased, Fixed.

Not in this PR: two core issues, open for the maintainers

Both were in an earlier head of this PR (05906f6, ede8963). Two independent audits showed that a safe fix for each needs more design than a bug fix, so both were taken out (this head changes neither path).

  1. A Codex session on the ChatGPT login outside a task's container never reports a lost sign-in. Codex.outcome reads one from the stream only for isolation == "remote". A chat endpoint's or sandbox's session whose login was refused is a plain failure: the endpoint answers 502 and its client retries. Reading the same notices there (as the earlier head did) can stop a run that would recover: a refresh refused because another session rotated the shared login meanwhile (its copy stale, possibly in a task worker's private login root), a usage-limit refusal after an MCP server's 401, an outage notice before the terminal error. A fix needs the stream's terminal error, not every earlier notice; a stale-copy check against the login's owner, with a bounded wait for an in-flight refresh; and a retry from the newer login.
  2. A restart after a first step stopped between its commit and its line in steps.jsonl runs that commit as the start. With nothing recorded, _prepare reuses the checkout as it is. Resetting it (as the earlier head did) runs git reset --hard and git clean -fdx. Before that is safe, the fix has to verify the worktree is the run's own branch (a worktree switched to another branch was reset), keep an adopted branch's tip (a later launch rewound it to the root), clear the learner state whether or not the head moved, and read a torn first journal line as no record.

Validation

  • New tests, each failing on main and passing here:
    • tests/core/test_cli_agent.py::test_a_login_session_with_no_login_to_copy_is_a_lost_sign_in (the marked error; the endpoint's answer through its real path: 401, hermit_login_failed; a login file there but unreadable, or in a folder this process cannot pass: unmarked)
    • tests/core/test_training.py::test_a_missing_login_met_in_the_evolvers_own_call_ends_the_run (through train(): the run ends, the step unrecorded)
    • tests/core/test_harbor_environment.py::test_a_failure_of_this_machine_keeps_what_the_run_spent
    • tests/core/test_isolate.py::test_a_container_worker_takes_a_relative_login_root_as_preflight_did
  • python -m pytest --changed --base origin/main (every group: hermit/agent/base/ is shared): 3 failed, 1781 passed, 172 skipped (every group selected). The 3 failures fail on main too: tests/core/test_harbor_environment.py::test_rrsi_sees_a_harbor_rollouts_failure_and_a_cli_model_is_refused_for_harbor and tests/methods/harness2/test_harness2_on_pi.py::test_what_a_pi_session_spent_is_kept_when_it_times_out_or_is_stopped (timed_out, cancelled).

Review

  • Tests and documentation cover the affected behavior, where applicable: the tests above; the troubleshooting row; the docs already say a lost sign-in ends the run; changelog entry.
  • Commands, defaults, and public interfaces are consistent: no setting or interface changes.
  • Agents follow the agent layers: no agent added.
  • Shared logs and examples contain no credentials or private data.
  • Documentation-only: not applicable.
  • Core changes. Yes, the files listed in Change, for the reasons given there.
  • Implementation correctness and failures. The mark is added only where a login is missing (login.prepare), so nothing that could recover ends the run; the endpoint and the Trainer act on the mark alone. A method that catches the error itself before the Trainer sees it (AHE's debugger, RRSI's step handler) still handles it as it did, as a plain failure.
  • Real execution paths and tests. Codex.run with no login file raises the marked error; a request answered through the endpoint's real path (ChatEndpoint.answer, cli_answer, Codex.run) gets 401; environment_rollout with a pipeline that raises an OSError carrying its spend.
  • This description. Read back against the diff.
  • Independent review (post-PR audit). Five audits (Codex gpt-6.2-astra, high effort, read-only). The first two, on the earlier heads, found the issues above. The fifth, on d9d1182: fixed here, the container worker's login_root expanded ~ where preflight and a session do not (now named as they name it), the troubleshooting row now says what to check when the file is there, a cut comment; recorded, a relative CODEX_HOME in a container run (the worker's own folder resolves it). The fourth, on 5c53472: fixed here, a login file in a folder this process cannot pass was marked on Python 3.14 (whose Path.is_file says False; absence is now its stat's word), a container worker looked for a relative login_root in its own folder, the Claude troubleshooting row now names its login, the changelog's wording; recorded, a host failure's record scrubs the log its spend names, as every failure path that keeps a log does, and a read-only log holding a key would fail that write. The third, on b465aac: fixed here, a login file that exists but could not be read was marked (now only an absent one is), the troubleshooting row's login command (now the file-based cache the tutorial documents), the changelog's wording, and a test through train(). Recorded, not fixed (each needs an input no producer here makes): a task prepare callback that deletes a task worker's private Codex login (none in the repo does) would end the run, though the host's login is good; the mark's text anywhere in an exception counts (an Evolver prompt file named hermit_login_failed.md, say); the answer agent keeps the last 1,000 characters of a refusal, so a login path over about 900 characters would hide the code.

🤖 Generated with Claude Code

iamziyuzhao and others added 3 commits November 25, 2026 20:23
…lure's spend, an unrecorded first step

- Codex.outcome reads a lost sign-in from Codex's stream for a login session outside a task's
  container too (it did only inside one): the chat endpoint answers 401 hermit_login_failed and
  the run ends, instead of a 502 its client retried while the run went on.
- login.prepare names a missing ChatGPT login with Hermit's lost-sign-in mark: a rollout's
  LoginFailed, the endpoint's 401 (ChatEndpoint.answer reads it).
- environment_rollout keeps what an agent said it spent on a host failure (an OSError), as its
  other failure paths do.
- Trainer._prepare resets the checkout to the start when nothing is resumed: a first step (or the
  Evolver's bootstrap) stopped between its commit and its steps.jsonl line left the restart on
  that unrecorded commit.

Found while patching #118.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n's own unrecorded first step

- A Codex session on this machine whose copy of the ChatGPT login another session's refresh
  replaced meanwhile is retryable, not a lost sign-in; so is a turn the provider could not serve
  (an MCP server's 401 before it).
- The endpoint answers a lost sign-in 401 also when the session ran out its clock.
- A missing login met inside the Evolver's own call ends the run (Trainer._raise_login_failed
  reads the mark).
- The checkout is reset only when it is this run folder's own and steps.jsonl records no step (an
  empty journal included), to the start its config.yaml saved, and the stopped step's learner state
  goes with it; a branch of that name with no checkout here is left as it is.
- Troubleshooting: a row for Codex's login; codex_stream's docstring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two audits found that the other two fixes need more design than a bug
fix: reading a lost sign-in from a local Codex session's stream (an
earlier notice, an MCP server's 401 or a stale login copy can reverse
its terminal outcome), and resetting the checkout after a first step
stopped before its record (another branch, an adopted tip, learner
state). Both are taken out and left open in the PR description.

Kept: login.prepare marks a missing ChatGPT login as a lost sign-in,
the chat endpoint answers it 401 (hermit_login_failed), and the Trainer
ends the run when the Evolver's own call raises it; a rollout that
failed on this machine (OSError) keeps what its agent said it spent.
The endpoint test goes through the real request path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamziyuzhao iamziyuzhao changed the title Three failure paths: a Codex sign-in lost on this machine, a host failure's spend, an unrecorded first step A missing Codex login ends the run; a host failure keeps its spend Nov 26, 2026
iamziyuzhao and others added 3 commits November 25, 2026 21:43
The third audit: a Codex login file that exists but could not be read
(being written, say) was marked as a lost sign-in and ended the run;
now only an absent one is, and an unreadable one stays that session's
failure, as before. The troubleshooting row gives the file-based login
the Codex plan tutorial documents, the changelog says the start-up
check covers only the start, and the Trainer's test runs through
train().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fourth audit: on Python 3.14 Path.is_file says False for a file in
a folder this process cannot pass, so such a login was marked lost;
the mark now needs both files' stat to say they are absent. A container
worker runs in a folder of its own: ContainerAgent hands it a relative
login_root made absolute, as it already did the plan's folder. The
Claude troubleshooting row names its login; the changelog says both
files must be gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fifth audit: the container worker expanded `~` in its login_root
where preflight and a session do not, so a shared copy preflight found
was looked for elsewhere; the root is now made absolute only. The
troubleshooting row says what to check when the login file is there;
a cut comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant

0