Skip to content

Spec: four more Harnesses (agy, Grok Build, Muse Code, OpenCode) #432

Closed
6 of 6 issues completed
Closed

Description

@JacobStephens2

Problem Statement

A Command can run its agent sessions on only two Harnesses, Claude Code and Codex. Jacob also wants to run the factory on Gemini 3.8 Flash in Antigravity CLI (agy), Grok 4.7 in Grok Build (grok), Muse Spark 1.3 in Muse Code (muse), and MiMo-V2.6-Pro in OpenCode (opencode). Today he can't choose any of them: the command line, the User config and Setup know only claude and codex.

Each of these CLIs runs headless and does the basics thirdshift needs, but each has gaps that would make an unattended Run fail silently, or fail confusingly:

  • Grok and OpenCode leave the agent's shell command running when stopped.
  • Muse and OpenCode don't load a skill named on the prompt's first line.
  • Muse runs its replies together in its final text, and an Architecture review decides its outcome from that final message.
  • OpenCode's stream often drops its last usage event.
  • agy never reads CLAUDE.md, and OpenCode reads only AGENTS.md.
  • Several of these CLIs update themselves in the background, which could replace the binary in the middle of a Run.

Each Harness also adds another branch to code that is already spread across several match statements per Harness.

Solution

thirdshift gains four Harnesses, named as their CLIs are: agy, grok, muse and opencode. Each can be chosen wherever claude and codex can be: the harness flag, harness.default, a [harness.<name>] section with a Model and Effort, and Setup.

Before any of them is added, the Harness module is deepened. Everything one Harness does moves into one adapter, so a new Harness is one adapter rather than edits to every place that matches on the Harness.

Stopping a session becomes one rule for every Harness: thirdshift stops the session's whole process tree, not just the CLI's process group.

Every Harness runs unattended and fully trusted in the worktree, with fixed flags and environment (ADR 0013), and with its self-update turned off.

Each Harness reads its own instruction file and falls back to the other. thirdshift adds the fallback, as a link at the worktree root kept out of git, where a CLI has none.

The Factory skills are linked where each Harness finds them. On a Harness that doesn't load the skill named in the prompt by itself, the Session prompt tells the model to load it, and thirdshift warns when the stream shows it never did.

The Model and Effort are checked before any work, the way each CLI allows. The final message, usage and failure come from wherever each CLI reports them reliably.

The design was settled in a grilling session on #428. The facts behind it are in the harness candidates research note, including its §6 on OpenCode and the corrections.

User Stories

  1. As a factory user, I want to choose agy as the Harness with the harness flag, so that a Command's sessions run on Gemini 3.8 Flash in Antigravity CLI.
  2. As a factory user, I want to choose grok as the Harness, so that a Command's sessions run on Grok 4.7 in Grok Build.
  3. As a factory user, I want to choose muse as the Harness, so that a Command's sessions run on Muse Spark 1.3 in Muse Code.
  4. As a factory user, I want to choose opencode as the Harness, so that a Command's sessions run on MiMo-V2.6-Pro, or any other Model my OpenCode providers route.
  5. As a factory user, I want to set harness.default to any of the six names in the User config, so that every Run on my machine uses that Harness unless a command says otherwise.
  6. As a factory user, I want a [harness.agy], [harness.grok], [harness.muse] and [harness.opencode] section, each with its own Model and Effort, so that switching Harness picks up the right Model for it.
  7. As a factory user, I want an unknown Harness name to fail with a message listing all six names, so that I can correct a typo.
  8. As a factory user, I want a Command to fail before any work, naming the setting that chose the Harness, when that Harness's CLI is not on PATH, so that no worktree, branch or Claim is made for a Run that can't start.
  9. As a factory user, I want the Model and Effort checked against agy's free catalog before any work, so that a typo costs nothing and says which Models and Efforts are valid.
  10. As a factory user, I want the Model and Effort checked against Grok's free catalog before any work, for the same reason.
  11. As a factory user, I want Muse's Model checked against Muse's cached catalog when it exists, and with a test call when it doesn't, so that a wrong Model is caught before any work even though Muse has no free model list.
  12. As a factory user, I want OpenCode's Model and Effort checked with a test call before any work, so that a wrong Model or variant is caught at no model cost, and a right one costs one tiny turn.
  13. As a factory user, I want Model and Effort names settled on the names each Harness takes, regardless of case where its catalog allows, so that I can write a Model the way I'd say it.
  14. As a factory user, I want OpenCode's Effort passed as the variant suffix on its Model, so that effort high reaches MiMo-V2.6-Pro as #high.
  15. As a factory user, I want Setup to offer only the Harnesses installed on my machine, with claude as the default when it is installed, so that the question stays short and lists only what can run.
  16. As a factory user, I want Setup to propose muse-spark-1.3 as the Model when I choose Muse, so that my content isn't used for product improvement by Muse's default -contributor Model without my knowing.
  17. As a factory user, I want Setup to ask for an OpenCode Model with no proposed default, and check my answer with a test call, so that I enter the provider-specific id my OpenCode setup uses.
  18. As a factory user, I want Setup to check an agy or Grok Model and Effort against its catalog, as it does for Codex, so that the User config never holds a name the Harness refuses.
  19. As a factory user, I want every session on every Harness to run with no approval prompts and no sandbox, so that an unattended Run never stalls on a question and can commit to the shared .git.
  20. As a factory user, I want Grok sessions to run with its folder-trust check off, so that I never have to run grok --trust in each repository, and a scheduled Pickup run never silently runs without AGENTS.md or its skills.
  21. As a factory user, I want Muse sessions to run with --yolo, so that they work on stock Ubuntu, where Muse's sandbox can't start.
  22. As a factory user, I want OpenCode sessions to run --standalone, so that they don't depend on a shared background service whose version and environment thirdshift doesn't control.
  23. As a factory user, I want each Harness's self-update turned off in every session, every Resume and every Model check, so that the binary can't change in the middle of a Run.
  24. As a factory user, I want those flags and environment variables fixed per Harness and documented, so that a session behaves the same on every machine whatever the CLI's own config says.
  25. As a factory user, I want interrupting a Command to stop every process its sessions started, including a shell command the CLI started in a process group of its own, so that nothing keeps running against a worktree after thirdshift has left it.
  26. As a factory user, I want that tree-stop to apply to Claude and Codex as well, so that a leaked command is stopped whichever Harness started it.
  27. As a factory user, I want the stop to send each Harness its own stop signals, then SIGKILL after the grace period, so that a CLI that stops cleanly gets the chance to.
  28. As a repository owner who keeps only AGENTS.md, I want every Harness to read it, so that one file serves all six.
  29. As a repository owner who keeps only CLAUDE.md, I want agy to read it through a GEMINI.md link and OpenCode through an AGENTS.md link, each made only where that Harness's own file is missing, so that the Harness choice doesn't decide whether my rules are read.
  30. As a repository owner, I want those links kept out of git, so that a Run never commits them.
  31. As a repository owner who deliberately keeps different AGENTS.md and CLAUDE.md, I want each Harness to read its own file where it exists, so that the difference survives. Grok reading both is documented.
  32. As a factory user, I want the Factory skills linked where each new Harness finds them, so that every Session prompt's skill is there to load.
  33. As a factory user, I want agy and Grok sessions to load their skill from the /thirdshift-<skill> first line of the Session prompt, as Claude does, so that their prompts match Claude's.
  34. As a factory user, I want Muse and OpenCode sessions' prompts to tell the model to load thirdshift-<skill> with its skill tool, so that these CLIs, which don't expand /name, still run the skill.
  35. As a factory user, I want a warning in the progress lines and the Command log when a Muse or OpenCode session's stream shows its skill was never loaded, so that I can tell when a session ran without its skill.
  36. As a factory user, I want the progress lines to condense each new Harness's stream: the session started, tool calls, errors, and the session-ended summary, so that I can follow a Run on any Harness.
  37. As a factory user, I want each session's full stream kept in its Session log on every Harness, so that I can read exactly what happened.
  38. As a factory user, I want the session id read from each Harness's stream, so that a Resume continues the same session.
  39. As a factory user, I want a Resume on each Harness to use that CLI's own resume-by-id, with the same flags and environment as the session it continues, so that it runs under the same conditions.
  40. As a factory user, I want an agy or Grok session's final message read from its final result event, so that an Architecture review on those Harnesses decides its outcome correctly.
  41. As a factory user, I want a Muse session's final message and usage read from Muse's own session log once the session exits, falling back to the stream when that log is missing or unreadable, so that the Architecture review sees the last reply alone rather than every reply run together.
  42. As a factory user, I want an OpenCode session's final message, usage and outcome read from opencode session export once it exits, falling back to the stream's last text without usage when the export fails, so that a dropped last event can't lose them.
  43. As a factory user, I want an OpenCode session whose exported outcome is failed to fail, whatever its exit code, so that a failed turn is never taken for success.
  44. As a factory user, I want a session on any new Harness that fails its turn to fail the Run with that Harness's own error text, so that the cause I read names what went wrong.
  45. As a factory user, I want each Harness's equivalent of background work killed at session end treated as Claude's and Codex's is, where its stream shows it, so that a Resume is started when a session ended while waiting on work.
  46. As a factory user, I want the "Built with" line in a pull request and a Run notification to name the new Harness, Model and Effort, so that I know what built the work.
  47. As a factory user, I want a Spec run's child Runs, a Base fix, every Repair and every Resume to run on the Command's Harness, so that one Command never mixes Harnesses.
  48. As a factory user, I want the docs to list each Harness: its product, its CLI name, the flags and environment it runs with, which instruction files it reads (including whether it reads ~/.claude/), and its quirks, so that I can choose one with my eyes open.
  49. As a factory user, I want CONTEXT.md's Harness entry to name all six Harnesses, so that the domain language matches the code.
  50. As a thirdshift maintainer, I want everything one Harness does gathered into one adapter, so that adding the next Harness touches one place.
  51. As a thirdshift maintainer, I want that deepening to change no behavior, with every existing Claude and Codex test passing unchanged, so that the refactor is safe on its own.
  52. As a thirdshift maintainer, I want a fake CLI for each new Harness in the test harness, emitting that CLI's real stream shape, so that each Harness's sessions are tested end to end.
  53. As a thirdshift maintainer, I want the tree-stop tested with a command that escapes its process group, so that the guarantee is checked on every Harness.

Implementation Decisions

  • Ticket order. This Spec's Tickets are:

    1. Deepen the Harness module, with no behavior change.
    2. Stop the whole process tree for every Harness. Blocked by 1.
    3. agy. Blocked by 1.
    4. Grok Build. Blocked by 1 and 2.
    5. Muse Code. Blocked by 1.
    6. OpenCode. Blocked by 1 and 2.

    Each Harness Ticket also updates CONTEXT.md, the docs and Setup's list of Harnesses, so that its pull request leaves that Harness usable from end to end.

  • The Harness adapter. One deep module per Harness behind one interface, which owns:

    • its name (which is its CLI's) and product name;
    • the arguments for a new session and for a Resume;
    • how the prompt reaches the CLI (an argument or stdin);
    • how the Session prompt names its skill: the / sigil, the $ sigil, or an instruction to load it with the skill tool;
    • the project skills directory;
    • its instruction-file fallback, if any;
    • its fixed environment;
    • its stop signals;
    • its Model and Effort check, settling names;
    • its stream parser (the existing stream interface: progress lines, summary, final message, session id, killed background work, failure and error);
    • the step after the session exits that reads the final message, usage and outcome from outside the stream, where the Harness needs one.

    The rest of thirdshift chooses the adapter once from the Harness and never matches on the Harness again. The ALL list and NAMES come from the adapters.

  • Harness names. claude, codex, agy, grok, muse and opencode. Setup lists them in that order.

  • Tree-stop. Before signalling, thirdshift takes a snapshot of the session's descendant processes with ps, which works on both release targets (Linux and macOS). It then sends each process group in that snapshot the Harness's stop signals in turn, each with the grace period, and finally SIGKILL. A second snapshot before SIGKILL catches processes started in the meantime. This applies to every Harness.

  • Unattended flags and environment (ADR 0013).

    Harness Flags Environment
    agy -p, --dangerously-skip-permissions, --output-format stream-json, never --sandbox AGY_CLI_DISABLE_AUTO_UPDATE=true (=1 is ignored)
    Grok -p, --always-approve, explicit even when the user's config already approves GROK_DISABLE_AUTOUPDATER=1, GROK_FOLDER_TRUST=0
    Muse exec --json --yolo MUSE_NO_AUTO_UPDATE=1
    OpenCode run --standalone --format json --auto, prompt on stdin (an argument containing a space is wrapped in literal quotes) OPENCODE_DISABLE_AUTOUPDATE=1

    Stdin is null for every other Harness, as it is today.

  • Model and Effort, per Harness.

    • agy: --model and --effort. The check reads agy models and its supported efforts, without a turn. A Model whose name carries its effort, such as gemini-3.8-flash-medium, is accepted as agy resolves it.
    • Grok: -m and --reasoning-effort. The check reads grok models, without a turn.
    • Muse: --model and --reasoning-effort. The check reads Muse's cached model catalog when it exists, and otherwise makes a minimal test call. An invalid Effort fails before any call anyway.
    • OpenCode: -m <provider>/<model>#<effort>. The check is a minimal standalone test call: a bad Model or variant fails with a provider.no-route error in about 2.5 s, before any model call. There's no free catalog without OpenCode's background service.
  • No Model set. This still means the Harness's own default for every Harness. For Muse, Setup proposes muse-spark-1.3, and the docs say that Muse's own default is the -contributor Model.

  • Resume.

    • agy: --conversation <id>.
    • Grok: -r <id>.
    • Muse: --session-id <id>.
    • OpenCode: -s <id>, in standalone.

    Ids always come from the stream. OpenCode creates a new session for an unknown id, so an id must never be made up.

  • Stream parsing.

    • agy: its init event gives the session id. Its step_update events give the progress lines. Its final result event gives the status, final text, error and usage.
    • Grok: its Claude-shaped streaming-messages-json format gives the session id, final message, errors and usage, so it may reuse the Claude parser where the shapes match.
    • Muse: the session id is stream.id. Text arrives as deltas, tool events as tool.result, and failure as run.terminal.failed.
    • OpenCode: each line's sessionID gives the session id. Progress comes from text, tool_use and step_finish events, and failure from error.
  • Reading after the session exits.

    • Muse: read the last reply and the usage from Muse's own session log for that id. Fall back to the stream if the log is missing or can't be parsed.
    • OpenCode: run opencode session export --standalone <id>.
      • Its outcome failed fails the session.
      • The final message is the last assistant message's last text part.
      • The usage is the sum over the assistant messages, which leaves out the automatic title call.
      • If the export fails, fall back to the stream's last text and show no usage.
  • Skill loading. The Factory skills are linked into .agents/skills/ for agy, Grok, Muse and OpenCode, and kept out of git as today (ADR 0012).

    • agy and Grok expand /thirdshift-<skill> themselves.
    • For Muse and OpenCode, the first line of the Session prompt tells the model to load thirdshift-<skill> with its skill tool. The parser watches for that load: OpenCode's tool_use with tool == "skill" and the skill's name as input, and Muse's read_skill call. If the skill was never loaded, thirdshift writes a warning line, and the session neither fails nor is retried.
    • The generated Prompts and skills page keeps showing Claude's form.
  • Instruction-file fallback. Rule: Claude reads CLAUDE.md and falls back to AGENTS.md (Claude Code already does this). Every other Harness reads AGENTS.md and falls back to CLAUDE.md.

    • Codex keeps its existing config setting for this.
    • Muse needs nothing.
    • agy gets a GEMINI.md link to CLAUDE.md at the worktree root when CLAUDE.md exists and neither AGENTS.md nor GEMINI.md does.
    • OpenCode gets an AGENTS.md link to CLAUDE.md when CLAUDE.md exists and AGENTS.md doesn't.
    • Both links are excluded through .git/info/exclude.
    • Grok's loading of both files is documented, not worked around.
  • User-level instructions. thirdshift writes nothing to a Harness's user-level instruction files. The docs say which Harnesses read ~/.claude/: Claude, Grok and Muse.

  • Setup.

    • The Harness question lists only the installed Harnesses.
    • The Model and Effort questions follow the chosen Harness. agy and Grok are checked against their catalogs. Muse is checked as its Command check does, with muse-spark-1.3 proposed. OpenCode is checked by test call, with no default proposed.
    • The User config template written out has a section for every Harness.
  • Domain docs. CONTEXT.md's Harness entry already names all six Harnesses. ADR 0013 records the unattended and trusted flags. Neither is reopened by this Spec.

Testing Decisions

  • A good test exercises thirdshift from the outside: a real Run against fake CLIs, then assertions on what the fake recorded (argv, environment, stdin, working directory, linked skills, instruction-file links) and on what thirdshift did (progress lines, Session logs, pull request, failure cause, exit status). It tests no adapter internals.
  • Primary seam: the scenario harness with a fake CLI on PATH, as Codex is tested today with a fake codex and the Codex sessions scenario test.
    • Each new Harness gets a fake CLI that emits that CLI's real stream shape (taken from the research note's recorded events), records each call, and runs the per-test script as the fake claude and codex do.
    • Muse's fake also writes a session log, and OpenCode's fake answers session export.
    • A sessions test file per Harness covers:
      • the flags and environment;
      • skill linking and the prompt's skill line;
      • the instruction-file fallback link, and that it stays untracked;
      • the Model and Effort check, passing and failing before any work;
      • Resume by id;
      • a failed turn;
      • the final message reaching an Architecture review;
      • for Muse and OpenCode, the reads after exit and their fallbacks, and the skill-not-loaded warning;
      • for OpenCode, an exported outcome of failed with exit 0.
  • Tree-stop is tested through the same seam. A fake session's script starts a long command in its own session (as setsid does) and records its pid. The test then interrupts the Run and asserts the command is gone. It runs for every Harness, Claude and Codex included.
  • Ticket 1 adds no tests. Every existing test passes unchanged, which is its acceptance check: the Codex sessions, Harness choice, Setup, User config, progress lines and background work tests.
  • Secondary seam: unit tests on pure parsing. Prior art: the Codex progress parser's tests, and the catalog parse tests in the Harness module. They cover each stream parser fed recorded lines (including OpenCode's dropped last step_finish and Muse's run-together final text), each catalog parser (agy, Grok, Muse's cache), Muse's session-log reader and OpenCode's export reader.
  • Setup is tested through its existing outside-world fake, extended with which Harnesses are installed and with each Harness's catalog or test-call result, as the Setup tests do for Codex today.

Out of Scope

  • MiMo Code (mimo). MiMo-V2.6-Pro runs in OpenCode instead. The research note keeps MiMo Code's findings and its Effort override.
  • Retrying a session on a transient backend failure, such as agy's occasional 503. If it shows up in real Runs, it gets a separate issue covering every Harness.
  • A sandboxed mode for any Harness, for machines where bubblewrap works.
  • Copying the user's ~/.claude/ instructions into Codex, agy or OpenCode's user-level files.
  • Reviewers from several model families (Multi-family review: have another model family review a Run's work #429). Each new Harness becomes available to it, but that design is Multi-family review: have another model family review a Run's work #429's.
  • Re-checking the research note's agy findings against agy 1.3.0. The test machine was upgraded from 1.2.17 by accident during research.

Further Notes

  • Spec for add support for more harness/model pairs #428. The design was settled in a grilling session, and the full record is in the grilling notes. The facts are in the harness candidates research note (§1–§4 per CLI, and §6 for OpenCode and the corrections). The decision on flags and trust is ADR 0013, which extends ADR 0012.
  • agy's start-up varied from 8 to 95 s in testing. Nothing in this Spec depends on it being fast.
  • OpenCode's --standalone adds about 2–3 s per session and briefly watches the home directory. Both are accepted in ADR 0013.
  • Muse sends about 26,500 input tokens per model call, which makes its test call the most expensive check. That is why its cached catalog is read first.

Sub-issues

Sub-issues

6 of 6 Issues completed
Loading 6 sub-issues

Activity

  1. added
    ready-for-agent
    and removed
    ready-for-agent
    on Oct 6, 2026
  2. added
    ready-for-agent
    in-progress
    and removed
    ready-for-agent
    on Oct 6, 2026
  3. removed
    in-progress
    on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions