Repository navigation
feat: add experimental T3 Code runtime backend - #5596
bryceeppler wants to merge 57 commits into
Conversation
|
This comment has been minimized.
This comment has been minimized.
|
Speaking as Kun's firstmate: Verdict: Tip vs main 8f756bb reviewed. No closing issue link — does not close an issue. Adds T3 Code runtime backend with explicit selection (plus token/origin-gated auto-detect). Unconfigured homes keep existing backends — opt-in, not new-default. VISION: aligns when opted in on captain-interface/authority/scripts/spine/scope; restart and fleet-outlives-vendor need tighter adapter bounds (see Greptile P1s). Blockers: (1) attestation MISMATCH — body head_sha 9efec65c5ac9 vs HEAD 07182e6c0bd0; (2) Greptile P1s outstanding (worktree symlink path, default model instance mapping, Codex settings overwrite, unbounded HTTP client, uncertain thread.create abort path). Attestation: MISMATCH. CI/NM: fork workflows action_required — not approved this pass (P1s outstanding). MERGEABLE/UNSTABLE. No auto-merge. Firstmate-flag no (not otherwise-ready). Cron FYI on Greptile P1 findings; not withhold/close. |
|
Speaking as Kun's firstmate: Verdict: Tip vs main VISION.md (each rule)
Blockers (waiting-author): Greptile still FAILURE with outstanding P1s including tip finding Live thread appears unreadable ( Attestation: MATCH. CI/NM: fork workflows still |
|
Speaking as Kun's firstmate: whole thread re-read (prior stamps; body + attestation; Greptile now SUCCESS; author tip fixes after 38136394). Diff tip vs main Verdict: Tip vs main (own inspection):
VISION.md per-rule:
Attestation: MATCH |
3b6c06c to
523cffa
Compare
T3 Code owns the agent session while Treehouse keeps owning the task worktree. The adapter drives the T3 server over its HTTP orchestration API with a CLI-issued bearer and reads native thread changes over the WebSocket shell stream; nothing is typed into a terminal. A spawn leases a Treehouse slot durably, registers the project by real path, creates the thread on the slot, and starts the launch turn with the encoded brief. T3 sets environment per provider instance, never per thread, so the facts a pane would export (GOTMPDIR, FM_TASK_ID, TRACEPARENT, a secondmate's launch prefix) travel as per-directory harness config: an env block in .claude/settings.local.json, or a [shell_environment_policy] table in .codex/config.toml. A tracked Codex config is overlaid under skip-worktree with a journal and restored byte for byte at teardown. Teardown stops and archives the thread before the slot returns, because a live thread whose worktree path disappears re-creates it on its next turn. The backend is experimental, runs only the claude and codex harnesses, and is selected explicitly or by a configuration-gated auto-detection rule: a home whose T3 shell snapshot shows exactly one live worktree-less thread.
The T3 server reports its own session status for claude and codex alike, and no shell sits in front of the agent, so both its native busy and idle verdicts are trusted ahead of harness records (source t3code-native). The watcher subscribes to the shell stream for this home's worker threads, normalizes pending approvals to blocked through the shared transition policy, and keeps polling as the fallback. A thread's capture stays byte-identical through a long tool call, so the wedge ladder gains one T3 consult that resets the idle timer only while the server still reports the session running; stopped and failed sessions read dead and are reported once by the shared dead-record probe.
…n T3 Code A T3 thread has no composer, so exit is the server's own session stop, proven by the same recovery-grade agent-state wait every other backend uses. A thread is bound to the driver that first ran it and a turn on a stopped thread continues the same agent, so relaunch is refused before anything is stopped, by the control plane and by the launch owner. A T3 missing is the server's own answer, so the absence proof re-reads the thread. The away daemon can supervise a captain that runs inside a T3 thread: T3 puts nothing into the agent's environment, so after the explicit overrides and the tmux and Herdr markers it asks the server for the one live worktree-less thread on this home's project. start refuses because T3 hosts no terminal to create; start-native remains the path.
A node HTTP fake answering from a per-case world covers the token and version gates, project matching, the command payloads, the status table, the stop-then-archive kill, worker and secondmate spawns, the per-directory environment files, tracked Codex config preservation, teardown ordering, the control plane's native exit and relaunch refusal, and the wedge consult. A second suite frames real WebSocket messages for the event reader and the watcher's fallback. A token-free live guard skips cleanly without T3. Cases that parse TOML report themselves skipped without a Python 3.11+ interpreter instead of passing vacuously.
The backend guide owns setup, token minting, task shape, lifecycle, restart behavior, push events, away-mode support, and active limits. The runtime backend verification record keeps the dated live evidence. The shared configuration, architecture, control-plane, trace-context, and away-mode owners gain one-line cross-references instead of restatements.
…secondmate bearer
|
@bryceeppler, a heads-up on the transport, with an offer. T3's Orchestrator V2 (pingdotgg/t3code#2829) removed V2's supported write path is the orchestration MCP endpoint at
The evidence, the tool-by-tool mapping and the gaps are in #6904. If it helps, I can contribute to this PR rather than open a competing one:
Most of your Firstmate-side wiring (lease, proven close, explicit selection, per-harness env) should carry over unchanged. Let me know whether you'd like that as a PR against your branch. |
T3's Orchestrator V2 removed POST /api/orchestration/dispatch, and an OAuth mcp-client session is accepted only on /mcp. Add bin/fm-t3-mcp.mjs, a dependency-free MCP client with the captain-run PKCE sign-in, a tools/list capability gate pinned to the signed-in environment id, and the thread verbs the adapter needs, and port bin/backends/t3code.sh onto it: launch, send, read, interrupt, archive with a proven close, and the away-mode thread lookup. The transport forces three changes: fm-control exit refuses on t3code (V2 has no session stop), the WebSocket push path is removed (an mcp-client is refused on it, so T3 windows poll), and a launch whose reply is lost keeps its lease instead of retrying (t3_thread_launch has no idempotency key). Fixes kunchenguid#6904
|
Opened bryceeppler#5 against this branch: it moves the |
|
Speaking as Kun's firstmate (OSS triage, not the captain). Thanks @bryceeppler. I re-read the thread since my 2026-10-05 stamp and reviewed head Since the last stamp: both items from that pass are addressed in your own commits.
Contract-class: opt-in (unchanged). T3 Code is chosen only with an explicit VISION.md, rule by rule: One captain, one interface (aligns when opted in). Authority explicit (aligns: explicit selection and bearer). Scripts own the mechanics (aligns: adapter scripts). Restart a non-event (aligns: lease kept on uncertain create, bounded HTTP). Delegation with a spine (aligns). Fleet outlives any vendor (aligns, with a vendor note below). Scope (aligns: experimental harness adapter). Vendor note (FYI, not a blocker here): @arthurcruzd reports that T3's Orchestrator V2 (0.0.46 nightly) removes Fork CI: this head's runs were sitting in Outcome: waiting-ci. If CI and no-mistakes go green on this head and it stays mergeable, this is an opt-in auto-merge candidate on a later pass. |
|
Thanks @kunchenguid for the re-review and for approving the fork CI runs, and thanks @arthurcruzd for bryceeppler#5 and the heads-up on Orchestrator V2. Since T3's Orchestrator V2 (pingdotgg/t3code#2829) is already merged on T3's main and removes Plan from here:
|
|
Speaking as Kun's firstmate: thanks @bryceeppler, that's a sensible call, and thanks for saying it plainly. Noted: this is back in draft and paused until T3's Orchestrator V2 reaches stable, and nothing from this branch should be merged in the meantime. Triage will not merge it. Head is unchanged at Next step: waiting on you. When you push the V2 rework (built on bryceeppler#5, re-verified live against stable T3) and mark it ready, it gets a fresh review here. No rush. The 14-day contributor clock applies while it is paused, so a short status note every couple of weeks keeps it open. |
A live run of the /mcp backend against t3 0.0.46-nightly.20261010.2935 on Linux found four defects the fake server could not: - capture read the oldest activity items: t3_thread_read pages forward from afterPosition, so the helper now starts from the thread's visible item count and widens backwards when that undercounts. - fm-control interrupt on t3code always reported cancel=unconfirmed because the key path discarded T3's own run-wait verdict; it now reports T3's confirmed, not-running, or unconfirmed. - the telemetry probe never read "off" on Linux, where /proc/<pid>/environ is NUL-separated and the value match ran into the next variable. - the credential-mode test ran BSD stat first, which GNU stat answers with filesystem output before failing. The fake server now pages like T3, the capture and interrupt tests fail without their fixes, and the runtime-backends record carries the live run.
- Interrupt confirmation waits on exactly the run T3 interrupted (wait --run). - A send reply lost after T3 committed it reads unconfirmed (exit 7 from the helper, verdict unconfirmed, fm-send exit 3), and one request id per logical delivery makes the resend idempotent. - Secondmate recovery never replaces an endpoint whose close is unproved, and resumes a failed T3 run in its own thread instead of launching a second one. - Secondmate retirement reaps provider processes T3 detaches after the archive before a pooled or standalone home is returned or removed. - Pending runtime requests read blocked, escalate once per request set through the watcher's push splice, and are answered with bin/fm-t3-answer.sh; permission approvals are surfaced, never answered. - Supervisor discovery reads every thread page and counts forks, not subagents. - Model selection resolves against orchestrator_capabilities, keeps unrelated default options under an effort override, and launch reads back the full t3_thread_configuration; the stale driver-binding claim is corrected. - The watcher's push splice waits on exact active runs through t3_thread_wait, bounded by the poll interval, with polling as the backstop. - The Claude pull-request-tool clause applies only before the T3 build verified safe, with an opt-in live guard and a dated verification record. - The fake server models paging, exact-run waits, asynchronous interrupt and archive, commit-then-disconnect sends, and pending requests; read limits cap at T3's 100.
|
Speaking as Kun's firstmate: thanks @bryceeppler for the V2 rework push ( I read the new diff for CI safety: it doesn't touch When you mark it ready, it gets a full fresh review. This rework now also edits default-path files ( Status: waiting on you, the author (draft hold until V2 is stable). No rush. |
Non-T3 secondmate recovery keeps its existing best-effort close, so homes without backend=t3code run the same liveness code as main. A T3 secondmate whose thread reads missing now re-proves the close through the idempotent archive before a replacement thread launches, and an unproved close spawns nothing.
…ed, keep task record
|
Speaking as Kun's firstmate: thanks @bryceeppler for the follow-up commits ( It's still a draft, and the body still says it's paused until Orchestrator V2 ships in a stable T3 release, so the hold stands. Triage will not merge this. I read the delta for CI safety: no When you mark it ready, it gets a full fresh review, including a check that homes without Status: waiting on you, the author (draft hold until V2 is stable). No rush. |
|
Heads-up for the hold in the PR body: T3 Code Orchestrator V2 shipped on the stable channel yesterday as v0.1.0 (https://github.com/pingdotgg/t3code/releases/tag/v0.1.0). Field report in case it helps: our fleet has run on a fork of this backend since 2026-10-09 (the primary as a T3 thread, four remote second mates on their own machines' T3 servers, and ship/scout workers), and today we moved our VPS and Mac T3 servers from nightly 0.0.46 to stable v0.1.0 with no backend changes needed so far. One design difference worth raising before anything else: this PR refuses exit and relaunch on t3code and reads an archived thread as missing. In our fork we implemented native exit (interrupt, then archive) and relaunch (resume the same thread, or open a new thread in the same worktree), and read an archived thread as dead. If that direction fits the project, we'd be glad to offer it as a follow-up on top of this PR rather than diverging. |
I won't be upkeeping this PR, feel free to continue the work from here. |
|
Speaking as Kun's firstmate: thanks @bryceeppler for all the work on this and for saying so plainly. Understood, you're stepping away from this branch. And thanks @arthurcruzd for the heads-up that T3 Orchestrator V2 is now stable (v0.1.0), and for the field report. Where this PR stands on head If someone wants to carry it forward (@arthurcruzd, you offered), please open a successor PR from your own branch with these changes:
Once that successor is open, I'll close this one as superseded and point here. A successor gets a full fresh review. That includes confirming that homes without Status: waiting on an author, either a successor PR or someone picking this branch back up. Nothing from this branch merges as-is. |
Adds an experimental, opt-in
t3coderuntime backend that runs Firstmate workers as T3 Code threads on T3's Orchestrator V2/mcptransport.Backend shape
bin/fm-t3-mcp.mjsis a dependency-free MCP client with a one-time PKCE sign-in from at3 auth pairing createcode, a 0600 credential, and atools/listcapability gate pinned to the signed-in environment id.bin/backends/t3code.shmaps launch, send, steer, read, interrupt, pending requests, and archive onto thet3_*tools.fm-control exitrefuses ont3code(V2 has no session stop), andrelaunchrefuses because a thread keeps its conversation, so no fresh agent can replace it.What changed since the last review
A Codex review of the V2 wiring returned twelve findings; all are fixed, each with a fake-server test that fails on the previous head.
fm-sendexit 3); one request id per logical delivery makes a resend land once, the accepted message and run ids are kept, and the away daemon freezes an unconfirmed digest and retries it with its own request id until confirmed, with later events in the next digest.blocked, wake the supervisor once per request set, and are answered withbin/fm-t3-answer.sh; permission approvals are surfaced and left to T3 Code.orchestrator_capabilitiesbefore leasing, keeps unrelated default options under an effort override, and the launch reads back the fullt3_thread_configuration.t3_thread_wait, bounded by the poll interval with polling as the backstop, and Herdr keeps its push wait in mixed homes.Verification
Live on 2026-10-10, Linux x86_64,
t3 0.0.46-nightly.20261010.2935(service-managed), Claude Code 2.1.296, in a scratch Firstmate home and scratch projects.docs/verification/runtime-backends.mdrecords the commands and results.fm-control interruptcancel=confirmedon the interrupted run; the child was gone 2 s lateravailablelink_pull_request,list_thread_pull_requests,unlink_pull_requestin a Claude threadThe live check ran on the code before the review rounds' fixes to sends, the away-daemon digest, and secondmate shutdown; those are covered by the fake-server suites.
Test suites:
fm-t3-mcp,fm-backend-t3code,fm-secondmate-liveness,fm-supervision-events, and the other colocated suites pass;bin/fm-lint.shandbin/fm-doc-audience-check.shpass.fm-test-run(--jobsadmission, pty-host reparent) andfm-control-relaunch(Herdr Pi relaunch) fail the same way on currentmainon this host, and the Herdr control smoke needs a default Herdr session this host lacks.Selection
Still opt-in: only an explicit
config/backend=t3codeplus a signed-in credential selects it, and unconfigured homes keep their existing backends.Default-path files and non-T3 homes
Each shared file this round touched, and why a home without
config/backend=t3codeis unchanged:bin/fm-backend.sh: addst3codecases to the push dispatchers (has_push,events_capable,wait_transition,commit/clear_transition,event_session,transition_target,transition_note); every existing backend keeps its own branch and default.bin/fm-watch.sh: T3 windows join the push wait only when no other push backend is recorded, so a Herdr-only or mixed home keeps Herdr's push wait exactly (tests/fm-supervision-events.test.sh).bin/fm-push-transition-lib.sh: appends a backend note to the wake reason; the note is empty for every backend butt3code, so the Herdr reason is byte-identical (tests/fm-supervision-events.test.sh).bin/fm-send.sh: a newunconfirmedverdict case; only the T3 adapter emits that verdict, so other backends reach the same branches as before.bin/fm-supervise-daemon.sh: a digest request id is minted only when the supervisor backend ist3code, and a digest freezes only on theunconfirmedverdict, so non-T3 digests flush and retry as before (tests/fm-daemon.test.sh).bin/fm-teardown.sh: the secondmate home shutdown barrier runs only forkind=secondmatewithbackend=t3code.bin/fm-control.sh,bin/fm-control-lib.sh: comment and refusal-message corrections on paths onlyt3codereaches.bin/fm-spawn.sh: the relaunch refusal message onlyt3codereaches, the version-scoped Claude channel clause in the T3-only channel installer, and the unconfirmed launch-brief report on the T3 launch-turn path.bin/fm-test-run.sh: registers the new opt-in live guard in the live family.bin/fm-secondmate-liveness-lib.sh: the resume-in-place path, the archive re-proof for a missing thread, and the refusal to replace an unproved close all requirebackend=t3code; every other backend runs main's best-effort kill line unchanged (tests/fm-secondmate-liveness.test.shpins it for tmux,tests/fm-backend-t3code.test.shcovers the T3 refusal).This round does not touch
bin/backends/herdr.shor the opencode watch plugin.Follow-ups
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
⏭️ **Rebase** - skipped
Step was skipped.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-spawn.sh:5803- The spawn launch turn treats a lost T3 reply as a proven refusal.fm_backend_t3code_turn_startnow returns 7 when T3 may already have committed the brief: the request went out, but its reply was lost (helper exit 7, delivery_unconfirmed). The launch-brief caller ignores that distinction. Any nonzero status prints "error: T3 refused the launch turn for $ID on thread $T" and exits 1. By then the task record is already published, and T3CODE_ABORT_CLEANUP/T3CODE_LEASED were cleared at line 5462. Concrete sequence: T3 commits the brief and the connection drops before its reply. spawn reports a refusal, but the worker thread is running the brief in its leased worktree. The dispatcher, believing nothing started, may tear the task down and re-dispatch it, which kills a working agent. A manual resend of a different text would deliver a second brief. Intent item 2 requires the caller to separate a proven refusal from an uncertain transport outcome and to report delivery as unconfirmed after a lost response. fm-send and the away daemon do this; this third caller of the same adapter does not. Fix: branch on rc 7 here. Report that the launch brief's delivery is unconfirmed: the thread may already be working, so inspect thread $T, and if the brief is absent, resend only the identical brief text, which reuses the recorded request id within the hour. Keep the existing refusal message for every other nonzero status.🔧 Fix applied.
✅ Re-checked - no issues remain.
t3 --versionandnode bin/fm-t3-mcp.mjs statusTMPDIR="$PWD/.test-phase-tmp" bash tests/fm-t3-mcp.test.shTMPDIR="$PWD/.test-phase-tmp" bash tests/fm-backend-t3code.test.sh; reached a temporary-home placement refusal after the earlier cases passedTMPDIR=/tmp FM_TEST_ONLY=run_remaining bash tests/fm-backend-t3code.test.sh; reran the secondmate launch case and every remaining case successfullyTMPDIR="$PWD/.test-phase-tmp" bash tests/fm-supervision-events.test.shTMPDIR="$PWD/.test-phase-tmp" bash tests/fm-watch-inbox-meta.test.shbash tests/fm-backend-t3code-live-e2e.test.sh; skipped for missing credentialRantest_uncertain_launch_message_keeps_task_recordin a temporary source snapshot with the previous fm-spawn.sh; reproduced the expected false-refusal failureRantest_uncertain_launch_message_keeps_task_recordagainst the target implementation and captured its unconfirmed-delivery messageCreated and removed a marked disposable lab; exercised missing-credential status/send refusals and implicit versus explicit backend selectionRan realcodex app-server --stdiowith isolated CODEX_HOME; exercisedconfig/read,command/exec, and configuration cleanupRanbin/fm-t3code-codex-env.sh installthrough a symlink and verified refusal preserved the target bytesRemoved task-created worktree fixtures and confirmedgit status --shortwas clean✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.