Repository navigation
Use completed Codex replies on hosted pages - #485
Conversation
# Conflicts: # skills/leaf/scripts/leaf/codex.py # tests/test_interact_session.py
leaf-agent
left a comment
There was a problem hiding this comment.
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.
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_
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.The deployment gate's separate asynchronous-revision fix remains owned by #483.
Validation
uv run pytest tests— 959 passeduv run pytest tests/test_interact_session.py tests/test_website_server.py— 174 passedpre-commit run --all-files