Skip to content

feat(opencode)!: agent_control — full subagent control on the agent-progress plugin (supersedes #313) - #320

Merged
github-actions[bot] merged 10 commits into
mainfrom
feat/agent-monitor-control-v2
Sep 29, 2026
Merged

github-actions[bot] merged 10 commits into
mainfrom
feat/agent-monitor-control-v2

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

Supersedes #313 (auto-closed at the 5-verdict threshold — a policy bound, not a new finding). Every finding from every BLOCK verdict on #313 is fixed in ONE commit on this fresh branch off current origin/main.

Add full subagent CONTROL to the OpenCode agent-monitor plugin, and land the monitor + control surface + its docs + the skill. Builds on the operator directive in #302 (OpenCode plugins are pure TypeScript — no .sh, no marketplace-pin dependency).

.opencode/plugins/agent-progress.ts registers TWO native V2 tools:

  • agent_progress (MONITOR, read-only) — per session: turns, span, last-activity age, tool mix, the LAST action, artifact hints, and a verdict WORKING / IDLE / LOOP / DONE. A "message" is an ASSISTANT TURN, never a stall signal.
  • agent_control (CONTROL): list / interrupt / delete / wait / confirm_stopped. Mutating actions require an EXPLICIT ses_… id (requireExplicitSession refuses all/blank/non-ses_) and report what they stopped; wait is bounded (DEFAULT_WAIT_TIMEOUT_S). list is read-only.

Pure TypeScript — the ONE execFile drives the opencode CLI (a tool, like gh in coord.ts), never a .sh; no marketplace pin.

Also in the umbrella: scripts/check-agent-progress.mjs (the 3-layer gate), charly.yml (verify runs the gate), .opencode/instructions.md (both tools), AGENTS.md (the dispatcher row). Skill source layer-charly-internals#66; byte-identical dotgithub copy .github#151 (successor #152).

Every finding from #313, fixed in ONE commit

The round-5 head (8c2f010, plus the update-branch merge) fixes the surviving blocks:

  1. B12 — the round-4 recentArtifact → DONE arm shipped untested. Every artifact fixture also had finish="stop", so DONE came from reportStatus regardless. Added the discriminating fixture: stale + a RECENT artifact + no finish=stop ⇒ DONE, built with the REAL store tool-input shape ({command: …}) so the artifact is genuinely extracted. Verified it fails without the arm (2 assertions) and passes with it.
  2. R1 — the DONE definition diverged from classify. .opencode/instructions.md and the agent_progress tool description now document the artifact-completion case ("a final report finish=stop, no pending action, or a landed artifact with the session then quiet"), matching the code.
  3. B6 / B14(b) — the PR's own added verify check had no proof it runs through the wired path. How tested below now pastes the REAL charly task verify run in which the added step executes and PASSES ([pass] check — the agent-progress monitor+control plugin … exit=0). The earlier "cannot load / umbrella charly.yml cannot load: version stamp dropped by 803d411 but the loader requires it #306" framing is dropped — umbrella charly.yml cannot load: version stamp dropped by 803d411 but the loader requires it #306 is CLOSED (the umbrella root charly.yml carries version: 2026.261.1747 on origin/main), and the loader error seen locally was a worktree artifact (the linked worktree's charly/ submodule is empty), not the PR.

Carried from earlier rounds (all still in this tree): R3 — ONE collectAnalyses loop + ONE sortByVerdict + ONE SQL.counts query shared by both branches, CONTROL_SQL.turns deleted; R1 — resolveTarget honours the schema-advertised all; R1 — the artifact display/verdict reconciled (recent artifact ⇒ DONE; older-only ⇒ labelled (none recent — transcript history)); B14(a)/R5 — CONFIRM_WINDOW_S, SQL.lastEvent, and the unused stale local deleted.

How tested

All commands executed on the new head f58a041 (this branch).

The charly task verify path RUNS THE ADDED STEP AND IT PASSES — the load failure seen earlier was the linked worktree's empty charly/ submodule (a worktree artifact), not the PR. Reproduced by giving the task tree a populated charly/ import (ln -s …/charly charly):

$ charly task verify
task verify: 5 step(s), 3 failed
  [fail] check — policy B — every distro-* gitlink equals charly's own box/* gitlink
  [fail] check — every submodule is clean and checked out at its recorded gitlink …
  [fail] check — the opencode gate plugin contract (…)
  [pass] check — the PR-watch plugin's pure logic + its shipped (uncommented) SDK delivery primitives
  [pass] check — the agent-progress monitor+control plugin — static (no .sh), the classifier (RCA regression), and a read-only store
      exit=0

The added step (check-agent-progress.mjs) executes through the wired verify path and returns exit=0. The 3 remaining failures are the scratch tree's absent submodules (FAIL: suspiciously few submodules (0)), not this PR's step — on a full umbrella checkout they are the routine pinning gate.

The gate — Layer A + B, on this head:

$ node scripts/check-agent-progress.mjs | grep -c '^  PASS'
116
$ node scripts/check-agent-progress.mjs | tail -1
check-agent-progress: OK

The round-5 coverage (the discriminating B12 fixture + the R1 docs):

$ node scripts/check-agent-progress.mjs | grep -E 'RECENT artifact|artifact-completion|real store shape'
  PASS  classify fixture: the shell tool input yields a RECENT artifact (real store shape)
  PASS  classify: a stale session with a RECENT artifact and NO final report ⇒ DONE (artifact completion; the display/verdict-reconciling arm) (got "DONE")
  PASS  classify: the artifact-completion DONE names the landed artifact

The fixture was proven to fail without the arm (temporarily commenting it out yields got "IDLE" on both assertions).

The earlier rounds' coverage (shared helper + control dispatch + display reconciliation):

$ node scripts/check-agent-progress.mjs | grep -E 'resolveTarget|resolveLimit|resolveSinceMin|collectAnalyses|sortByVerdict|runControl wait|confirm_stopped:|none recent'
  PASS  resolveTarget: no `session`/`all` ⇒ the whole set (got {"mode":"all"})
  PASS  resolveTarget: `all: true` forces the whole set (overrides `session`) (got {"mode":"all"})
  PASS  resolveTarget: `all: false` without a `session` is refused
  PASS  resolveTarget: a non-ses_ id is refused (never silently scanned)
  PASS  resolveLimit clamps `limit` (cap 50, DEFAULT_LIMIT fallback)
  PASS  resolveSinceMin honours `sinceMin` (DEFAULT_SINCE_MIN fallback)
  PASS  collectAnalyses: the shared loop enumerates the real store (ONE helper for agent_progress + agent_control)
  PASS  collectAnalyses: an aborted signal stops the loop promptly (no sessions analyzed)
  PASS  sortByVerdict: LOOP/WORKING/DONE (loudest first, ONE shared comparator) (got ["LOOP","WORKING","DONE"])
  PASS  runControl wait: calls ctx.session.wait({sessionID})
  PASS  runControl wait: a wait that never resolves is BOUNDED (reports the timeout, never hangs)
  PASS  runControl confirm_stopped: unchanged turns vs the baseline ⇒ STOPPED
  PASS  runControl confirm_stopped: MORE turns than the baseline ⇒ STILL RUNNING
  PASS  formatReport: old artifacts are labelled 'none recent — transcript history' (reconciles with the verdict)

Layer C — the REAL opencode binary (v2.0.19), live-or-skip, on this head:

$ LIVE_OPENCODE=1 AGENT_PROGRESS_LIVE_MODEL=ollama-cloud/deepseek-v4.1-flash node scripts/check-agent-progress.mjs
  PASS  real opencode: the throwaway project has NO marketplace submodule (the lagging-pin state)
  PASS  real opencode: the plugin loaded (no load error)
  PASS  real opencode: no server reload during the call
  PASS  real opencode: the model called the agent_progress tool
  PASS  real opencode: agent_progress returned a verdict line
  PASS  real opencode: the report carries the turn count
  PASS  real opencode: the model called the agent_control tool (action=list, read-only)
  PASS  real opencode: agent_control list returned the session table (or an explicit empty-notice)
check-agent-progress: OK

124 PASS / 0 FAIL with the live layer on this head.

A REAL agent_progress run against the live store — the COMPLETE output of ONE invocation:

$ node -e 'import("./.opencode/plugins/agent-progress.ts").then(m=>m.runProgress({all:true,windowMin:15,limit:3})).then(r=>console.log(r.content))'
agent_progress  window 15m  db /home/atrawog/.local/share/opencode/opencode.db  driver node:sqlite
──────────────────────────────────────────────────────────────────────
ses_f135a8af2ffep17sEo6MxSYua0  "One-time agent progress and control check"
  model ollama-cloud/deepseek-v4.1-flash · idle_outcome=succeeded
  turns 2 · span 1s · last-turn 5s ago · last-event 0s ago
  tools  execute×1
  artifact  opencharly/opencharly#318 · merged · v2026.261.1747 · v2026.271.1115 · 313/.github#151 · pushed · opencharly/layer-charly-internals#66 · v2026.271.1338 (+1)
  VERDICT  WORKING — recent turns (5s < 15m)
ses_f139c2cc3ffey1Cks2nF7NRFmh  "Available tools and plugins"
  agent build · model ollama-cloud/deepseek-v4.1-flash · idle_outcome=succeeded
  turns 106 · span 1h 3m · last-turn 8m ago · last-event 7m ago
  tools  shell×68 read×28 execute×9 webfetch×9 edit×5 skill×4
  artifact  opencharly/opencharly#318
  VERDICT  WORKING — recent turns (8m < 15m); tool cadence (133 calls: shell×68 read×28 execute×9 webfetch×9)
ses_f136ea8efffei2VWjYG1JYdkNB  ⤷subagent "Land #717 convergence wave (7 legs)"
  agent general · model ollama-cloud/deepseek-v4.1-flash
  turns 70 · span 21m · last-turn 22s ago · last-event 22s ago
  tools  shell×76 read×7 edit×4 skill×3 write×2 execute×2
  artifact  merged
  VERDICT  WORKING — recent turns (22s < 15m); tool cadence (94 calls: shell×76 read×7 edit×4 skill×3)

A REAL agent_control list run — the COMPLETE output of ONE invocation (the FIRST line is the table header, formatControlList's non-empty branch — there is no agent_control list banner for a populated result; the sole agent_control list literal is the empty-case message):

$ node -e 'import("./.opencode/plugins/agent-progress.ts").then(m=>m.runControl({action:"list",sinceMin:240,limit:3},{})).then(r=>console.log(r.content))'
id                          age        verdict  agent      title
ses_f135a8af2ffep17sEo6MxSYua0 0s         WORKING             One-time agent progress and control che…
ses_f139c2cc3ffey1Cks2nF7NRFmh 7m         WORKING  build      Available tools and plugins
ses_f136ea8efffei2VWjYG1JYdkNB 22s        WORKING  general    Land #717 convergence wave (7 legs)

R3/R5 dead-code self-test: grep -c 'SQL.lastEvent\|const stale ' → 0; the only COUNT(*) AS turns … MAX(time_created) occurrence is SQL.counts itself.

The sibling opencode gates still PASS on this head:

$ node scripts/check-pr-watch.mjs          → check-pr-watch: OK
$ node scripts/check-opencode-plugin.mjs   → check-opencode-plugin: OK
$ node scripts/check-opencode-coord.mjs    → check-opencode-coord: OK

Rulebook compliance

  • R0 — skills loaded before any edit: git-workflow, plugin, agents, skills, marketplace, strict-policy.
  • R1 — RCA + zero warnings: the loader error was RCA'd to a worktree artifact (empty charly/ submodule) — not the PR; umbrella charly.yml cannot load: version stamp dropped by 803d411 but the loader requires it #306 is CLOSED and the stamp is on main. The DONE docs now match classify; the artifact display/verdict contradiction is fixed.
  • R2 — no deferral/split: monitor, control, gate, docs, skill land together; the carried-auto-close successor is this PR.
  • R3 — no duplication: ONE collectAnalyses + ONE sortByVerdict + ONE SQL.counts, shared by both branches; CONTROL_SQL.turns deleted.
  • R4 — named constants, bounded: CONTROL_ACTIONS, DEFAULT_WAIT_TIMEOUT_S, DEFAULT_LIMIT, DEFAULT_SINCE_MIN, VERDICT_RANK, SQL, CONTROL_SQL; wait bounded.
  • R5 — legacy/dead code deleted: CONFIRM_WINDOW_S, SQL.lastEvent, the unused stale local are gone.
  • R6 — git safety: PR-only; no force-push; no hook bypass.
  • R7 — prove the gate: the charly task verify run pastes the added step executing exit=0; the unit + live gates are pasted. The full pinning gate did not pass in the scratch task tree (it lacked the submodules the three pinning steps require) — reported, not claimed as green.
  • R8 — generated-artifact invariants: no generated artifact hand-edited.
  • R9 — live-or-skip, never fake: the unit layer runs a REAL read-only store + a REAL /bin/false; the live layer drives the REAL binary.
  • R10 — fresh proof from the final tree: all output is from the committed head f58a041.
  • Rule 9 / auto-close carry-forward: feat(opencode)!: agent_control — full subagent control on the agent-progress plugin #313 is cross-referenced RESOLVED — superseded by this PR; the four surfaces are updated.

Change classification

  • Change class: opencode harness config (.opencode/*, scripts/check-*.mjs, charly.yml, AGENTS.md) — code/config, not docs-only.
  • Verification gate: charly task verify (the added step executes exit=0) + scripts/check-agent-progress.mjs (A/B/C — 116 unit, 124 live, on this head) + the sibling opencode gates.
  • Attribution tier: analysed on a live system — the changed runtime path (agent_progress + agent_control list) ran live against the real opencode binary and the real store, with retained output; the repository's charly task verify executed the added step exit=0, but the FULL gate did not pass (the scratch task tree lacked the submodules its three pinning steps need), so the "fully tested and validated" tier is not claimed.

Relates to #302 (the pure-TypeScript architecture directive). Skill source opencharly/layer-charly-internals#66 (projection consumer leg opencharly/marketplace#380); byte-identical dotgithub copy opencharly/.github#152.

Agent: agent-monitor-control · session ses_f13e97f62ffebD0x2sHlT4KW19
Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)

…rogress plugin (#302 architecture)

Add a second native tool, agent_control, to .opencode/plugins/agent-progress.ts:
list / interrupt / delete / wait / confirm_stopped. interrupt stops a RUNNING
session without deleting it (ctx.session.interrupt); delete drives
`opencode session delete` (session + child sessions); wait is a BOUNDED
ctx.session.wait; confirm_stopped re-reads the transcript and ASSERTS no new
turns (the CONFIRM-it-stopped rule). interrupt/delete/wait REQUIRE an explicit
session id (never `all`) and report what was stopped, so a session another slug
owns is never silently killed.

Pure TypeScript: the control half's ONE execFile drives the opencode CLI (a
tool, like `gh` in coord.ts), never a .sh — no marketplace pin.

Also: the gate gains static + unit control coverage (closed action set, the
explicit-session rail, a real read-only SQLite fixture, refusals) and the live
layer now calls BOTH agent_progress and agent_control list (read-only — the test
never interrupts/deletes a real session); charly.yml runs the gate in verify;
instructions.md documents both tools; AGENTS.md gains the dispatcher row.
The live snippet now normalizes the tool return (a plain content string in Code
Mode, or { content }) so the model-call assertions read the real report.
…ew round 1)

- Delete CONFIRM_WINDOW_S (zero references; its comment described a window the
  confirmStopped implementation does not have — an R1 comment/code divergence).
- KNOWN_TOOLS was zero-reference: wire it via unknownTools(), which the report now
  uses to surface any tool outside the known set ('tools+' line); the gate asserts it.
- Move the delete children query into CONTROL_SQL (named SQL, R4).
…ete dead code (review round 2)

R3 — extract ONE shared helper `collectAnalyses(db, {now, windowMin, sinceMin, limit, signal})`
plus `VERDICT_RANK`/`sortByVerdict`/`resolveLimit`/`resolveSinceMin` and route BOTH
`agent_progress` (all) and `agent_control` (list) through them; drop the duplicated
`CONTROL_SQL.turns` and reuse `SQL.counts` in `turnStats` (ONE counts query).

R1 — honour the schema-advertised `all` input via `resolveTarget` (`all:true` forces the
whole set; `all:false` REQUIRES an explicit `session`).

B14(a)/R5 — delete the zero-caller `SQL.lastEvent` and the unused `stale` local in
`classify()`.

R10 check-coverage — the gate now asserts resolveTarget honours `all`, the limit/sinceMin
clamps, collectAnalyses enumerates the real store and stops on abort, and sortByVerdict
orders loudest-first.
…verging comments, gate `wait`+`confirm_stopped` (review round 4)

R1 — the report printed `artifact merged · gh pr merge …` while the verdict said
`no artifact` (the display used `a.artifacts`, the verdict `a.recentArtifacts`). A RECENT
artifact in a stale session is now COMPLETION evidence → DONE ("landed an artifact … then
quiet"), and when only OLDER artifacts exist the display labels them
"(none recent — transcript history)" — display and verdict can no longer contradict.

R1 — the `reportStatus` doc-comment claimed BOTH classifier and report call it; only
`classify` does. Comment corrected to match the code.

R1 — the analyzeSession artifacts fallback comment claimed a short-session rationale; the
fallback is unconditional (and it is LONG/truncated tails that hit it). Comment corrected.

B12 — Layer B now drives `runControl({action:"wait"})` through a stubbed ctx.session.wait
for BOTH the idle and the bounded-timeout result (and the missing-primitive refusal), plus
the `confirm_stopped` ACTION (STOPPED and STILL RUNNING vs the baseline) — a path with no
test fails to exist. Gate: 113 unit / 121 live, 0 FAIL.
…ove the verify step runs (review round 5)

B12 — the round-4 `recentArtifact → DONE` arm shipped untested (every artifact fixture also
had finish=stop, so DONE came from reportStatus regardless). Added the discriminating
fixture: stale + RECENT artifact + NO finish=stop ⇒ DONE, using the REAL store tool-input
shape so the artifact is truly extracted. Verified it FAILS without the arm (2 assertions).

R1 — the DONE definition in .opencode/instructions.md and the agent_progress tool
description now documents the artifact-completion case (a landed artifact with the session
then quiet), matching classify.

R10/B6 — the added verify step is proven through the charly task verify path it is wired
into: `[pass] check — the agent-progress monitor+control plugin … exit=0`.

Gate: 116 unit / 124 live, 0 FAIL.
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: f58a041025052b3b91fc3ee9e7667da7ed1f9e45 (branch: feat/agent-monitor-control-v2)

Security screen: PASS — no secrets/egress/eval; the one execFile drives the local opencode CLI; the added charly.yml step strengthens (not weakens) the verify set; the AGENTS.md edit only adds a Skill-Dispatcher row (no landing/attribution/no-force-push rule touched, so no T4 sign-off is required).

Checklist: All applicable rules PASS or NA. Body is complete and internally consistent (summary accounts for all 5 files; honest analysed on a live system tier, not inflated); the gate's assertions reconcile with the plugin (classifier RCA-regression, control dispatch, read-only store, resolveTarget/collectAnalyses/sortByVerdict R3 consolidation, artifact-display/verdict reconciliation); the pasted charly task verify failures are pinning steps of the scratch worktree (a CI gate — ground rule 5), with the PR's own added step shown executing exit=0 through the wired path. Comment thread is empty — nothing to disposition.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 29, 2026 10:17
@github-actions
github-actions Bot merged commit 3637e65 into main Sep 29, 2026
1 check passed
github-actions Bot pushed a commit to opencharly/.github that referenced this pull request Sep 29, 2026
…e-identical to opencharly/opencharly#320) (#153)

* feat(opencode)!: agent monitor + control plugin (agent_progress + agent_control)

Byte-identical to opencharly/opencharly: .opencode/plugins/agent-progress.ts
(agent_progress monitor + agent_control control), scripts/check-agent-progress.mjs
(A static / B unit incl. the RCA regression / C live), and the instructions.md
section documenting both tools. Pure TypeScript — no .sh, no marketplace pin.

* fix(opencode): remove dead control constants + wire KNOWN_TOOLS (review round 1)

Byte-identical to opencharly/opencharly: delete CONFIRM_WINDOW_S (zero refs),
wire KNOWN_TOOLS via unknownTools(), move the delete children query into CONTROL_SQL.

* fix(opencode): one shared collector + counts query, honour `all`, delete dead code (review round 2)

Byte-identical to opencharly/opencharly#313: R3 (ONE collectAnalyses + ONE
SQL.counts, no CONTROL_SQL.turns), R1 (`all` honoured via resolveTarget), and the
dead-code removal (SQL.lastEvent, the unused `stale` local). Gate coverage added.

* fix(opencode): reconcile the artifact display/verdict, correct two diverging comments, gate `wait`+`confirm_stopped` (review round 4)

Byte-identical to opencharly/opencharly#313: R1 (display/verdict artifact reconciliation +
two corrected doc comments) and B12 (Layer B drives the `wait` and `confirm_stopped`
control paths). Gate: 113 unit / 121 live, 0 FAIL.

* fix(opencode): pin the artifact-completion DONE arm + document it; prove the verify step runs (review round 5)

Byte-identical to opencharly/opencharly (successor to #313): B12 (the artifact-completion
DONE arm is now pinned by a discriminating fixture), R1 (the DONE definition documents the
artifact-completion case), and the charly task verify path proof. Gate: 116 unit / 124 live.

---------

Co-authored-by: Andreas Trawoeger <[email protected]>
charly-auto-merge Bot added a commit that referenced this pull request Sep 29, 2026
@aitrawog
aitrawog deleted the feat/agent-monitor-control-v2 branch November 1, 2026 19:06
github-actions Bot pushed a commit that referenced this pull request Nov 14, 2026
* chore(pins)!: advance the unit-8 pins and re-anchor the census

The umbrella pin wave for opencharly/spec#304 unit 8 (#1024).

Eight pins move: charly (the fleet), the three distros (their own waves), plugin-check
(#149), plugin-substrate (#42/#43/#44/#45/#46/#47), sdk (#514) and spec (#320/#321).

The census follows the body: three dulling rows re-anchor to the plugin module, with the
three KEEPER citations (#VmBackend, #VmBackendName, #VmKrun) correctly staying in spec -
a blanket rewrite moved them and the control caught it. The D-PAT census lowers the twin
row and records the plugin union: the six D-PAT-2 dup findings the deletion created are
gone because plugin-substrate#47 removed the duplicate defs.

TODO.md row 2.1 reads Units 1-8 of 11 with the unit nine legs, its counts (KindValueDefs
3 -> 2, five bodies remain) and its three lessons; the ledger carries the P01 row (3 units
left) and the §9 record.

Measured on the served tree: the assembled graph builds clean, the corpus sweep moved zero
verdict classes, currency 8 of 409 -> 3 of 409, the design controls and the 48-step pin
gate green.

Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

* docs: the four gitlinks and where the other four went (review round)

* docs(ledger): the P01 state column names unit 8 (review round)

* docs: the rollback sentence says four (review round)

---------

Co-authored-by: aitrawog <[email protected]>
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