Skip to content

Add a basic paired eval of Claude Code delivery handling - #1074

Merged
max-sixty merged 5 commits into
mainfrom
codex-app-server-terms
Sep 24, 2026
Merged

max-sixty merged 5 commits into
mainfrom
codex-app-server-terms

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

scripts/eval_claude_delivery.py runs headless Claude Code sessions, one
with a base ref's plugin and one with this checkout's, at the same time.
Each serves the same page, starts its background leaf wait, and gets
one real comment over HTTP. The script reports seconds from the comment
to pickup and to the first reply, the actions before leaf wait --ack,
and any acknowledgement command the agent invented. claude -p keeps a
background shell alive while stdin stays open, so each session runs with
--input-format stream-json and the comment arrives through Claude
Code's own task notification.

A session ends 20 s after the turn the comment woke, or at a ten-minute
deadline that kills it and marks the run timed out. A failed run stops
its session and server either way.

It is basic and imperfect: four rounds, one page, one comment shape, a
fresh session, and substring scoring. Its docstring lists these limits.

It settles the TODO item on checking each carrier's delivery route after
#1068, which this change removes:

  • App Server: 4 of 4 verify_site.py local runs passed. None invented an
    acknowledgement command or posted an early leaf reply.
  • Claude Code: 4 paired rounds against a7cd8cd, the commit before Write each delivery's handling for the carrier that freezes it #1068.
    Every run in both arms acknowledged as its first action after reading
    the envelope, and none invented a command. Pickup took 8, 7, 11 and 8 s
    before and 5, 5, 10 and 9 s after. A smoke run of this script against
    main gave the same picture.

🤖 Generated with Claude Code

This was written by Claude Code on behalf of max-sixty

scripts/eval_claude_delivery.py runs headless Claude Code sessions, one
with a base ref's plugin and one with this checkout's, at the same time.
Each serves the same page, starts its background `leaf wait`, and gets
one real comment over HTTP. The script reports seconds from the comment
to pickup and to the first reply, the actions before `leaf wait --ack`,
and any acknowledgement command the agent invented. `claude -p` keeps a
background shell alive while stdin stays open, so each session runs with
`--input-format stream-json` and the comment arrives through Claude
Code's own task notification.

It is basic and imperfect: four rounds, one page, one comment shape, a
fresh session, and substring scoring. Its docstring lists these limits.

It settles the TODO item on checking each carrier's delivery route after
#1068, which this change removes:

- App Server: 4 of 4 `verify_site.py local` runs passed. None invented an
  acknowledgement command or posted an early `leaf reply`.
- Claude Code: 4 paired rounds against a7cd8cd, the commit before #1068.
  Every run in both arms acknowledged as its first action after reading
  the envelope, and none invented a command. Pickup took 8, 7, 11 and 8 s
  before and 5, 5, 10 and 9 s after. A smoke run of this script against
  main gave the same picture.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

The session cutoff can stop the very delivery this eval measures. Once the comment is posted, the first result can still be the setup turn that served the page and launched leaf wait; line 166 starts a 20-second timer without checking whether the wait notification arrived or the comment was handled. If that route takes longer than 20 seconds, closing stdin ends the Claude session and can leave reply_s empty because the evaluator stopped it. Tie shutdown to the comment's reply and the end of its handling turn, with the overall timeout as the failure bound.

max-sixty and others added 2 commits September 23, 2026 19:39
The setup turn's own result could arrive after the comment was posted and
start the 20-second shutdown before the delivery woke the session. The
timer now starts only on a result that follows the wait's completion
notice, with TURN_LIMIT as the failure bound.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A wait notification that lands while the setup turn is still running
set the delivery flag before that turn's result, so the result could
still start the shutdown timer. The setup turn is always the first
result, so the timer now skips it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

The eval still needs a deadline that fires when Claude stops producing stream records.

Comment thread scripts/eval_claude_delivery.py Resolved
A session that stopped writing stream records left the read loop
blocked, since the time check ran only on the next line. A timer now
kills the child at TURN_LIMIT and marks the run timed out, and the
results table says so.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

The new deadline survives failures in the stream loop. If json.loads(line) raises on a truncated record, or post_comment(url) raises because the local server has stopped, run_session exits before deadline.cancel() and before it stops the Claude process. Python's non-daemon threading.Timer then keeps the eval process alive until TURN_LIMIT (ten minutes), and the failed run does not reach its event capture or server cleanup. Put cancellation and child cleanup in a finally around the stream loop so a failed arm ends promptly as well as a stalled one.

An exception in the stream loop, such as a truncated record or a comment
post to a stopped server, skipped the deadline's cancel, the child's
shutdown and the server stop, so the timer held the process open for
TURN_LIMIT. Those now run in a finally.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit ab7d273 into main Sep 24, 2026
5 checks passed
@max-sixty
max-sixty deleted the codex-app-server-terms branch September 24, 2026 03:41
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