Repository navigation
Simplify the Codex harness: drop streamed replies and the terminal App Server route - #7552
Merged
Merged
Conversation
…p Server route
Codex sees little use now, and models answer fast enough that streaming a turn's
final message into the page buys little. This removes the Leaf machinery that
existed only for streamed Codex replies and for the experimental terminal App
Server route. Local Codex still works through its hooks, `codex queue` and, in a
chat the desktop app has open, a turn the app starts. leaf.page still works
through its App Server, with the agent answering by `leaf thread reply`.
What changes for a user or agent:
- Every Codex reply goes through `leaf thread reply`. The `writer: "turn"`
route is gone, with what it needed: reply reservations, the provisional
("Replying") reply the browser drew, posting a turn's final message as the
reply, correction and joined turns, and the page's `stream.json`.
- The panel no longer shows a Codex task's current step read from App Server.
- The terminal App Server route (`leaf codex launch`, `LEAF_CODEX_APP_SERVER`,
`codex-setup.md`) and its `codex-adapter` record are gone. The adapter
starts a turn in an open desktop chat, as before, and otherwise queues.
- A delivery carries every fresh event; the cap of one owed reply per thread
per delivery, which the turn writer needed, is gone, and with it the
`replying` and `interrupted` reasons a stranded update could have.
- On leaf.page, `HostedTurn` follows one turn to its end. Its replies carry no
agent or session identity, since the container's `leaf` is not an installed
copy; the label shown is the same ("Agent").
- A served workflow's `response` is `{id, attempt}`, without the constant
`state`. `reply_visible` feedback no longer carries `attempt`.
- The `delivery` record moves to `since=64` with the `writer` and
`correction` fields gone; eval envelopes are `leaf-delivery/64`.
- `leaf-dev journey run codex` replaces the `codex-app-server` and
`codex-queue` targets. The journey's `codex` wrapper records only the
task's own App Server, so a title-inference server no longer takes over the
queue's route.
Tests: removed the tests of the removed routes (terminal App Server delivery,
turn-written replies, corrections, stream activity) and the eval cases for
turn-written replies (`app-server-edit-before-final`,
`codex-independent-terminal-transports`, and the `turn-` variants of
`resolved-request-stays-owed`). Website tests answer as the agent with
`leaf thread reply`.
Checked: the `codex` and `website-adapter` agent journeys pass every step; the
website hosted-reply eval scores 10/10 on base and head.
leaf-agent
previously approved these changes
Nov 28, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Two leftovers from the removal are in comments outside the diff. The release_on_termination docstring in src/leaf/base/leases.py still says a command "may also own reply reservations", which no longer exist. The PagePool docstring in tests/conftest.py still lists stream.json among the files a served page writes.
#6547 proposes the App Server's thread/fork as the Codex fork carrier. With the terminal App Server route gone, a local Codex task no longer runs on an App Server Leaf can reach, so that issue's plan for Codex needs a new route.
…t step The website journey reached Gone quiet by closing the provider's wait lease, which only a streamed reply read. A hosted turn's progress line is a start on the update, so the receipt goes quiet when that start is older than the working grace; the test now dates the start there and drops the unused lease. Also drops three comments that still described reply reservations, stream.json and the stream activity renewal.
leaf-agent
approved these changes
Nov 28, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 28, 2026
Adds `app_server.follow_turn`, which reads one thread's notifications (buffered ones first) until a turn ends and returns that turn. It replaces three loops that each did this with their own buffering, timing and completion check: Codex inference reading its answer, the website's hosted-turn follower with its `TurnStream` class, and the website's wait for an orphaned turn it interrupted to stop. The diff is line-neutral (+124/−123). The gain is one home for reading a turn to its end, so a change to how turns end lands once. What a reviewer should weigh: - `follow_turn` takes both a `deadline` (inference, and the interrupt wait that holds the user's request open) and a `silence` bound (the hosted turn, whose length is open-ended). Each caller keeps the timing it had. - Inference now keeps the notifications that arrive behind its `turn/start` response, where it used to drop them, and waits for the turn that response names. - The hosted follower's `turn_first_notification` record drops its `buffered` field, which nothing read. The developer `codex_task.Task` stays as it is: it watches every turn of a thread across clients, not one turn to its end. Max asked for this as open item #4 of the Codex harness simplification (#7552). Tests: the website follower, dispatch and answer tests, the inference and title tests, a live Codex inference request, and the `website-adapter` agent journey (passed on a rerun; in the first run the hosted turn ran to its own final answer, but the agent replied without publishing its edit). > _This was written by Claude Code on behalf of max-sixty_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the Leaf machinery that existed only for streamed Codex replies and for the experimental terminal App Server route, since Codex sees little use now and models answer fast enough that streaming a turn's final message buys little. Local Codex keeps its hooks,
codex queue, and the desktop-app router (a chat the app has open still takes input as a turn with no message in the user's name). leaf.page keeps App Server, and the agent there answers withleaf thread replylike everywhere else.Size: product code (
src/, browser runtime) is about −3,360 lines net, of which about 950 are outsidesrc/leaf/agents: records, served state, base, commands and the browser runtime. Tests are −8,122, evals −426.What a reviewer should weigh:
leaf thread reply. Thewriter: "turn"route goes, with reply reservations, the "Replying" provisional reply, correction and joined turns,stream.json, and the panel's live Codex step.replying/interruptedstranded reasons go.deliveryrecord moves tosince=64;codex-deliverykeeps its schema.leaf_deliveryturn start, hosted turns and inference. Dropping the terminal route leaves Run Leaf's forks in Codex and Pi #6547's Codex forks open, sincethread/forkworks from an App Server Leaf starts itself, desktop chats included.Asked for by Max, who approved both removals; reviewed by Codex and a fresh Claude Code pass. The
codexandwebsite-adapteragent journeys pass every step, the website hosted-reply eval scores 10/10 on base and head, and the runtime tests, Worker checks and focused model/process tests pass.