Skip to content

feat: background runs, stop, and JSON errors for agent use - #17

Merged
3ae3ae merged 1 commit into
general-clifrom
wp/agent-ops
Oct 19, 2026
Merged

3ae3ae merged 1 commit into
general-clifrom
wp/agent-ops

Conversation

@3ae3ae

@3ae3ae 3ae3ae commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Summary

The run-control half of the agent-friendliness work. #16 was the guide half.

  • run --detach: re-launches the same run as a background session leader that logs to <run>/run.log, and returns name, pid and log at once. A child that fails immediately is reported with the log's tail.
  • <run>/run.pid: written while a run is going. A second start of the same run is refused, and stale pid files are cleaned up.
  • harness2 stop [NAME]: sends SIGINT, so the calls in flight finish and a rerun resumes. A detached run's whole process group is signalled. A foreground run gets the signal only for its own process, because its group may contain the shell or the agent that launched it.
  • --json errors: printed as {"error", "exit_code"} on stdout.
  • diff --json: returns {label, changes, diffs}.
  • No hanging on input:
    • apply -i and chat refuse to start without a terminal instead of hanging.
    • init's non-TTY defaults are documented in the guide, together with config set for changing them.

Test plan

  • 153 core tests and 13 plugin tests pass (13 new: detach, early failure, double-start refusal, pid lifecycle, stop for group leader and non-leader, JSON errors, diff --json)
  • ruff
  • A detached run against a real model: covered by the live smoke test after merge

🤖 Generated with Claude Code

- `harness2 run --detach` starts the same run as a background process,
  logging to <run>/run.log, and returns its name, pid and log path at
  once (an immediate failure is reported with the log's tail).
- A running run records itself in <run>/run.pid; a second start of the
  same run is refused, and `harness2 stop [NAME]` asks it to stop: the
  calls in flight finish, the run exits, and rerunning resumes it. Only
  a detached run's own process group is signalled, never the shell or
  agent that launched a foreground run.
- With --json, a failing command prints {"error", "exit_code"} on
  stdout instead of an error line; `diff --json` returns the changes
  and per-file diffs.
- `apply -i` and `chat` refuse to start without a terminal instead of
  waiting for input, and the agent guide says how to change init's
  choices with `config set`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@3ae3ae
3ae3ae merged commit d238082 into general-cli Oct 19, 2026
@3ae3ae
3ae3ae deleted the wp/agent-ops branch October 19, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant