Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

214 stars

Watchers

1 watching

Forks

Repository files navigation

Harness Reins (reins): hand long work and child agents to an independent owner, then resume the exact session that asked

Dispatch work to any agent and route the result back to the session that asked.

Release 0.14.6 npm harness-reins Python ≥ 3.9 Linux, macOS, Windows Works with Codex, Claude Code, Pi and DeepSeek Harness MIT license

Quick start · New: reins tui · Benchmark · How it works · Usage · Docs · 中文


The problem

You ask Codex, Claude Code, Pi or DeepSeek Harness to train a model, run a benchmark, or hand a review to a second agent. The work takes two hours. Now what?

  • The agent polls with sleep && tail, burning turns, tokens and context on nothing.
  • Or the job is owned by the agent's shell, so it dies when the turn ends, times out, or the app restarts.
  • Or the second agent's answer lands somewhere else, and you carry it back to the conversation by hand.

The fix

Reins hands the work, a command or a fresh agent in any harness, to an independent OS-native process owner. When it finishes, Reins resumes the exact same conversation with a short result: what it observed, what a child agent reported, where the files are, and the command to acknowledge it.

$ reins run --task "train model" -- python train.py --config configs/exp.yaml
reins: submitted managed task <task-id>
reins: execution backend: systemd
...

The agent ends its turn — zero model calls while it waits. Two hours later, the same session receives a short envelope like this:

[reins] <task-id>-c1
Task: train model
Result: exited 0 · 2h 3m 32s
From: run on systemd-user
Files: ~/.reins/tasks/<task-id>/ (attempt-1.log)
Details: .../details/<task-id>-c1.md (as needed)
Session: <session-id> (only)
ACK after inspection: reins ack <task-id>-c1

New in 0.14: every session in one terminal

reins tui: a panel lists Claude Code, Codex, Pi and DeepSeek Harness sessions with where each runs and its running tasks; beside it one session is open in its own interface, where a long task was submitted and its result arrived in the same conversation hours later

Ten agents in three harnesses means ten windows, and no way to see which of them is waiting on a task, a reply or you. reins tui puts them on one screen: every Claude Code, Codex and Pi session on the machine, whether it runs in a terminal, the desktop app or the background, with the tasks, goals and messages it started. Press Enter and the session opens in a pane beside the panel, in its own interface.

  • One conversation, never a copy. A closed Claude Code session resumes in the background and the pane attaches to it; a Codex thread opens through Codex's shared app-server, so the pane, Codex Desktop over SSH and every callback write the same thread. A session already open in another window is never opened a second time.
  • Results land where you are looking. A callback for a closed Claude Code session brings it up under the same id, and one for an open Codex thread arrives as a new turn in it, not as a second headless run beside it.
  • Grouped by project, named by you. Sessions sit under their folder, and the Reins name you gave each one stands beside the title its harness picked, so look-alike sessions stay apart. A session that cannot open says why in a window you will not miss.
  • Everything from one menu. Right-click a session (or press o) to open it below or to the right, fork it, open a shell in its directory, message it, pin it, copy its id, stop or archive it. Start a collaborator from the same menu: a new Claude Code, Codex or Pi session that already knows its partner and how to reach it.
  • Safe to leave. Alt+d, closing the terminal or a dropped SSH connection leaves every session running, Alt+q asks first with Detach preselected, and reins tui brings the same screen back.
  • Ready on install. The npm package for Linux and macOS includes Zellij and the panel. Ctrl keys go straight to Claude Code.
reins tui            # the panel
reins tui <id>       # open one session, by its id or a task it started

→ Terminal UI guide · Linux and macOS

Measured: what waiting costs

8× cheaper, 10× fewer model calls, and the work survives the agent being killed. Same agent (Codex with Kimi K3), same task, with and without Reins. → The full benchmark

Over 60 hours the agent without Reins made 911 model requests and spent 287 yuan, then its session was killed and the task failed; with Reins it made 90 requests and spent 35 yuan, and finished all 72 hours

Without Reins the agent has to keep watch: one session polled for 60 hours, made 911 model requests and spent ¥287, and when its process was killed the task died with it. With Reins the agent ends its turn after each step and is called back when there is something to do: ¥35 over the same 60 hours, nothing to kill at hour 60, and the job ran to the end.

Share of wall time: without Reins most of the run is spent waiting with the agent alive; with Reins most of it has no agent process at all

Without Reins With Reins
3-day task, cost of the first 60 h ¥286.78 ¥35.17
Model requests in those 60 h 911 90
Every agent process killed at hour 60 task failed finished all 72 h
Result back in the same session (median) – 2 s
4.8-hour task, cost ¥30.59 ¥30.11

Reins changes what waiting costs and whether the work survives, not how well the model solves the task. Money at list price (input ¥20, cache hit ¥2, output ¥100 per million tokens).

Why more than one harness?

Subscriptions are the cheapest way to use frontier models, and they come tied to a harness. A Claude plan gives you Claude models inside Claude Code; a ChatGPT plan gives you OpenAI models inside Codex. That quota generally can't be pointed at another tool, and each of these harnesses is built around its own vendor's models.

Open harnesses such as Pi work the other way around. They run whatever model you give them: an API key from any provider, an open-weight model on your own GPU, or a cheap fast model for routine steps.

Real work rarely fits one model. Writing, coding, reviewing and long experiments each have a model that does them best or most cheaply, and models keep getting more specialized. Using the right one for each job means running several harnesses side by side, some closed and some open. None of them knows the others exist: a Codex session can't hand a task to Claude Code and get the answer back, and a Pi agent can't report to either.

This project fills that gap. From a Codex, Claude Code, Pi or DeepSeek Harness session, reins agent codex|claude|pi|dsh starts a fresh agent in any of the four as a durable job, and the result comes back to the session that asked for it. Codex, Claude Code, Pi and DeepSeek Harness are harnesses; Reins is what holds all of them, which is why Long Task Callback became Agent Traffic Control and then Harness Reins.

Highlights

Feature What you get
No polling The worker and daemon wait for you. No model turns are spent while the task runs.
Same conversation Callbacks are bound to the original Codex (CODEX_THREAD_ID), Claude Code (CLAUDE_CODE_SESSION_ID), Pi (PI_SESSION_FILE) or DeepSeek Harness (DSH_SESSION_ID) session — never a guess.
Survives the agent Tasks run under systemd, launchd or Task Scheduler — not as a child of the agent turn or even the daemon.
Claude Code native In Claude Code (CLI or desktop app), a background reins wait wakes the conversation you're looking at — no headless side session. → Claude Code guide
Pi native Pi's extension steers the result into the running Pi session — even mid-run, before its next model call. → Pi guide
DeepSeek Harness native A background reins wait runs as a DSH job; its completion notification wakes the same conversation. DSH has no headless fallback, so delivery is always the original live session. → DSH guide
Any agent, any harness reins agent codex|claude|pi|dsh starts a fresh agent as a durable job from any of the four. It writes a structured report, shown to you as a claim, never as proof.
Sessions talk to each other Name a Codex, Claude Code, Pi or DSH session, then reins send to it from any other. Messages survive a busy or closed session, never start a process unless you ask, and agents that talk in circles get stopped. → Guide
Every session in one terminal reins tui lists the Claude Code, Codex and Pi sessions on the machine with the tasks, goals and messages they started, and opens any of them in a pane in its own interface, without a second copy of the conversation. → Guide
One installation reins setup installs one canonical ~/.reins/bin/reins; copies of reins in other environments forward to it, so versions never mix.
Multi-stage goals Track an objective across many callbacks with a YAML plan that the agent must verify before declaring victory.
Never reruns blindly Ambiguous launches, reboots and failures are reported to the agent for inspection — Reins never silently replays work.
Self-repairing setup When something is misconfigured, the agent gets a machine-readable repair plan and fixes it itself.
At-least-once delivery Durable queue, stable callback IDs, retries with backoff, and explicit ACKs.

Quick start

# 1. Install (prebuilt for Linux x64, macOS and Windows x64; see below for other platforms)
npm install -g harness-reins

# 2. Make it the installed Reins, add the skills for Codex + Claude Code, start the coordinator
reins setup --force --enable --now
#    Using Pi too? Add --with-pi-extension (Pi skill + live-callback extension)
#    Using DeepSeek Harness too? Add --with-dsh (skill + launcher discovery)

# 3. Check that everything is healthy
reins --version
reins doctor --agent codex --session <session-id>

Without Node, or on Linux arm64, install from source and run the same reins setup:

python3 -m pip install "git+https://github.com/lz59970062/harness-reins.git"

That's it. setup installs the bundled skill, so your agent already knows when and how to use reins. From inside a Codex, Claude Code or DeepSeek Harness session, just ask it to run something long.

Platform requirements
Platform Task owner Coordinator Notes
Linux Independent systemd user service (v240+) systemd user service Falls back to GNU screen when no user systemd is available (e.g. Docker, AutoDL). See containers.
macOS One-shot launchd job in the GUI session LaunchAgent No screen needed. See macOS guide.
Windows 10+ Per-user Task Scheduler task + Job Object Login scheduled task Requires a logged-in session and an ACL-capable filesystem (NTFS). See Windows guide.

The backend is recorded when a task is submitted and is never silently changed during recovery. To use the screen compatibility backend: sudo apt install screen (or dnf install screen), then reins run --backend screen ....

Codex Desktop callbacks

Start Desktop normally: auto delivers callbacks through the native codex queue command, with no launcher and no restart. Callback modes are explicit (cli, codex-queue, app-server, manual, auto). Read Codex Desktop and callback modes for the details and current limits.

Coming from ATC (atc) or Long Task Callback (ltc)

Reins does not read the records of either. Move over in one explicit step:

reins migrate            # shows what would change; changes nothing
reins migrate --apply    # archives ~/.atc and ~/.ltc, removes the old services, skills and hooks
reins setup --force --enable --now

Each generation moves on its own: one that still has callbacks to deliver or tasks running is left alone and reported, so a busy LTC does not hold back an idle ATC. Add --wait to let the old daemons finish first, or --only atc|ltc to move one. State directories are renamed, never deleted. ATC's systemd drop-ins and its experts.yaml carry over to Reins.

How it works

Five steps: submit, own, run, queue, resume; the agent submits the next stage and the loop repeats

systemd user service (Linux) / LaunchAgent (macOS) / login scheduled task (Windows)
  └─ reins daemon                 control, recovery and callback delivery

Independent per-task service (screen for legacy tasks)
  └─ Reins worker
      └─ training / benchmark / build / child agent
  1. Submit — the agent calls reins run or reins agent. Reins durably records the command, environment, original session binding, backend and log path, then returns immediately.
  2. Own — the daemon asks the OS for a separate task service. The task is not a child of the agent or the daemon.
  3. Run — the job runs for minutes or hours. Nobody polls.
  4. Queue — on exit, Reins stores the result and queues a callback for the original conversation.
  5. Resume — the same session wakes up, inspects the result, and runs reins ack.

Rule of thumb: anything reliably done in under 60 seconds can run in the foreground. Anything longer — or of uncertain duration — goes through reins run.

Usage

Reins has three entry points:

Command Use it when…
reins run -- <command> You want Reins to launch and own a new long task.
reins agent codex|claude|pi -- <prompt> You want a fresh child agent to work in the background and report back.
reins done ... The task is already owned by screen, tmux, Slurm or another scheduler — just report completion.

run — submit a long task

reins run \
  --cwd "$PWD" \
  --task "train model" \
  -- python train.py --config configs/exp.yaml

Returns as soon as the task is durable, printing the task ID, backend and log file:

tail -f ~/.reins/tasks/<task-id>/attempt-1.log

DeepSeek Harness: wake the live session

DSH keeps background jobs alive across turns and notifies the conversation when one exits. After reins run, it prints the exact command to start with run_in_background: true:

reins wait --queue-dir ~/.reins/queue --task <task-id>

Read the finished job's output with job_output; that output is the callback. DSH's one-shot runner refuses desktop-preset sessions, and a second writer would race the live writer lock, so Reins never resumes a DSH conversation headlessly: with no waiter the callback stays queued until this session runs reins wait again. → DSH guide

Claude Code: wake the live session

Claude Code wakes a session when a background shell command exits. After reins run, it prints the exact command to run with run_in_background:

reins wait --queue-dir ~/.reins/queue --task <task-id>

reins wait exits — and the session wakes up — as soon as the callback is queued. While a waiter is alive the daemon stays out of the way; if the session is gone, the daemon falls back to a headless claude -p --resume from the session's original directory. The installed Claude skill teaches Claude to do this on its own. → Claude Code guide

agent — delegate to a background child agent

reins agent claude --cwd "$PWD" --task "review parser edge cases" \
  -- "Inspect parser.py and its tests. Report concrete defects and suggested fixes."

reins agent codex --template test --task "write parser tests" \
  -- "Use docs/parser-contract.md to test parser.py, including invalid input and boundaries."

The child gets its own private prompt/result files; the callback still goes to your conversation. Use --template / --template-file for reusable prompts, --model / --reasoning-effort to pin the child's model, and --dry-run to preview. → Agent mode & templates

done — report an externally managed task

set +e
python train.py --config configs/exp.yaml
status=$?
reins done --cwd "$PWD" --task "train model" \
  --command "python train.py --config configs/exp.yaml" --exit-code "$status"
exit "$status"

Drop this into a screen/tmux session, Slurm epilogue, shell trap or Python finally. done only queues the callback — it doesn't make the preceding process durable.

Acknowledge, inspect, cancel

reins wait --task <task-id>         # (Claude Code / DSH) block until the callback is ready, then print it
reins ack <callback-id>        # confirm a callback was received and inspected
reins status                        # list callbacks that still need handling
reins cancel --id <callback-id>     # cancel a queued callback
reins retry --id <callback-id>      # re-deliver a result without rerunning the task
reins owner [<task-id>]             # which session started a task, by its Reins name
reins stop <task-id> -m "why"       # stop a task for good; its session is told not to rerun it
reins doctor --agent codex --session <id>   # JSON readiness report + repair plan

Multi-stage goals

Callback ACK says "I saw this result." Goal ACK says "the whole objective is done (or blocked)."

reins goal start --id report-goal --session <session-id> --cwd "$PWD" \
  --task "finish the report" --plan-file .reins/goals/report-goal.yaml
reins goal check --id report-goal
reins goal ack --id report-goal --state completed --plan-sha256 <checked-sha256>

The plan is an editable YAML path of steps. Completion is rejected unless every step is completed and the digest matches a fresh goal check. Idle goals get a status nudge every three hours. → Goals guide

send — message another session

reins session register reviewer          # inside the session that should receive
reins send reviewer --subject "Check the queue change" -m "Branch feature/queue is ready."
reins inbox                              # what is waiting for this session

Works across Codex, Claude Code, Pi and DeepSeek Harness on one machine. Messages between machines are planned. → Messages between sessions

tui — every session in one terminal

reins tui                # the panel, with each session's tasks and messages
reins tui <id>           # open one session, by its id or a task it started

Double-click a session to open it beside the panel; n starts a new one, a right click opens its menu. Claude Code and Codex sessions keep running when you close the pane or the screen. Not on Windows. The npm package for Linux and macOS includes Zellij; with pip, install harness-reins[tui] and Zellij. → Terminal UI guide

Session binding

Inside an agent conversation, Reins binds automatically via CODEX_THREAD_ID (Codex) or CLAUDE_CODE_SESSION_ID (Claude Code). You can also bind explicitly:

reins done --agent claude --session <session-id> --cwd "$PWD" --task "external job" --exit-code 0

If no target can be determined, Reins fails instead of guessing; there is no "most recent session" fallback.

Guarantees and boundaries

  • At-least-once delivery. Unacknowledged callbacks retry with backoff. After a host failure a callback may arrive twice, so resumed agents inspect existing processes and artifacts before acting.
  • No blind reruns. After a reboot, Reins wakes the original session with the task, log path and interruption reason — the agent decides whether to resume from a checkpoint. There is no --resume-command.
  • No cross-host recovery. Reins does not move workspaces, data, checkpoints or credentials between machines.
  • Private state. Everything lives under ${REINS_HOME:-~/.reins}/; full callback details are saved privately in details/<callback-id>.md. An older ~/.codex/harness-reins/ is moved there on first run and left as a symlink.

More in recovery & self-repair and architecture.

Upgrading from 0.6

Drain existing work and upgrade the coordinator before submitting native tasks, or use a separate 0.7 queue and Agent profile — the 0.6 daemon does not understand native task records. Pass the same --queue-dir /absolute/path/to/reins-queue to reins daemon, reins run and reins ack. Standalone coordinators also need separate CODEX_HOME profiles. The submitting shell must carry the original Agent session ID (or pass --session). Old scripts may still pass --via-daemon; it is a hidden no-op.

Service management
# Linux
systemctl --user status harness-reins.service
journalctl --user -u harness-reins.service -f
# macOS
launchctl print "gui/$(id -u)/harness-reins"

reins setup --service auto picks systemd (Linux), launchd (macOS) or windows-task (Windows). Use --service standalone --now where user systemd is unavailable (e.g. AutoDL), or --service supervisor explicitly. Standalone setup does not register startup on its own — see containers for boot hooks, Supervisor and Docker restart policies.

Documentation

中文文档站 · 文档源码

Topic
Claude Code: live callbacks, binary discovery, session directories docs/claude-code.md
Pi: steered live callbacks, managed sessions, Pi child agents docs/pi.md
DeepSeek Harness: live jobs, no headless resume, DSH child agents docs/dsh.md
Terminal UI: sessions, tasks and messages in one place docs/guides/tui.en.md
Agent mode, templates, Claude Code config docs/agent-mode.md
Registering templates as discoverable skills docs/template-registration.md
Goals and acknowledgement layers docs/goals.md
Callback format, reminder cadence, user hook docs/callback-reminders.md
Callback modes (CLI / Desktop / manual) docs/callback-modes.md
Restart, recovery and self-repair docs/recovery.md
Protocol v1 and package architecture (design) protocol · architecture
Platform ownership and extension points docs/architecture.md
macOS · Windows · Containers macOS · Windows · Containers
Benchmark: what waiting costs, with and without Reins Benchmark
Validation records 0.8.0.dev0 Linux in Docker
Validation records (Long Task Callback era) 0.7.0 · 0.7.1 preview · Linux preview · macOS · Windows
Release history CHANGELOG.md

Roadmap

  • Native task owners on Linux, macOS and Windows
  • Fresh child agents in Codex, Claude Code and Pi; live callbacks into Claude Code and Pi
  • Protocol v1: root-plus-suffix IDs, record schemas, delivery capabilities, results that keep child reports apart from observed facts (0.8)
  • One canonical installation and npm distribution for Linux x64 (0.8)
  • Prebuilt npm packages for macOS and Windows (0.14.5)
  • Messages between Codex, Claude Code and Pi sessions on one machine (0.11), and DeepSeek Harness (0.12)
  • A terminal UI for every Claude Code, Codex and Pi session on the machine (0.14)
  • Messages between machines, over SSH and an authenticated port (design)
  • Expert agents, and forking an expert's context from a checkpoint
  • Fan-in: one callback when a group of tasks finishes
  • More harnesses: Gemini CLI, OpenCode, and agents that speak ACP
  • A first benchmark against working without Reins: Codex and Pi, Terminal-Bench 4 and a 3-day task (results)
  • Benchmark with several runs per cell, more models, and injected faults on regular tasks

License

MIT · Reins was previously Agent Traffic Control (atc) and, before that, Long Task Callback (ltc); see Coming from ATC or Long Task Callback.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

214 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages