Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .agents/skills/harness-adapters/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Muse, Gemini, Prime Agent, and AGY are verified only for crewmate and scout work
`../../../bin/fm-harness.sh` prints firstmate's own harness from verified environment markers and process ancestry, and owns how they combine.
A marker names its harness, but a structural ancestor of a different harness outranks it, because a marker is ordinary environment state a child or a multiplexer can retain while ancestry is what proves who owns the process tree.
Only `FM_PI_HARNESS=pi-signed` at the launch boundary together with `PI_CODING_AGENT=true` selects Pi-signed; shared unmarked launcher ancestry remains Pi.
Prime Agent and Pi share `PI_CODING_AGENT=true`, so only the launch marker `FM_PI_HARNESS=prime-agent`, established by `../../../bin/fm-spawn.sh` at the prime-agent launch boundary, selects Prime Agent, checked before the `CLAUDECODE` fast path and the unmarked Pi result and after the cursor, gemini, rovo, and omp marker arms; Prime Agent's own session-wide `PRIME_AGENT_*` values are not detection evidence, so an unmarked Prime Agent session stays Pi-family until the supervision slices land.
Prime Agent and Pi share `PI_CODING_AGENT=true`, so only the launch marker `FM_PI_HARNESS=prime-agent`, established by `../../../bin/fm-spawn.sh` at the prime-agent launch boundary, selects Prime Agent, checked before the `CLAUDECODE` fast path and the unmarked Pi result and after the cursor, gemini, rovo, and omp marker arms; Prime Agent's own session-wide `PRIME_AGENT_*` values are not detection evidence, so an unmarked Prime Agent session stays Pi-family by design.
The marker is accepted only with the Pi-family marker, and when `CLAUDECODE=1` is present too it acts as a precedence override rather than evidence, like `FM_OMP_HARNESS=omp`: the verdict is prime-agent only when a real `prime-agent` process is in the ancestry, and a claude pane started by hand inside a Prime Agent session stays claude.
omp publishes no marker of its own; `FM_OMP_HARNESS=omp` is Firstmate's launch marker and the anchored process name `omp` is its ancestry evidence, as `references/harness/omp.md` records.
`../../../bin/fm-spawn.sh` owns worker marker establishment, while the README launch command owns the signed-primary boundary.
Expand Down Expand Up @@ -91,7 +91,6 @@ A new tool remains undispatchable until the `verify` plan, its harness entry, ev
"pi": "references/harness/pi.md",
"pi-signed": "references/harness/pi.md",
"prime-agent": "references/harness/prime-agent.md",
"prime-agent": "references/harness/prime-agent.md",
"grok": "references/harness/grok.md",
"kimi": "references/harness/kimi.md",
"cursor": "references/harness/cursor.md",
Expand Down
65 changes: 39 additions & 26 deletions .agents/skills/harness-adapters/references/harness/prime-agent.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
# Prime Agent

This slice registers Prime Agent as a distinct Pi-family harness and covers detection, crewmate/scout launch, and control mechanics.
Herdr pane classification and detached-daemon-session retirement land in the following adapter slices; primary supervision does too, so a secondmate launch is refused here.
This reference covers Prime Agent detection, crewmate/scout launch, semantic busy state, and control mechanics.
The active empirical record is [`docs/verification/prime-agent.md`](../../../../../docs/verification/prime-agent.md).
Secondmate launches remain outside the verified boundary.

## Detection

Prime Agent exports `PI_CODING_AGENT=true`, the same Pi-family marker used by Pi and Pi-signed.
The launch-boundary marker `FM_PI_HARNESS=prime-agent` is what disambiguates it when paired with the Pi-family marker, the same Firstmate-owned mechanism `FM_PI_HARNESS=pi-signed` uses for the signed wrapper.
Prime Agent's own `PRIME_AGENT_CODING_AGENT_DIR` and `PRIME_AGENT_INTERNAL_DAEMON_WORKER=1` are session-wide inherited values and are deliberately not detection evidence: an unmarked Prime Agent session stays Pi-family.
`../../../bin/fm-harness.sh` checks the Prime Agent marker before `CLAUDECODE` and the unmarked Pi result, and after the cursor, gemini, rovo, and omp marker arms.
Those four therefore keep their identity when one of them is started by hand inside a Prime Agent session.
grok is deliberately not among them: `GROK_AGENT=1` is already tested after the unmarked Pi result, so a grok session started inside any Pi-family session has always resolved to that family, and reordering it belongs outside this slice.
An explicit `FM_PI_HARNESS=pi` or `FM_PI_HARNESS=pi-signed` is therefore what a Pi or Pi-signed session carries, and neither is ever relabelled.
The marker without `PI_CODING_AGENT=true` is ignored, so it cannot relabel a Claude or unrelated process.
The marker can itself leak into a Claude pane of the same session, so when `CLAUDECODE=1` is present it is a precedence override rather than evidence, the same boundary `FM_OMP_HARNESS=omp` uses: the verdict is `prime-agent` only when a `prime-agent` process sits within eight parents, and otherwise falls through to `claude`.
With `CLAUDECODE` absent the marker stands alone and no ancestry is required.
Prime Agent does not clear the foreign markers it inherits either, so a prime-agent launch clears `CLAUDECODE` and `GROK_AGENT` in its own template and rides the shared launch prefix that clears `CURSOR_AGENT`, `CURSOR_INVOKED_AS`, and `GEMINI_CLI`, which is what keeps a prime-agent worker started under a cursor or gemini primary from resolving as that primary.

Detection was verified against Prime Agent 0.9.1 on Linux, with earlier checks against 0.7.1 and 0.7.2.

## Launch and control

`../../../bin/fm-spawn.sh` launches a prime-agent crewmate or scout on the same single-positional brief and `-e` extension shape as Pi, establishing `FM_PI_HARNESS=prime-agent` so the worker identifies itself, passing `--model` and `--thinking`, and writing the turn-end notification extension to `state/<task-id>.prime-ext.ts` outside the worktree.
`../../../bin/fm-teardown.sh` removes that extension with the rest of a task's wiring, and `fm_control_harness_wiring_paths` lists it so a relaunch onto another harness retires it.
Control mechanics are Pi's, verified on Prime Agent 0.9.1: a single `Escape` cancels a turn, the composer is left empty afterwards so no clear key is needed, and `/quit` exits.
`../../../bin/fm-spawn.sh --help` owns the executable-preflight mechanics: a missing `prime-agent` executable on PATH refuses before endpoint or metadata creation.

## Scope of this slice

Detection keys on the explicit `FM_PI_HARNESS=prime-agent` launch marker only, so a firstmate-launched worker identifies itself while a Prime Agent PRIMARY still resolves as Pi-family exactly as it did before.
Ambient auto-detection of that primary, and a prime-agent secondmate, arrive with the supervision slices that give the value a supervision model, a supervision snippet, and the primary supervision extensions; a secondmate spawn is refused here rather than launched unsupervised.
The launch-boundary marker `FM_PI_HARNESS=prime-agent` disambiguates it when paired with the Pi-family marker.
Prime Agent's own `PRIME_AGENT_CODING_AGENT_DIR` and `PRIME_AGENT_INTERNAL_DAEMON_WORKER=1` are inherited session values, not detection evidence.
`../../../bin/fm-harness.sh` checks the Prime Agent marker before `CLAUDECODE` and the unmarked Pi result and after the cursor, gemini, rovo, and omp marker arms.
Those four keep their identity when started by hand inside a Prime Agent session.
With `CLAUDECODE=1`, the marker selects Prime Agent only when a real `prime-agent` process sits within eight parents.
Without `CLAUDECODE`, the marker is sufficient once the Pi-family marker is present.
A marker without `PI_CODING_AGENT=true` is ignored.
The Prime Agent launch clears `CLAUDECODE` and `GROK_AGENT` and uses the shared launch prefix to clear cursor and Gemini markers.
An unmarked Prime Agent session remains Pi-family by design.
Detection and launch markers were verified live against Prime Agent 0.9.4.

## Launch and busy state

`../../../bin/fm-spawn.sh` launches a Prime Agent crewmate or scout with one encoded brief, `--provider`, `--model`, `--thinking`, and `-e state/<task-id>.prime-ext.ts`.
The generated extension writes the semantic busy record on `agent_start`, clears it after a settled `agent_end`, and touches the turn-end notification marker on `turn_end`.
Prime Agent 0.9.4 has no `agent_settled` event, so error stop reasons and pending messages hold the busy record for a short grace window.
`bin/fm-busy-lib.sh` trusts the generated `prime-ext` source only for a recorded Prime Agent task.
The extension is written outside the project and is removed by cleanup and harness relaunch wiring.
Prime Agent primary supervision and secondmate launch remain unproven and are outside this adapter's verified scope.

## Control

Prime Agent uses the Pi-family control table.
A single `Escape` interrupts a running turn and leaves the composer empty without a clear key.
`/quit` exits the Prime Agent process and leaves the detached daemon worker for directory-bound retirement.
Relaunch starts a fresh Prime Agent client in the same pane and directory rather than claiming an unverified pane-resume contract.
Prime Agent 0.9.4 control behavior was verified live in Herdr.
`../../../bin/fm-spawn.sh --help` owns executable preflight and rejects a missing `prime-agent` before task publication.
`../../../bin/fm-prime-agent-lib.sh` owns detached-worker listing and retirement for task cleanup.

## Scope

Prime Agent is verified for crewmate and scout work.
Secondmate launches remain refused because no primary supervision protocol is verified for Prime Agent.
Primary-session supervision is outside this adapter's verified scope.
Prime Agent's native RPC, RLM, and agent-messaging features are not Firstmate control-plane replacements.
1 change: 1 addition & 0 deletions .agents/skills/quota-array-dispatch/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ An `exhausted_now` runway vetoes the candidate.
The helper selects a candidate only when its applicable quota has a known `effectivePercentRemaining` greater than zero.
This is an optional narrow helper with a known limitation: it maps each harness to one primary provider family only, so a candidate whose established provider differs from that primary family is checked against the wrong quota row.
omp has no primary family, so the helper keys an `omp:` candidate on its model prefix, mapping only `openai-codex/` and `claude-bridge/` and refusing every other prefix; the helper's header owns that mapping.
Prime Agent candidates must use the verified `openai-codex/<id>` prefix; bare, `anthropic/`, and other provider prefixes are refused rather than mapped to an unrelated quota family.
Authoritative multi-provider routing - including provider discovery from the harness catalog and quota matching by that explicit provider - stays owned by this skill's intake procedure above and AGENTS.md section 4, not by the helper.
Use it only when the brief already fixed the candidate order and every candidate's provider is the harness's primary family.
It does not replace the reasoning-class, runway-feasibility, or authentication gates above.
Expand Down
2 changes: 2 additions & 0 deletions bin/fm-busy-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# task's recorded harness classifies unknown, so one adapter's writer can
# never classify another adapter):
# pi-ext Pi/pi-signed per-task extension (agent_start/agent_settled)
# prime-ext Prime Agent per-task extension (agent_start/agent_end)
# omp-ext omp (Oh My Pi) per-task extension (agent_start/agent_end without willContinue)
# opencode-plugin OpenCode per-task plugin (session.status)
# claude-hook Claude lifecycle hooks (UserPromptSubmit/Stop/StopFailure/SessionEnd)
Expand Down Expand Up @@ -199,6 +200,7 @@ fm_busy_sources_for_harness() { # <harness>
opencode*) adapter=opencode-plugin ;;
gemini*) adapter=gemini-hook ;;
pi|pi-signed) adapter=pi-ext ;;
prime-agent) adapter=prime-ext ;;
omp) adapter=omp-ext ;;
kimi*)
fm_busy_kimi_verified || { printf ''; return 0; }
Expand Down
14 changes: 0 additions & 14 deletions bin/fm-harness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,6 @@ detect_own() {
if [ "$strength" = comm ]; then echo "$harness"; else echo "$marker"; fi
}

# True when an exact `omp` process sits within eight parents of this one. The
# same anchored match as the ancestry walk in detect_own, kept separate so the
# marker precedence above can demand real process evidence.
ancestry_names_omp() {
local pid=$$ comm
for _ in 1 2 3 4 5 6 7 8; do
comm=$(ps -o comm= -p "$pid" 2>/dev/null) || return 1
[ "$(basename -- "$comm")" = omp ] && return 0
pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d ' ')
[ -n "$pid" ] && [ "$pid" -gt 1 ] || return 1
done
return 1
}

# Resolve the effective crewmate harness: config/crew-harness (a bare adapter
# name) wins; absent or "default" mirrors firstmate's own harness.
resolve_crew() {
Expand Down
27 changes: 20 additions & 7 deletions bin/fm-quota-choose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@
# claude-bridge/<id> checks the claude row, each against the bare <id> for
# model: and product: scopes. Any other or absent prefix is refused up front,
# the same shape as an unknown harness, because no quota-axi row measures it.
# quota-axi reports Codex quota unavailable on this host because omp carries
# its own Codex login, so an openai-codex candidate reads as unknown quota here
# and is never selected on this host; its runway is disclosed uncertainty for
# the agent-side gates, not measured headroom.
# Prime Agent records the launch provider separately from its model; the
# candidate must preserve that identity here. Only openai-codex/<id> is mapped
# to the codex quota family. Bare, anthropic/, and other provider prefixes are
# refused rather than silently reading an unrelated quota row.
# Live quota-axi data may report Codex quota as unknown when a harness carries
# its own Codex login; an openai-codex candidate then remains eligible only with
# disclosed uncertainty for the agent-side gates, not measured headroom.
set -u

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand Down Expand Up @@ -309,7 +312,8 @@ fi
printf '%s\n' "$QUOTA_JSON" | fm_quota_json_valid || die "invalid quota-axi provider data"

# provider_for_harness <harness> [<model>]
# Map a firstmate harness name to its primary quota-axi provider family.
# Map a firstmate harness name and its provider-qualified model to a quota-axi
# provider family.
# Multi-provider harnesses (Pi, OpenCode) map to their primary family only; see
# the header limitation note. omp is keyed on the candidate model prefix instead
# and has no family for any other prefix (see the header). Authoritative
Expand All @@ -327,7 +331,13 @@ provider_for_harness() {
claude) printf 'claude\n' ;;
codex) printf 'codex\n' ;;
opencode) printf 'codex\n' ;;
pi|pi-signed|prime-agent) printf 'pi\n' ;;
pi|pi-signed) printf 'pi\n' ;;
prime-agent)
case "${2:-}" in
openai-codex/*) printf 'codex\n' ;;
*) return 1 ;;
esac
;;
grok) printf 'grok\n' ;;
kimi) printf 'kimi\n' ;;
cursor) printf 'cursor\n' ;;
Expand Down Expand Up @@ -373,6 +383,7 @@ for c in "${CANDIDATES[@]}"; do
fm_control_harness_supported "$harness" || die "unknown harness: $harness"
provider_for_harness "$harness" "$model" >/dev/null || case "$harness" in
omp) die "omp quota mapping covers only the openai-codex and claude-bridge prefixes: $model" ;;
prime-agent) die "prime-agent quota mapping requires the openai-codex/<model> prefix; bare and non-Codex providers are refused: $model" ;;
*) die "unknown harness: $harness" ;;
esac
done
Expand All @@ -384,7 +395,9 @@ for c in "${CANDIDATES[@]}"; do
[ "$model" = "$c" ] && model="default"
provider=$(provider_for_harness "$harness" "$model")
scope_model=$model
[ "$harness" != omp ] || scope_model=${model#*/}
case "$harness" in
omp|prime-agent) scope_model=${model#*/} ;;
esac
effective=$(effective_for_provider_model "$provider" "$scope_model")
if [ -z "$effective" ] || [ "$effective" = "null" ]; then
continue
Expand Down
Loading
Loading