Skip to content

leaf thread create --part tells the agent when the visual doesn't draw the part #7039

Done

Description

@max-sixty

leaf thread create --part ID accepts any id that starts with a prefix the visual declares, whether or not the visual draws that part. An agent that mistypes an id gets the same success record as for a real part, and leaf page check --render afterwards reports nothing. On the page, the thread stands on the whole visual. A timeline shows its marker in the margin, level with the timeline's top and labelled "timeline · Deploy order · event:nope", so the user can't tell which event the question is about. In the trial behind #7006, both authors of a pipeline visual noticed that the command took a part their visual never draws. That visual marks its parts with data-lf-part, and the agent driving one of those pages saw no marker at all for such a thread (not rerun here).

Reproduction, from a checkout's root:

export XDG_STATE_HOME="$PWD/.tmp/part/state"
bin/leaf page init .tmp/part/page --package reading --package timeline
cat > .tmp/part/page/index.html <<'EOF'
<!doctype html>
<html lang="en">
  <head>
    <title>Deploy order</title>
    <meta name="description" content="The order of last night's deploy, by job." />
  </head>
  <body>
    <main>
      <section id="order">
        <h1>Last night's deploy</h1>
        <lf-timeline id="deploy-order" aria-label="Deploy order">
          <lf-lane label="Build">
            <lf-event id="deploy-compile" at="0" end="4000" label="Compile"></lf-event>
            <lf-event id="deploy-artifact" at="4000" label="Artifact ready"></lf-event>
          </lf-lane>
          <lf-lane label="Release">
            <lf-event id="deploy-rollout" at="4500" end="9000" label="Roll out"></lf-event>
          </lf-lane>
        </lf-timeline>
      </section>
    </main>
  </body>
</html>
EOF
# The timeline draws event:deploy-compile, event:deploy-artifact and event:deploy-rollout.
bin/leaf thread create .tmp/part/page --section deploy-order --part event:nope --text "Is this the slow step?"
bin/leaf thread create .tmp/part/page --section deploy-order --part step:nope --text "Is this the slow step?"
bin/leaf page check .tmp/part/page --render | jq -c '{status, findings: [.findings[].code]}'

The first thread create prints a comment record with "anchor": {"section": "deploy-order", "visual": "event:nope"}. The second is refused: § deploy-order has no visual part 'step:nope'; ids starting with 'event:'. The check prints {"status":0,"findings":[]}.

What the page shows for that thread, read from a fresh build of the same page with the comment in its log:

cp .tmp/part/page/index.html .tmp/part/deploy.html
echo '{"kind":"comment","author":"agent","agent":"Claude","revision":1,"id":"undrawn","text":"Is this the slow step?","anchor":{"section":"deploy-order","visual":"event:nope"}}' > .tmp/part/log.jsonl
uv run leaf-dev probe .tmp/part/deploy.html --log .tmp/part/log.jsonl \
  --js '() => [...document.querySelectorAll(".lf-margin-marker")].map((marker) => marker.getAttribute("aria-label"))' \
  | jq -c .result

It prints ["Thread, 1 unread, timeline · Deploy order · event:nope"].

Expected. The agent learns that event:nope names no part the timeline draws, at thread create or at the next check that draws the page, with the parts it does draw.

Ran on a34788414e, macOS 26.5: Chrome 158 for the check, Playwright 1.65.2's Chromium for the probe.

Cause, confirmed. registry.contract.VisualParts admits an id by its prefix alone, and its docstring says "Admission does not say a part is on screen; the browser resolves that." Only the visual's module knows the parts it draws, and nothing carries the browser's answer back to the agent. Root AGENTS.md says "Python never accepts an anchor the rendered page can't resolve."

Where the build met it. The trial in #7006, where twelve agents new to Leaf each built a package from the shipped references alone.

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

Activity

  1. added
    bug
    agent-experience
    on Nov 24, 2026
  2. leaf-agent commented on Nov 24, 2026

    @leaf-agent
    Collaborator

    Confirmed from the code on 93ebc4dbef; no fix PR yet, because the repair needs a contract the runtime doesn't have, and it changes what thread create --part costs.

    Why nothing can answer today. A visual has no way to say "this id names none of my parts":

    • capture_anchor checks the id against the visual's prefixes only (anchor_capture.py#L193), and no browser runs for --part.
    • In the browser, an admitted id the visual doesn't currently draw falls back to the whole visual whenever its lfParts has reveal or find (drawsAbsentParts, anchor-resolution.js#L1033). The fallback can't tell "drawn in another step" from "never a part". That gives the timeline marker you saw. A visual with marks only (data-lf-part, no reveal/find) resolves the anchor to null, so the thread has no marker at all, which fits the pipeline report.
    • page check --render reads no logged anchor, so the check passes.

    The signal is already half there. Every reveal/find visual also gives label(id). The timeline's returns null for an unknown event (lf-timeline.js#L208), and so does the trace's (lf-trace.js#L725). The chart's builds words from the id string for any point: id, whether or not a datum matches (lf-chart.js#L252).

    Proposed rule. A visual's declared parts are the ones it draws now, plus, for a visual with reveal or find, each id its label(id) names. An id outside that set doesn't resolve: the whole-visual fallback applies only to named ids. The chart's label then returns null for an id that matches no datum. With that rule:

    1. thread create --part resolves the anchor in the browser before it admits the comment, as cmd_comment already does for drawn markup (message_check, about a second). It refuses an id the page can't resolve and lists the parts the visual does draw. That meets root AGENTS.md's "Python never accepts an anchor the rendered page can't resolve".
    2. A browser thread can't produce such an id, so no check of logged anchors is needed beyond that.

    The one call I'd leave to you is the cost: every --part thread would pay a browser run at creation, where today it pays none. The alternative is to report unresolved visual anchors at page check --render, which is cheaper per thread but tells the agent only at its next check, after the user may already have seen the thread. I'd take the first. If you agree, a follow-up run can build the rule, the chart's label change and the --part resolution, with a regression test on the reproduction above.

  3. max-sixty commented on Nov 25, 2026

    @max-sixty
    OwnerAuthor

    Max chose how thread create --part should treat a part the visual didn't draw. It checks the id against the parts the page's last render reading drew, the list leaf page state shows since #7109:

    • Drawn: admitted, as now.
    • Not drawn, on a visual that puts an absent part on the whole picture (its lfParts has reveal or find, as a timeline's or trace's does): admitted, with a note saying the thread stands on the whole picture.
    • Not drawn, on a visual that doesn't (a diagram): refused. The refusal lists the parts it drew, and says that leaving out --part puts the thread on the whole visual. So the agent can always post, and the page never gets a thread with no marker.
    • A visual that lists no parts (a chart, which finds a point when asked): passes, as now.
    • No reading of the live version, as right after a save: the command draws the page once in a browser first, as thread create --quote now does for words a page's script draws (Keep the turn-end check from asking a choice the agent holds, and let thread create quote words a script draws #7140). If no browser can draw it, the id passes as now, with a note saying it wasn't checked.

    He chose this over Tend's proposal above, refusing every --part id in a browser through a new label(id) contract, which starts Chrome for every such thread, and over warning the agent and leaving it to wait for a background reading. The warning would arrive after the thread was posted, and the reading takes a median of 8.8 s against 1–3 s for drawing the page once.

    A PR implementing this follows.

    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

Labels

agent-experiencebug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions