Skip to content

refactor(agents): one follower for every agent's atif/1 tail, and Codex's and Gemini's tails in modules of their own - #940

Merged
earakely-scale merged 4 commits into
mainfrom
edgararakelyan/atif-tails-shared-follower
Nov 28, 2026
Merged

earakely-scale merged 4 commits into
mainfrom
edgararakelyan/atif-tails-shared-follower

Conversation

@earakely-scale

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

Copy link
Copy Markdown
Collaborator

A follow-up to #924 that changes no behaviour, with one exception: when Claude Code's CLI run raises or is cancelled, what its transcript gained is now fed as well, as Codex and Gemini already did. Before, only a run that returned had that last read. Before this PR:

This PR gives each of these one home.

What changes

One follower (utils/tail_follow/tail_follow.py)

  • tail_follow.following reads a tail while the CLI runs and once more after it exits, whichever way the run ends. A read still in flight when the run ends is fed, not dropped.
  • Every bridge follows its tail with it. Codex, Gemini and Claude Code each take it through shared_sources.toml and copy it beside the bridge, as feat(agents): Codex follows the env's clock, its CLI on real time and the model told the env's date #926's agent_clock and model_relay are taken. Their own follow/stop functions go.
  • Claude Code's tail reads and commits in one call, as Codex's and Gemini's do. Its read and advance were split so a read cancelled midway was read again, and the shared follower never cancels one. The follower calls read directly.
  • Gemini gets its first shared_sources.toml. Its install now copies a shared file to its basename, as Codex's and Claude Code's do.

The tails in modules of their own

  • Codex's rollout tail (RolloutTail, rollout_aux and the fork handling) moves to codex_rollout.py.
  • Gemini's transcript tail (SessionTail, session_aux, transcript_messages) moves to gemini_transcript.py.
  • Each tail is given how to find its files (find, and Codex's sessions folder), rather than reaching back into the bridge. SESSIONS_DIR, find_rollout_path and find_session_file stay in the bridges, where the rest of the agent and its tests use them.

Shared test helpers

  • tst/util/atif_recorded.py holds what the three agents' recorded tests repeated: loading and replaying a scenario, writing the expected documents again, and the checks for usage sums, each model call's time and model, and each call's result. Claude Code's shared tool files plug in through hooks.
  • tst/manual/atif_recording.py holds what both recorders did alike: build the image as a release builds it, send a turn and read it back with its live pages, and keep the key out.

Codex's sub-agent state. A sub-agent's place is one state, held, embedded or earlier, rather than the two flags declared and earlier.

Gemini's host install works in /app, as every other shipped agent's does. On a local sandbox a host install runs on this machine as this user, who can't make /workspace at the root, so Gemini's failed there before it copied anything. The local sandbox maps /app to a folder of its own.

Testing

  • Unit:
    • The agents, build-context and release-script tests pass (2,251).
    • New tests for the shared follower: a read in flight when the run ends is fed before the final one, a run that raises still gets its final read, and a follower that fails is logged while the turn goes on.
    • Gemini's image-contract test now reads shared_sources.toml, as Codex's does.
    • Claude Code's image-contract test now checks, as Codex's and Gemini's do, that the Dockerfile and install.sh carry every module the server imports. It fails with the follower dropped from install.sh.
    • Gemini's host install names the workspace the local sandbox maps to its own folder. The new test fails on /workspace.
  • Recorded fixtures: all three agents' replay to unchanged documents. Writing them again through the new helper gives byte-identical files (19 of them). They replay through protocol 0.1.660, the agents' floor, with no finding.
  • Chaos (kept outside the repo), on this branch:
    • The adapters: clean over 9,112 seeds per adapter, all eight plants caught.
    • The tails: Codex's and Gemini's clean over 811 seeds each, all three plants caught.
    • Claude Code's tail after the fold: clean over 2,735 seeds, all three plants caught (a read that doesn't commit, a torn line taken as read, shapes not shared between reads). The writer tears lines, adds sub-agent transcripts and replaces the transcript with its scrub.
  • Through each image built from this branch, recorded on a test host with atif/1 prescribed, about $1:
    • Codex: coding over two turns, a sub-agent, a forked sub-agent and a browser screenshot.
    • Gemini: coding over two turns, a browser screenshot and failed calls the CLI retried.
    • Claude Code: coding over two turns, a sub-agent and a /compact between turns, recorded again through the image built from the last commit.
    • All ten scenarios' served copies pass the validator with no finding, the sub-agents among them embedded.
    • Each replay through its adapter equals the copy the agent served, except for the task data the SDK adds at the end. So the shared follower fed the adapters every record the tails read.
  • Installed by install_agent from each build context, with atif/1 prescribed and live pages, about $0.35:
    • Into a Debian task container with no Python: Codex, Gemini and Claude Code.
    • Onto the sandbox's host: Codex and Gemini.
    • Every turn served a valid copy, and its live pages matched it.
    • The shared follower copied to its basename and was imported, as was each tail module.
    • Gemini, after the /app fix: onto the host and into the container, two turns of one conversation each, both passing.

🤖 Generated with Claude Code

Confidence Score: 5/5 · The changes appear safe to merge; no blocking issues were found.RetriggerView in GreptileConfidence Score: 5/5

The changes appear safe to merge; no blocking issues were found.

Summary

The PR gives Claude Code, Codex, and Gemini one shared transcript follower and moves Codex’s and Gemini’s tails into separate modules.

  • All three agent bridges follow their run files through one shared follower.
  • Codex tracks each sub-agent’s place with one clear state.
  • Gemini host installs now use the sandbox’s /app workspace.
  • The agents’ recorded-run tests and recording scripts share their repeated helpers.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  CLI[CLI writes transcript] --> Tail[Agent-specific tail]
  Tail --> Follower[Shared follower]
  Follower --> Adapter[ATIF adapter]
  Exit[CLI exits or raises] --> Final[Finish current read and read once more]
  Final --> Follower
Loading

Reviews (8) · Last reviewed commit: "refactor(agents): Claude Code's transcri..." · Reviewed by Greptile

earakely-scale and others added 2 commits November 27, 2026 14:53
…d Codex's and Gemini's tails get modules of their own

The three bridges each followed their CLI's files their own way, Codex's and
Gemini's with copies of one loop. utils/tail_follow is the one follower now,
taken by each image through shared_sources.toml; Claude Code's tail gains
take(), its read committed. Codex's rollout tail moves to codex_rollout.py
and Gemini's transcript tail to gemini_transcript.py, each given how to find
its files rather than reaching back into the bridge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… helpers, and Codex's sub-agent says where its records go

tst/manual/atif_recording.py holds what both recorders did alike (the image
built as a release builds it, a turn sent and read back with its live pages,
the key kept out), and tst/util/atif_recorded.py the loading, replaying and
checks the three agents' recorded tests repeated. Codex's adapter keeps a
sub-agent's place as one state, held, embedded or an earlier task's, rather
than two flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale marked this pull request as ready for review November 27, 2026 23:32
@earakely-scale
earakely-scale requested a review from a team as a code owner November 27, 2026 23:32
earakely-scale and others added 2 commits November 27, 2026 16:53
…ox maps to its own folder

A host install on a local sandbox runs on this machine as this user, who can't make /workspace at the root, so
Gemini's install failed there before it copied anything. Every other shipped agent works in /app, which the local
sandbox maps to a folder of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…one call, and its image and install carry every module the server imports

The tail's read and advance were split so a read the follower cancelled midway was read again. The shared follower
never cancels a read, so read now moves past what it gives, as Codex's and Gemini's tails do, and the follower calls it
directly. Claude Code's image-contract test now checks, as Codex's and Gemini's do, that the Dockerfile and install.sh
carry every module the server imports, the shared ones included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale merged commit deb9078 into main Nov 28, 2026
37 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/atif-tails-shared-follower branch November 28, 2026 05:18
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.

1 participant