Skip to content

Run Leaf's forks in Codex and Pi #6547

Open

Description

@max-sixty

Leaf's forks run only in Claude Code: the line fork that writes the agent's working line on a thread message (forks.py), the summary fork (summary_fork.py) and the turn-end check (clerk.py). Each is one call of the conversation that calls no tool. In Codex and Pi, the main session answers every thread message with no working line from Leaf, and no turn-end check runs.

Since #6438, Leaf's Python decides every fork, and Claude Code's hooks module only carries out its instructions (fork, complete) and reports back what came of them (carrier.py). So each harness needs a carrier of its own, not new fork logic:

  • Codex: the App Server's ephemeral thread/fork.
  • Pi: the extension (hooks/pi.ts) resending its session, as clerk.py's header proposes.

Giving a thread message's work to a background agent needs nothing from Leaf: since #6574 the main session decides that itself, through its harness's own subagent tool.

Check first whether OpenAI's prompt cache serves a forked thread's prefix, and whether Pi's providers cache a resent session. Without a cache hit, each fork reads the whole conversation at the full price: on Claude, a 200k-token conversation costs about $0.10 cached and about $1 uncached.

This waits until the Claude Code forks have been in use for a while, so the carrier contract the other harnesses implement has settled.

From open item #59 on the fork-messages page, at Max's request.

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

Activity

  1. added
    backlog
    on Nov 19, 2026
  2. max-sixty commented on Nov 29, 2026

    @max-sixty
    OwnerAuthor

    The check this issue asks for is done, and the cache doesn't serve a Codex fork. On codex-cli 0.170.0, a plain thread/fork keys the prompt cache by the fork's own thread id. Its first turn read 0–27% of a 117–231k-token conversation from cache, even when the parent thread had been active seconds earlier. The fork's second turn read 94%, so each one-call fork would pay full price for the whole conversation.

    experimentalPredictionMode on thread/fork keys on the parent's id and caches about 99%, but it refuses (requires a loaded parent) unless the parent is loaded on the same App Server. A user's Codex session is loaded by their desktop app or terminal client, which holds its writer lock, so an App Server Leaf starts can't load it. Prediction mode would work only for leaf.page, whose App Server Leaf owns.

    I've asked upstream for a cache key on thread/fork or a way to inherit the parent's key: openai/codex#21796.

    If nothing there helps by 2026-12-02, Leaf won't run its forks in Codex, and this issue narrows to Pi.

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlog

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions