Skip to content

Title threads that an App Server turn answers, and show the placeholder only while one is coming - #1401

Merged
max-sixty merged 10 commits into
mainfrom
site-stuck-generating
Sep 28, 2026
Merged

max-sixty merged 10 commits into
mainfrom
site-stuck-generating

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

On leaf.page a new thread's row read "Generating title" forever. A title is a thread_title event, which the agent writes by adding --title to leaf thread reply. But a turn Leaf starts over Codex App Server (the website, and leaf codex start) writes its reply from the turn's own messages, and leaf thread reply refuses that event. The delivery still asked for --title, so nothing could ever name the thread. The browser, meanwhile, showed the placeholder for any untitled thread whether or not anything would name it.

What changes

  • skills/leaf/scripts/leaf/codex_titles.py (new): when an App Server carrier starts a turn, it also names each untitled thread that turn answers. That is one ephemeral App Server thread per title whose whole context is the thread's first message and its anchored passage, with no tools and every configured MCP server disabled by name. It runs beside the turn and never delays it. The title is written as the page's claimant, only while the thread is still untitled. Wired into worker/leaf_website (on gpt-5.6-luna) and codex_adapter.start_delivery_turn (on the task's model).
  • registry.json: the "add a title" handling clause now applies only to answer.kind == "reply", so a turn-carried agent is no longer told to do something it can't.
  • thread-card.js: the placeholder shows only while the agent's workflow on the thread is under way (attention.kind == "waiting", reason == "workflow"). A thread whose turn ended, stalled, was never picked up, or was answered without a title reads its opening words.
  • LEAF_THREAD_CONFIG in codex.py: threads Leaf starts no longer load Codex defaults they never use (skills, plugins, multi-agent, memories, browser/image tools, web search).
  • Instrumentation: each hosted turn's turn_stream_completed record carries model-request and token counts; new thread_title_generated/skipped/failed records (documented in worker/README.md); leaf-dev verify-site reports titledMs.

Measured (leaf-dev verify-site local, alternating arms)

main (4 runs) branch (3 runs)
Title arrives never 4.7–7.0 s
First reply text visible 3.4–6.2 s 3.3–4.0 s
Reply complete 15–21 s 16.8–17.2 s
Hosted agent input tokens per turn 80.8k (1 run) ~35k

A title request costs ~1.9k input tokens and ~3 s at the median; about 1 in 10 took 18–28 s.

Weak points

  • Each new thread adds one model call against the container's 20-calls-per-minute limit.
  • If the reply lands before the title, the row shows the opening words briefly, then the title.
  • The browser infers "a title is coming" from workflow attention rather than a fact the server states directly.
  • Claude Code threads still get their title only with the agent's reply (recorded in TODO.md).
  • Not verified against production or verify-site wrangler.

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

max-sixty and others added 8 commits September 28, 2026 00:10
On leaf.page a new thread read "Generating title" for good. A thread gets its title
from a `thread_title` event, and the delivery told the agent to add `--title` to
the reply that answers it. On Codex App Server, though, the turn's own messages
are the reply, and `leaf thread reply` refuses that event, so the hosted agent had
no command that could name the thread. A local run of the hosted-agent benchmark
on main replied at 19.5 s and never titled the thread.

The carrier that starts an App Server turn now names each untitled thread that the
delivery answers (`codex_titles`). Each title comes from one ephemeral App Server
thread that sees only the opening message, the passage it is anchored on, and a
one-line instruction. Codex's tools, skills, plugins, memories and AGENTS.md are
turned off for it. On the website's Codex (0.153.4) and model (`gpt-5.6-luna` at
low effort), a request reads about 1,900 input tokens instead of 13,000–15,000,
and it returns a title in about 3 s at the median. With a shell, the model
sometimes acted on the message instead of naming it. The title request runs
beside the turn without delaying it. It is written under the page's claim, and
only while the thread is still untitled.

Both App Server carriers title this way. The website uses its hosted model, and
`leaf codex start` uses the task's configured model. The "no title yet" handling
clause now applies only to an event that owes a plain `reply`. Before, it applied
to every event in an untitled thread, including events answered by an App Server
turn, which could not follow it.

`verify_site.py` now records a `titled` milestone. `local` gives the adapter its
own temporary directory, because an App Server left behind by an earlier run held
the fixed socket path and made the next server exit on start.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
turn_stream_completed now carries how many model requests the turn made and the
input, cached input and output tokens they summed to, so a benchmark or an
Observability query can read a turn's context cost beside its duration.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The hosted task and each title thread now start with LEAF_THREAD_CONFIG, which
turns off what Codex loads by default and no Leaf-started thread uses: the skills
list, plugin and app suggestions, other agents, memories, browser and computer
use, image generation and web search. A title thread also drops every tool and the
working directory's AGENTS.md. Web search was also the one route to the network
the hosted task is told to stay off.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The thread row read "Generating title" for as long as a thread had no title,
whether or not anything was going to name it. An agent that answered without
`--title`, a title request that failed, or a thread the user closed all left it
there for good. The placeholder now stands only while the thread waits on the
agent, which is when a title is on its way: on an App Server turn it comes from
the carrier beside the turn, and on other carriers from the reply. Once the
thread no longer waits on the agent, the row reads the thread's opening words.

The carrier's title request now reads the thread from the page log and uses its
first spoken message and the passage it is on. Before, it rebuilt the opening
from the delivery's digest, which leaves out the batch's own messages. When a
user commented and then added "also, thanks" before the turn started, the title
was drawn from the afterthought. A thread with no words to title from is recorded
as skipped. A refused title is recorded without its words, because they come
from the user's. Both carriers start titling after the turn has started, and the
generated event is built by the same `title_event` constructor as `leaf thread
--title`.

Behavior moved: `test_packages_and_panel_share_threads_through_gestures_and_
authored_content` asserted the placeholder on a thread the agent had already
answered; it now reads the opening words.

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

A title thread on `leaf codex start` runs in the user's own App Server, and a
probe with an MCP server configured showed the thread starting it. Replacing the
`mcp_servers` table in the thread's config left it running, and turning each
server off by name stopped it, so the title request reads the configured servers
through `config/read` and disables each one. Codex 0.153.4, the website's
version, has `config/read` too.

worker/README.md, which owns the hosted-turn record contract, now names the
`thread_title_*` records and the token fields on `turn_stream_completed`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	dev/leaf_dev/verify_site.py
A thread whose turn ended, stalled, or was never picked up read "Generating
title" beside "Turn ended" or "Waiting for pickup" for good, because
attention `waiting` covers those conditions too. The placeholder now also
requires the served reason `workflow`, so those threads read their opening
words.

The feature gallery's pending-title demo was a thread the agent opened, which
nothing is naming, so it now reads the question. Its text says so and
describes the placeholder a thread the user opens shows while the agent works;
the two gallery tests assert the question, and the corpus is regenerated. A new
render test covers a comment nobody picked up.

Title requests now read the MCP server list and start their thread in the
page's directory, so a project's own servers are turned off along with the
user's.

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 hosted title request sets sandbox: "read-only" in codex_titles.generate_title, while the hosted task deliberately uses danger-full-access because the Cloudflare container cannot create Codex's nested bubblewrap namespaces (see WebsiteCodexHost._start_thread and worker/README.md, “The container”). That leaves the new hosted title path dependent on whether App Server initializes the read-only sandbox for a tool-free turn; the mock App Server test does not exercise this. Pass the carrier's sandbox policy into the title request and use the hosted policy in the container, with tools still disabled, then verify that the Wrangler journey records a thread_title event. Until that path works, the PR's central leaf.page fix remains unverified.

The website's container cannot create Codex's bubblewrap namespaces, so the
hosted task runs with danger-full-access. A title request asks for read-only.
Run in the website's image (Codex 0.153.4), with `codex sandbox linux` failing
there as the control, two read-only title requests returned titles in ~6 s:
a sandbox confines only the tools a turn runs, and a title turn has none.

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

Copy link
Copy Markdown
Owner Author

Measured rather than changed. I ran codex_titles.generate_title inside the website's own image (Dockerfile.website, Codex 0.153.4) under Docker, where Codex's sandbox cannot start: the control, codex sandbox linux -- echo, fails with bwrap: Creating new namespace failed. Both read-only title requests returned titles in ~6.3 s ("Nightly Export Timing", "Update Main Heading"; ~1.9k input tokens each). A sandbox confines only the tools a turn runs, and the title turn has none, so read-only never reaches bubblewrap. Passing the carrier's policy through would thread a parameter to a setting that has no effect here. f5de3df records the reason beside the setting.

The Wrangler journey (verify-site wrangler --agent) is still unrun: it needs an OPENAI_API_KEY this session doesn't have.

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

# Conflicts:
#	skills/leaf/assets/runtime/thread/thread-card.js
#	skills/leaf/scripts/AGENTS.md
leaf-agent
leaf-agent previously approved these changes Sep 28, 2026
@max-sixty
max-sixty merged commit de93c77 into main Sep 28, 2026
5 checks passed
@max-sixty
max-sixty deleted the site-stuck-generating branch September 28, 2026 17:55
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