Skip to content

Opencode agent/skill surgery - #7095

Open
jasnell wants to merge 4 commits into
mainfrom
jasnell/agent-surgery
Open

Opencode agent/skill surgery#7095
jasnell wants to merge 4 commits into
mainfrom
jasnell/agent-surgery

Conversation

@jasnell

@jasnell jasnell commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Cleaning up refining opencode skills, agents, and tools

The prompt had grown into a reference manual loaded on every turn: 22,385
characters, of which the skill-loading rules appeared four separate times
and "Core Analysis Areas" restated guidance already delivered by the
checklists it tells the agent to load. Sampling ten topics from the coding
patterns section, nine were already covered by kj-style.md or its mandatory
detail/review-checklist.md.

Cut to 11,114 characters with no loss of routing information:

- Collapse the four copies of the skill-loading rules into one list.
- Replace Core Analysis Areas with the workerd-specific rules the loaded
  checklists do not cover, dropping the generic and self-duplicating
  bullets.
- Convert the mode descriptions from paragraphs to one line each. Only one
  mode is ever active, but all eleven are in every request.
- Point at the reference docs directly rather than at the skills that
  wrap them, saving a hop for identical content. The wrappers stay, since
  they are how other agents discover the docs by description.
- Use lists rather than markdown tables, which prettier pads out.

Rewrite the context-gathering section around the in-repo tools, which were
mostly unmentioned: cross-reference and bazel-deps were named, while
jsg-interface, compat-date-at, ci-report and next-capnp-ordinal were not.
Everything it points at ships in this repository, so the guidance holds for
every developer rather than depending on local MCP configuration.

Two permission fixes:

- 'gh api *' was 'ask' while the review workflow requires gh api to fetch
  prior review comments, so every PR review stalled on a prompt. Read-only
  pulls endpoints are now allowed; everything else still asks.
- Deny cat, head, tail, find and ls. The agent is told to use the Read and
  Glob tools, which number lines and bound their output; allowing the shell
  equivalents only invited unbounded reads into a context window whose
  occupancy directly limits review quality.
A balanced review was a single linear pass: load five checklists, read the
diff, read the dependencies, write findings. Two things go wrong. Attention
is split across five orthogonal checklists at once, which covers each of
them less thoroughly than a focused pass would. And by the time findings
are written the checklists are tens of thousands of tokens back, in a
context now full of source code.

Add three read-only subagents, each loading exactly one checklist:

  review-safety  memory safety, thread safety, lifetimes, V8/GC
  review-api     performance, API design, compatibility, security, standards
  review-style   KJ/C++, Rust or TypeScript conventions, by file type

The architect launches them in parallel and becomes the synthesiser:
merging findings, dropping cross-axis duplicates, and surfacing genuine
conflicts between axes rather than silently picking a side. That last part
is what the existing conflicting-recommendations rule always described but
could not do, having only one reviewer to arbitrate between.

Each subagent fetches the diff itself from a command the architect passes,
so the diff is not re-emitted into three task prompts. Each returns
findings in the shared format and nothing else, capped at fifteen, plus a
"Cleared:" line so the architect can tell a clean axis from an unexamined
one. They cannot edit, and cannot spawn further subagents.

The fan-out is skipped where it cannot pay for itself: quick reviews,
single-axis modes where the architect would only relay one reviewer's
output, and changes small enough to read directly.

Primary-context instruction load for a balanced C++ PR review drops from
~58,500 to ~21,300 characters, since the checklists now load inside the
subagents. Total tokens billed goes up: this trades cost for review depth
and for headroom in the context that writes the final report. The
subagents inherit the default model; pin a cheaper one in their frontmatter
if that trade stops being worth it.
@jasnell
jasnell requested review from a team as code owners August 22, 2026 01:03
Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/architect.md Outdated
@ask-bonk

This comment was marked as resolved.

@jasnell
jasnell force-pushed the jasnell/agent-surgery branch from 4fc2ce5 to bb13bbc Compare August 22, 2026 01:34
@jasnell

This comment was marked as resolved.

Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/code-review.md
@ask-bonk

This comment was marked as resolved.

@jasnell
jasnell force-pushed the jasnell/agent-surgery branch from bb13bbc to b136d62 Compare August 22, 2026 01:50
@jasnell

jasnell commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

/bonk review again

Comment thread .opencode/agent/code-review.md
Comment thread .opencode/agent/review-api.md
Comment thread .opencode/agent/review-safety.md Outdated
Comment thread docs/reference/api-review-checklist.md
Comment thread docs/reference/api-review-checklist.md
@ask-bonk

ask-bonk Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Posted 5 actionable inline findings. git diff --check passed.

Time for a pun! Those reviewer permissions need to stop redirecting the conversation.

github run

@jasnell
jasnell force-pushed the jasnell/agent-surgery branch from b136d62 to 1d1e0da Compare August 22, 2026 02:21
@jasnell

jasnell commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

/bonk check again

Comment thread .opencode/agent/code-review.md Outdated
@ask-bonk

ask-bonk Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding. git diff --check passed.

Here's a joke for you: Why did the token avoid git remote -v? It didn’t want to be exposed.

github run

@jasnell
jasnell force-pushed the jasnell/agent-surgery branch from 1d1e0da to 104ffda Compare August 22, 2026 02:25
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