Skip to content

feat(task-steps): always_on and the live follow keep a prescribed run's atif/1 copies, and always_on's judge grades them - #890

Merged
earakely-scale merged 11 commits into
mainfrom
edgararakelyan/fd-6078-y4-pr3-always-on-live
Nov 23, 2026
Merged

earakely-scale merged 11 commits into
mainfrom
edgararakelyan/fd-6078-y4-pr3-always-on-live

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Y4 PR 3 of 3 for FD-6078. #854 made a prescribed run's prompt-step turns read and store their atif/1 copies. This PR does the same for always_on and the live follow, and teaches always_on's judge to read those copies. A run that prescribes nothing is unchanged. Closes FD-6078.

Since the first review

  • always_on's copies are read off the wake's path (Sarah's first point, decided S1 with Edgar). A wake no longer waits for its copy. The run's end fills in each turn's url, record and timeline fields, giving the copies still going one fetch cap more. Before, a copy that hit the 120 s cap during the wake left the wake with no trajectory.
  • A run that prescribes atif/1 to an agent offering only native keeps an unprescribed run's timeline (Sarah's third point, S3). Before, its timeline named each turn's index and format, as a copied run's does. A test checks it.
  • A harness's compaction, own messages and internal tools in atif/1 are follow-up work, to land before such a harness opts in to atif/1 (Sarah's second point, S2). No harness that has them offers atif/1 today.
  • Claude Code's own compaction, checked: the recorder gains a compacted scenario: a turn of work, a /compact turn, then a turn that reads what the summary kept. It found a gap, which is pinned here and is that follow-up's first case (S2b).
    • The turns around the compaction give the judge the same events from the copy as from native.
    • The /compact turn's copy lacks what native gives the judge as two notes, the summary and "Compacted".
    • The copy has no step for the call that wrote the summary, so its token counts leave that call out; its cost counts it.
    • The pins fail once the adapter writes a compaction step.
  • A live follow whose atif/1 copy hasn't started yet reads again rather than stopping at the first 404.
  • Merged main: always_on's timeline events carry both main's cut_off field and this PR's turn fields.
  • The live follow's atif/1 settings (fallback format, media pull, media folder) travel as one LiveAtif rather than four arguments through four layers. The judge's shared atif/1 helpers in atif_turns are public.

What changes

always_on (task_steps/always_on.py)

  • It prescribes the run's formats to its agent, as prompt_agent does. Until now it prescribed native only.
  • Each wake's and nudge's trajectory is read as feat(task-steps): prompt steps keep each turn's atif/1 copy as its trajectory when the run prescribes it, and judges grade it #854 reads a prompt step's:
    • the turn's copy when the run prescribes atif/1 and the agent offers it;
    • otherwise, or when the copy can't be had or lacks media, native.
  • Off the wake's path. A wake doesn't wait for its copy: the copy is read in the background, each after the one before. The run's end fills in each turn's url, record and timeline fields before the timeline is stored.
  • The time cap. At the run's end, the copies still going get one more fetch cap (TRAJECTORY_FETCH_SECONDS, 120 s), or none when the step is being cancelled. A copy still going then is recorded unavailable, timeout, with no url. Native reads stay inline within the same cap as before, so wake_reserve_seconds doesn't change.
  • A failed end. A run's end that raises before it joins its copies (a failed clock read, say) leaves none running: the run's close cancels any still pending.
  • Per-turn records. Every turn records what its url holds (target_agent_per_turn_trajectories), on every run, as prompt_agent has since feat(task-steps): prompt steps read each turn's native trajectory by name and record its format #843.
  • Timeline fields. In a run whose turns are copies, which share one document url, each agent_turn_end and nudge event also names its turn index and trajectory_format. Any other run's timeline is byte-identical to before, a run prescribing atif/1 to an agent that offers only native included.

always_on's judge (verifiers/always_on_agent_verifier.py, judge_utils/turn_events.py)

  • turn_events.atif_turn_events(view) gives an atif/1 turn's events in the shapes a native Claude Code turn's take. That covers:
    • text, thinking, and tool calls with their results;
    • a sub-agent's events, tagged subagent with the call that started it;
    • the final message.
  • Staging per wake. The judge stages each atif/1 wake from its own A2A task, cut out of the shared document. In its own copy of the timeline it keys that turn as <document url>#<task id>. The key is never written into the judge's files.
  • Harness settings. A copy carries no harness trace, so assistant_harness reads no settings from it. That matches what a native Claude Code turn gives.

The live follow (a2a_agent/trajectory_follower.py, snapshot_utils/live_trajectory.py, prompt_agent.py)

  • What it follows. A prompt step whose copy replaces native follows atif/1 live.
  • Pages. Each poll's new closed root steps are a page. The document's header is stored beside the page where it changed, as <after>-<next>.<n>.header.json (the greatest is the latest), not on every page. Each sub-agent's new steps and changed header go under sub/<id>/, nested ones too.
  • meta.json names the format, the schema and profile versions, the document's ids, and media_base, the folder its media/ paths resolve in. The latest header with every page's steps is a prefix of the turn's stored copy.
  • Media. Each page's media are pulled between polls into the run's atif folder, through the copies' own record of what that folder holds. So screenshots show while the turn runs, and the turn's copy asks for none of them again. Nothing is pulled once the turn's drain starts; the copy's own pull covers what's left.
  • Refusals. A turn the agent refuses atif/1 before any page was stored is followed natively. One refused after pages exist ends with end.json naming why (stopped), so a turn's pages never mix formats.
  • A copy not started yet. Before any page is stored, an atif/1 read the agent answers 404 is a copy that hasn't started yet, so the follower reads again until the turn ends. Before this, the follower took that 404 to mean the task was gone and stopped with no pages.

Decided with Edgar (2026-11-23)

  • The live follow follows atif/1 when it's prescribed. It doesn't stay native, and it doesn't follow both.
  • Live pages hold steps, with the header written only when it changes, rather than a whole snapshot per poll.
  • Deduplication happens in the follower for now, which works with every released agent. The SDK changes go in their own protocol PR next: a header digest, a sub-agent cursor and caching of rendered steps.
  • A refusal before any page falls back to native; one after pages exist stops the follow with a reason.
  • Live media are pulled between polls, as described above.
  • always_on's copies are read off the wake's path and filled in when the run ends, the copies still going given one fetch cap more (S1, after Sarah's review; it replaces reading each copy inline within the wake's one cap).
  • Per-turn records go on every always_on run.
  • Timeline turn fields appear only in runs whose turns are copies (S3 narrows "prescribed runs").
  • A harness's compaction, own messages and internal tools in atif/1 are follow-up work, before such a harness opts in (S2).
  • The judge's private per-turn key stays out of its files.
  • A compaction turn's notes and summary call are missing from a Claude Code copy until the copy has a compaction step, pinned by the recorded tests (S2b).
  • Two known differences on a sub-agent turn are accepted:
    • native has the sub-agent's prompt as a note, which staging labels a harness note;
    • the copy has the sub-agent's closing reply, which native stdout never carries.
  • Harnesses whose trajectories carry their own harness.* labels offer no atif/1 today, so they stay native. Nothing harness-specific is added.

Choices to review

  • Sub-agent progress while it runs. A running sub-agent's progress shows in live pages only once the root step that started it closes. That's how the SDK serves sub-agents today, and the next protocol PR's sub-agent cursor fixes it.
  • Traffic per poll. The agent still sends its whole header on every poll (about 60 KB for Claude Code). The follower writes it only when it changes, so storage is linear, but the bytes still cross the agent's link until the protocol PR adds the header digest.
  • Live media pulls share AtifCopies._held with the end-of-turn pull. Two pulls racing on one file at worst ask for it twice, and the store check counts it as held either way.

Testing

  • Unit, always_on (test_always_on_trajectory_formats.py):

    • the run's formats are prescribed;
    • a prescribed run's wakes and nudges are their copies, each named in the timeline;
    • a wake goes on while its copy is read, and each copy fills its turn when the run ends (the copy is held until the next turn runs);
    • a copy still going a fetch cap after the run ends is unavailable, timeout, with no url;
    • a run whose end fails before it joins its copies cancels them;
    • a run prescribing atif/1 to an agent that offers only native reads native, records format_not_offered, and names no turn;
    • a run that prescribes nothing reads native and names no turn.

    The three new tests fail on the commit before each.

  • Unit, the judge (test_always_on_agent_verifier.py, test_claude_code_atif_recorded.py):

  • The judge-input pin gains always_on_atif_staged. Its existing cases don't change, and the golden diff only adds that case.

  • Unit, the live follow (test_prompt_agent_live_atif.py, against a live SDK agent in process):

    • pages rebuild a prefix of the stored copy;
    • the header is stored once per change;
    • a refused turn is followed natively;
    • a page's media are pulled while the turn runs;
    • a refusal after pages ends naming why;
    • sub-agents' and nested sub-agents' pages are stored as they come;
    • a follow whose atif/1 reads answer 404 before the copy starts stores every page once the copy starts, and one whose copy never starts ends with its turn.

    The tests for the new behaviour fail on main.

  • Related unit folders. task_step, a2a_agent, agents and the protocol suite pass: 7,937 tests. The four failures are the known Mac-only computer_exec_test.py ones.

  • Live chaos (kept outside the repo).

    • What it does: it runs the real follower and page writer against a fake agent whose document grows while the turn runs. Root steps close one by one, the header changes, sub-agents and nested ones gain steps, and screenshots are named. The answers come with random pagination, 5xx answers, transport errors, and refusals before or after the first page.
    • Invariants:
      • no object is rewritten with other bytes;
      • pages are a prefix of the document's steps;
      • the latest header is the document's last, and each header file differs from the one before;
      • sub-agent pages are their steps;
      • formats never mix;
      • no media pull starts in the drain.
    • Results: clean locally (210 seeds) and for 20 minutes on a test host (6,354 seeds), and it catches planted bugs (a header on every page; no native fallback).
    • 404s before the copy starts were added as a fault with the fix (1ea1a9c). The run is clean on the fix (337 seeds in a minute). On the commit before it, the first seeds already fail with no pages.
  • Real runs with Claude Code on a test host (live follow on, atif/1 prescribed). In each, every live step equals the stored copy's step of that id, and the latest header matches the copy's.

    • Desktop computer-use task: 7 pages and 2 header versions for 9 steps. All 6 screenshots were stored, 5 of them while the turn ran, each about 0.1 s after the page that named it.
    • A sub-agent task: the sub-agent's pages are its trajectory in the copy.
    • Two parallel sub-agents: each one's pages are its trajectory in the copy.
  • A real always_on run with Claude Code (Sonnet), atif/1 prescribed, on a test host. The task is a support-chat world with a simulated user, end-state and process judges, and a satisfaction rating.

    • All 14 of its turns' copies are valid, and every judge graded.
    • Staging parity: the always_on judge's staging was built twice from the same run. Once from its 14 atif/1 copies, and once from their 14 native trajectories, which a test-only hook read beside each copy. All 53 of the judge's files are byte-identical.
  • After Sarah's review, a second round on a test host (1914bd4 plus the recorder, about $4.80):

    • The espresso always_on run again, with Claude Code (Sonnet) and atif/1 prescribed.
      • All 19 turns' copies are valid. Each turn's url, record and timeline fields were filled in when the run ended, with none missing.
      • In 6 turns the run logged its next events before the copy was stored, so the wake didn't wait for it.
      • The judge's staging, from the copies and from the native trajectories read beside them, gave 73 of 73 files byte-identical.
    • The live follow again on the desktop task: 8 pages, 3 header versions and 10 steps, each equal to the stored copy's, and 7 of 7 screenshots stored. On the sub-agent task, its pages match too.
    • The compacted recording, above.
  • The live tests hold the agent's turn on an event, not a sleep (6bd02f0). The first version's media test failed on CodeBuild's loaded runner: no poll fell inside its 0.5 s pause.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The latest changes appear safe to merge, and the previous copy-cleanup issue is fixed.

Summary

The PR adds atif/1 copies to always_on, teaches its judge to read each turn, and follows prescribed copies live.

  • Always_on turns can use their atif/1 copies as trajectories.
  • The always_on judge can stage each atif/1 wake on its own.
  • Live prompt-step follows can store atif/1 turns as pages.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Agent turn ends] --> B[Read copy in background]
  A --> C[Continue run]
  C --> D[Finish run]
  D --> E[Join copies and fill turn records]
  E --> F[Store timeline and response]
  D -->|Finish raises early| G[Outer cleanup]
  F --> G
  G --> H[Cancel remaining copies]
Loading

Reviews (13) · Last reviewed commit: "fix(task-steps): always_on cancels the a..." · Reviewed by Greptile

earakely-scale and others added 2 commits November 23, 2026 09:26
…ectory when the run prescribes it, and its judge stages it

always_on prescribes the run's formats and reads each wake's and nudge's trajectory through AtifCopies, inline within
its one fetch cap: the atif/1 copy when prescribed and offered, else, or when the copy can't be had or lacks media,
native. Every turn records what its url holds (target_agent_per_turn_trajectories), and in a prescribed run each turn's
end names its index and format in the timeline, since its turns share one url. always_on_agent_verifier stages an
atif/1 wake from its own task's events (turn_events.atif_turn_events, the shapes a native Claude Code turn gives), keyed
by document and task, and reads no harness settings from a copy. A run that prescribes nothing is unchanged, and the
judge-input pin gains an always_on atif/1 case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ve, its media pulled as the pages come

The live follow of a prompt step whose copy replaces native reads atif/1: each poll's new closed root steps are a page,
the document's header is stored beside the page where it changed (versioned, so the greatest is the latest), each
sub-agent's new steps and header go under sub/<id>/, and meta.json names the versions, the document's ids and the
folder its media resolve in. Each page's media are pulled between polls into the run's atif folder through the copies'
own record of what it holds, so the turn's copy asks for none of them again; nothing is pulled once the turn's drain
starts. A turn the agent refuses atif/1 before any page was stored is followed natively; one refused after ends with
end.json naming why, so a turn's pages never mix formats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale

Copy link
Copy Markdown
Collaborator Author

@greptileai review

…vent, not a sleep

The live media test failed on a loaded Linux runner: no poll fell in the 0.5 s pause, so the first screenshot's page
came in the drain, which pulls nothing. The agent now holds its turn until the follower has pulled a page's media (the
header test: stored a page), at most 30 s, so the mid-turn page is certain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale marked this pull request as ready for review November 23, 2026 18:08
@earakely-scale
earakely-scale requested a review from a team as a code owner November 23, 2026 18:08
earakely-scale and others added 2 commits November 23, 2026 10:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rted, not ending at the first 404

Before any page is stored, an atif/1 cursor read the agent answers 404 is a copy that hasn't started yet, so the
follower reads it again until the turn ends rather than treating the task as gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sarah-chitty-1 sarah-chitty-1 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.

Looks good. It's opt-in, and unprescribed runs are unchanged: the PSI neutral harness doesn't offer atif/1, so its always-on wakes still read native. Two things before always-on runs prescribe atif/1:

  1. A copy that hits the 120 s cap leaves the wake with no trajectory. AtifCopies.read records it unavailable / timeout with no url and no native read in its place, and the media pull counts against the same cap. Wakes with lots of screenshots, which the neutral harness now sends (v8+), or with browser recordings, are the likeliest to hit it, and the judge then grades without that wake. Could it fall back to native on a separate short budget, or finish the read in the background and fill in the url, the way #854 does for prompt steps?
  2. atif_turn_events only knows Claude Code-shaped events: text, thinking, tool calls, sub-agents and the final message. There are no compaction summaries (or who wrote them), no harness messages (save request, after summary, failed wake), and no flag for harness-internal tools like memory and history search. That's fine while only Claude Code offers atif/1. A harness that compacts (the neutral harness, or Claude Code with its own compaction) needs these in the profile before it opts in. Otherwise the judge counts memory writes as actions and loses the summaries, and for native traces a missing written_by already makes a run ungradable.

Small: the tests are all Claude Code. One always-on test with a native-only agent that has the trajectory extension, as the neutral harness does, would check the "unchanged" claim directly.

earakely-scale and others added 3 commits November 23, 2026 12:55
…iveAtif, and the judge's shared atif/1 helpers are public

The live follow's fallback format, media pull and media folder were four arguments threaded through four layers, and
LiveTurn took eleven positional ones; they're one LiveAtif now, built once by prompt_agent, and LiveTurn takes keywords.
The page writer cancels its own media pulls (cancel_pulls). turn_events no longer imports atif_turns' private helpers:
content_text, steps_of, calls_with_results and SubAgents are public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…8-y4-pr3-always-on-live

# Conflicts:
#	src/agent_env/task_step/task_steps/always_on.py
…e's path, and fills it in when the run ends

A wake no longer waits for its copy: the copy is read in the background, as prompt steps read theirs, and the run's
end fills in each turn's url, record and timeline fields, giving the copies still going one trajectory fetch cap more
(none when the step is cancelled). A copy still going then is recorded unavailable, timeout. Native reads stay inline.
AtifCopies.join takes that timeout, and its inline read is gone.

A run that prescribes atif/1 to an agent offering only native now keeps an unprescribed run's timeline: the turn
fields name a turn only when the run's turns share a copy's url.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale and others added 3 commits November 23, 2026 14:08
…compacted between its turns

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts turns, pinning what its copy lacks

The compacted scenario, recorded through the agent's image on the pinned CLI with atif/1 prescribed: a turn of work, a
/compact turn, and a turn that reads what the summary kept. The turns around the compaction give a judge the same
events from the copy as from native. The /compact turn's copy lacks what native stdout gives as notes (the summary and
"Compacted") and a step for the call that wrote the summary, so its token counts leave that call out, though its cost
counts it. Both are pinned until the copy has a compaction step (FD-6916).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its end failed before joining them

A run's end that raised before it joined its copies (a failed clock read, say) left them reading and writing after the
step had exited; the run's close now cancels any still pending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All three are addressed in this PR:

  1. A copy at the 120 s cap. always_on now reads each turn's copy off the wake's path, as prompt steps do since feat(task-steps): prompt steps keep each turn's atif/1 copy as its trajectory when the run prescribes it, and judges grade it #854, and fills in each turn's url, record and timeline fields when the run ends. The copies still going then get one more fetch cap, and a copy still going after that is recorded timeout. Native reads stay inline. (1914bd4, 8a3e4b4)
  2. Compaction, harness messages, internal tools. This is follow-up work, which must land before such a harness opts in to atif/1, and before atif/1 can become a run's default read. I also recorded a Claude Code conversation that compacts (/compact). The turns around the compaction match. The compaction turn's copy lacks native's summary and "Compacted" notes, and its summary call's tokens. Both are pinned in the recorded tests until the copy has a compaction step. (6ccde11, f735a5b)
  3. The native-only test. Added: atif/1 prescribed to an agent whose trajectory extension offers only native reads native, records format_not_offered, and names no turn in the timeline. It caught a real difference: before, that run's timeline named each turn's index and format. (1914bd4)

Re-run on a test host:

  • the espresso always_on run: 19 copies valid, all filled in when the run ended, and the judge's staging 73/73 identical to native;
  • the live follow on the desktop and sub-agent tasks;
  • the compaction recording.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants