Repository navigation
Add a basic paired eval of Claude Code delivery handling - #1074
Conversation
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
left a comment
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
The eval still needs a deadline that fires when Claude stops producing stream records.
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
left a comment
There was a problem hiding this comment.
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]>
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 getsone 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 -pkeeps abackground shell alive while stdin stays open, so each session runs with
--input-format stream-jsonand the comment arrives through ClaudeCode'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:
verify_site.py localruns passed. None invented anacknowledgement command or posted an early
leaf reply.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