Skip to content

Simplify the Codex harness: drop streamed replies and the terminal App Server route - #7552

Merged
max-sixty merged 3 commits into
mainfrom
simplify-codex-harness
Nov 28, 2026
Merged

max-sixty merged 3 commits into
mainfrom
simplify-codex-harness

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

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 with leaf thread reply like everywhere else.

Size: product code (src/, browser runtime) is about −3,360 lines net, of which about 950 are outside src/leaf/agents: records, served state, base, commands and the browser runtime. Tests are −8,122, evals −426.

What a reviewer should weigh:

  • Every Codex reply now goes through leaf thread reply. The writer: "turn" route goes, with reply reservations, the "Replying" provisional reply, correction and joined turns, stream.json, and the panel's live Codex step.
  • A delivery now batches every fresh event; the one-owed-reply-per-thread cap and the replying/interrupted stranded reasons go.
  • On leaf.page, replies carry no agent or session identity; the label shown is unchanged ("Agent").
  • The delivery record moves to since=64; codex-delivery keeps its schema.
  • The App Server pieces later work builds on stay: the transport, Leaf-started servers, the leaf_delivery turn start, hosted turns and inference. Dropping the terminal route leaves Run Leaf's forks in Codex and Pi #6547's Codex forks open, since thread/fork works 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 codex and website-adapter agent 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.

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

…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
leaf-agent previously approved these changes Nov 28, 2026

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

Comment thread src/leaf/records/transaction.py Resolved
…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.
@max-sixty
max-sixty merged commit d49a7e3 into main Nov 28, 2026
8 checks passed
@max-sixty
max-sixty deleted the simplify-codex-harness branch November 28, 2026 23:07
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_
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