Skip to content

Use completed Codex replies on hosted pages - #485

Merged
max-sixty merged 4 commits into
mainfrom
codex/hosted-leaf-agent
Sep 9, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex/hosted-leaf-agent

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

The hosted agent can publish the requested page edit yet omit an explicit leaf reply, leaving the reader with an empty-result receipt even though Codex produced a final response.

  • Consume the merged App Server event reader's completed response as the reply only when the agent left the accepted Leaf input unanswered.
  • Preserve exact-turn settlement and explicit Leaf reply precedence.
  • Keep every accepted input recoverable: failed turns use the failure receipt, empty completed turns use the empty-result receipt, and invalid model-authored media references fall back to that same receipt.

The deployment gate's separate asynchronous-revision fix remains owned by #483.

Validation

  • uv run pytest tests — 959 passed
  • uv run pytest tests/test_interact_session.py tests/test_website_server.py — 174 passed
  • pre-commit run --all-files

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two findings on the worker half, and one overlap to decide.

The final message is agent-authored text, and cmd_reply is a CLI door that exits. read_text_arg runs text_media_errors over every body and calls sys.exit when a Markdown destination under /media/ isn't in the page directory. worker/server.py already knows this — the AGENT_REPLY_PATH branch of _post wraps its own cmd_reply in except SystemExit as error: and answers 400. _finish_turn now sends the same class of text through the same door with no such guard, and its caller _follow_turn catches (OSError, RuntimeError, ValueError, WebSocketException), which SystemExit is not. So a final message carrying an unresolvable /media/… reference raises past the follow loop, and threading swallows SystemExit without a traceback: the Leaf claim turn has already been closed by the transaction above, the pending obligations get no receipt at all, and nothing is logged. That is strictly worse than the MISSING_REPLY it replaced, and it undoes the deterministic-receipt guarantee this PR's summary says it preserves. The fix is either the except SystemExit the reply endpoint already uses, falling back to MISSING_REPLY, or screening the candidate with text_media_errors before it becomes the fallback. Both are outside the diff hunk — happy to push whichever you prefer.

worker/README.md and the code disagree about a failed turn. The new sentence makes the failure receipt conditional on the absence of a final message, so a failed turn that did emit one reads as receiving that message. _finish_turn never consults final_message unless status == "completed" — a turn that streamed a message and then failed still gets GENERATION_FAILURE_REPLY. session-lifetime.md's version of the same rule is the accurate one; the README is the one to correct. Inline suggestion below.

scripts/verify-site.py overlaps #483. #483 rewrites the same verify_agent_turn reads with the same diagnosis — the gate reading the page before the turn's outcome landed — and goes further: it waits on the published document rather than the first revision to appear, checks the revision the browser followed separately from the heading it rendered, and relaxes the heading to a containment. The two will conflict textually, and #483's production evidence is directly relevant to the worker half here: two of the three hosted turns it ran completed with no reply at all and settled on MISSING_REPLY, which is the case this PR is fixing. Worth deciding which side carries the gate change rather than landing both.

Comment thread worker/README.md Resolved
Comment thread worker/server.py Resolved
@max-sixty
max-sixty merged commit ba3d487 into main Sep 9, 2026
16 checks passed
@max-sixty
max-sixty deleted the codex/hosted-leaf-agent branch September 9, 2026 05:20
max-sixty added a commit that referenced this pull request Sep 9, 2026
Once the website accepts a reader message, a failure on the App Server
connection that follows the turn currently clears transient activity and
exits. The durable pickup remains, so the thread can stay unanswered
indefinitely.

Route that failure through the existing terminal settlement path. It
closes the matching Leaf turn, logs the stream error, and posts the
ordinary generation-failure reply only for still-pending input.
Successful turns retain the completed assistant-message behavior from
#485.

Validation: `uv run pytest tests` (966 passed), plus changed-file
pre-commit checks.

> _This was written by Codex on behalf of max-sixty_
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.

2 participants