Skip to content

feat(opencode)!: agent monitor + control plugin (supersedes #151; byte-identical to opencharly/opencharly#320) - #153

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

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

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

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

The dotgithub copy of the OpenCode subagent monitor + control plugin — byte-identical to opencharly/opencharly#320 (which supersedes #313). It lands here because .github is the org-wide home for the opencode harness config every session in this clone loads.

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

  • agent_progress (MONITOR, read-only) — 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. list is read-only.

Pure TypeScript — the ONE execFile drives the opencode CLI, never a .sh; no marketplace pin. scripts/check-agent-progress.mjs is the 3-layer gate (static / unit against a real read-only SQLite fixture / live against the real opencode binary).

Byte-identity: this head's .opencode/plugins/agent-progress.ts, scripts/check-agent-progress.mjs, and .opencode/instructions.md are diff-identical to opencharly/opencharly#320's head.

Every finding from #151, fixed in ONE commit

The round-5 head (7e270ed) fixes the surviving blocks:

  1. A1 / R10 — the pasted agent_control list output could not be produced by the committed code. The prior body prefixed the table with an agent_control list header line that formatControlList never emits for a non-empty result (its FIRST line is id … age … verdict …). How tested below now pastes the REAL complete output: the header is the table row, and the sole agent_control list literal is the empty-case message.
  2. 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: …}). Verified it fails without the arm (2 assertions).
  3. R1 — the DONE definition diverged from classify. .opencode/instructions.md and the tool description now document the artifact-completion case ("a final report … or a landed artifact with the session then quiet"), matching the code.
  4. A1 — body ends with the Assisted-by: footer (this is the body's final line).

Carried from earlier rounds: R3 (ONE collectAnalyses + sortByVerdict + SQL.counts shared by both branches; CONTROL_SQL.turns deleted), R1 (resolveTarget honours all; the artifact display/verdict reconciled), B14(a)/R5 (SQL.lastEvent, the unused stale local deleted).

How tested

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

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

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.

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

$ 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

Proven to fail without the arm (commenting it out yields got "IDLE").

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; there is no agent_control list banner for a populated result):

$ 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)

Byte-identity with opencharly/opencharly#320 (the shared files), verified at the final heads:

$ diff .opencode/plugins/agent-progress.ts <(#320 head's copy)   → identical
$ diff scripts/check-agent-progress.mjs  <(#320 head's copy)   → identical
$ diff .opencode/instructions.md         <(#320 head's copy)   → identical

R5 dead-code self-test: grep -c 'SQL.lastEvent\|const stale ' → 0.

Rulebook compliance

  • R0 — skills loaded before any edit: git-workflow, plugin, agents, skills.
  • R1 — RCA + zero warnings: the two diverging doc-comments are corrected; the artifact display/verdict contradiction is FIXED; the DONE docs match classify.
  • R2 — no deferral: the plugin, the gate, and the docs land together; this is the auto-close successor.
  • R3 — no duplication: ONE collectAnalyses + ONE sortByVerdict + ONE SQL.counts; CONTROL_SQL.turns deleted.
  • R4 — named constants, bounded: CONTROL_ACTIONS, DEFAULT_WAIT_TIMEOUT_S, DEFAULT_LIMIT, DEFAULT_SINCE_MIN, VERDICT_RANK, SQL, CONTROL_SQL.
  • 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 pasted output is the EXECUTED gate on this head.
  • 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 7e270ed.
  • Auto-close carry-forward: feat(opencode)!: agent monitor + control plugin (byte-identical to opencharly/opencharly#313) #151 is cross-referenced RESOLVED — superseded by this PR; ownership is transferred on the thread.

Change classification

  • Change class: opencode harness config (.opencode/*, scripts/check-*.mjs) — not docs-only.
  • Verification gate: scripts/check-agent-progress.mjs (A/B/C — 116 unit, 124 live, on this head).
  • 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; there is no charly project in this repo, so no charly task verify gate exists to run.

Byte-identical to opencharly/opencharly#320 (supersedes #313); the skill source is opencharly/layer-charly-internals#66.

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

atrawog and others added 7 commits September 29, 2026 10:14
…nt_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.
…ew 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.
…ete 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.
…verging 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.
…ove 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.
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

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

Security screen: PASS — no injected instructions (T2), no secrets/egress/obfuscation, no new deps, no gate/rulebook weakening, no scope mismatch (the diff registers exactly the two tools the body names).
Checklist: All applicable rules PASS or NA. Change class = opencode harness config (not docs-only); gate scripts/check-agent-progress.mjs is pasted on the current head and is internally consistent (A+B = 116; +8 live = 124; the artifact-completion and wait-timeout arms are discriminating, and the 12 static + unit assertions reconcile with the diff). R3/R5 removals (CONTROL_SQL.turns, SQL.lastEvent, CONFIRM_WINDOW_S, const stale) are confirmed absent from the diff, so the grep self-test claim is true regardless of re-run. R10/ADE/SDD/CUE/bed matrix are NA (no charly, candy, CUE/proto, or generated artifacts in this repo). Cross-repo byte-identity with opencharly/opencharly#320 is unverifiable read-only (tool-limited, non-blocking). 0 comments to disposition.

Verdict: PASS


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

View action run

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.

2 participants