Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e059c002c |
No files matched your search
@@ -0,0 +1,183 @@
|
||||
# Enforcement hooks: what apm can ship, and portable alternatives
|
||||
|
||||
Research for holocron issue #168 (map #166, "Infra and agent-team packages"). Captured 2026-11-12.
|
||||
|
||||
**Question.** Can the infra package *enforce*, not just instruct, the map's safety stance? The stance
|
||||
blocks `kubectl apply/delete`, `helm upgrade`, unchecked `ansible-playbook`, `tofu apply`, vault
|
||||
decryption, and reads of vault password files unless a human has approved. If it can, through what
|
||||
mechanism?
|
||||
|
||||
**Short answer.** Partly. apm can ship one `PreToolUse`-style hook that reaches Claude Code,
|
||||
Copilot (CLI and cloud agent), Codex and Gemini CLI, and each of those can deny a shell command
|
||||
after inspecting its text. Only Claude Code and Copilot CLI can turn the block into an *ask*, which
|
||||
is a real human approval. Every provider documents its hooks as best-effort guardrails rather than a
|
||||
security boundary. Hooks see only the command text, so `sh -c`, a script the agent writes and then
|
||||
runs, or a Python subprocess gets past them. Real enforcement has to come from credentials the agent
|
||||
does not hold: a read-only kubeconfig, no apply credentials for tofu, an unreadable vault password
|
||||
file and branch protection. Use the hook as the fast, explainable first layer, not the boundary.
|
||||
|
||||
Sources were the installed apm 0.28.0 source (`apm_cli/`, read from the pipx venv), the apm docs,
|
||||
and each provider's official docs. Context7 was unavailable in this session (invalid API key), so
|
||||
every citation below is a primary source fetched directly.
|
||||
|
||||
---
|
||||
|
||||
## 1. What apm ships as a hook, and where it lands
|
||||
|
||||
**Authoring.** Hook files are JSON keyed by lifecycle event, in `.apm/hooks/` or a root `hooks/`.
|
||||
apm accepts the Claude shape (`PreToolUse`, nested `matcher` and `hooks`) and the Copilot shape
|
||||
(`preToolUse`, flat entries with `bash`/`powershell`/`timeoutSec`). `${PLUGIN_ROOT}` and
|
||||
`${CLAUDE_PLUGIN_ROOT}` resolve to the package root and are rewritten per target
|
||||
([apm: Hooks and commands](https://microsoft.github.io/apm/producer/author-primitives/hooks-and-commands/);
|
||||
`apm_cli/integration/hook_integrator.py` module docstring). kyberforge's `SessionStart` hook
|
||||
(`plugins/kyberforge/.apm/hooks/hooks.json`) is exactly this. apm merges it into
|
||||
`.claude/settings.json` with the command rewritten to
|
||||
`${CLAUDE_PROJECT_DIR}/.claude/hooks/kyberforge/.apm/hooks/check-apm-current.sh` (ADR-0019, and the
|
||||
deployed `.claude/settings.json`).
|
||||
|
||||
**Deployment per target** (apm docs table, confirmed against `_MERGE_HOOK_TARGETS` and
|
||||
`integration/targets.py`):
|
||||
|
||||
| Target | Deployed to | Mode | Notes from source (apm 0.28.0) |
|
||||
|---|---|---|---|
|
||||
| claude | `.claude/settings.json` | merged | Reshaped to the nested matcher schema, default matcher `*` (`_to_claude_hook_entries`). |
|
||||
| copilot | `.github/hooks/<pkg>-<name>.json` | one file per hook | Events renamed to camelCase, `version: 1` added (`hook_integrator.py` ~L1087). |
|
||||
| codex | `.codex/hooks.json` | merged | `require_dir=True`: skipped unless `.codex/` already exists. No event rename and no reshape (Codex uses Claude's names and shape). |
|
||||
| gemini | `.gemini/settings.json` | merged | `require_dir=True`. `PreToolUse` becomes `BeforeTool` and timeouts become milliseconds (`_to_gemini_hook_entries`). |
|
||||
| cursor | `.cursor/hooks.json` | merged | `require_dir=True`, `version: 1` added. **No entry in `_HOOK_EVENT_MAP` and no shape transform** (see section 4). |
|
||||
| opencode | none | skipped | "OpenCode has no hooks concept" (`targets.py`). |
|
||||
|
||||
**Executable-trust gate.** Hooks are an executable primitive. When the consuming `apm.yml` has an
|
||||
`executables:` block, a hook deploys only if the consumer approves it (`apm approve`). Without the
|
||||
block, every executable deploys silently (`apm_cli/security/executables.py` docstring; ADR-0019).
|
||||
That gate works in the safety stance's favour: a consumer can see, and has to approve, the guard
|
||||
hook.
|
||||
|
||||
**What apm does *not* ship:**
|
||||
|
||||
- Permission rules, sandbox settings, or any `settings.json` key other than `hooks`. No source path
|
||||
writes `permissions` or `sandbox`. A repo-authored key in `.claude/settings.json` is permanent
|
||||
`apm audit --ci` drift (ADR-0018, AGENTS.md).
|
||||
- Tool-name translation in matchers. A `"matcher": "Bash"` is written verbatim to every target, but
|
||||
the shell tool is `Bash` in Claude and Codex, `Shell` in Cursor
|
||||
([Cursor hooks](https://cursor.com/docs/agent/hooks)), and `run_shell_command` in Gemini
|
||||
([Gemini hooks reference](https://geminicli.com/docs/hooks/reference/)). Copilot's flat format
|
||||
has no matcher at all.
|
||||
- `bin/` on `PATH`. A package's `bin/` deploys at **user scope only**, for the Claude target only,
|
||||
into the skill directory's `bin/` (`skill_integrator.py` ~L1571–1670, "bin/ deploy is user-scope
|
||||
only"). It is not a channel for portable wrapper scripts.
|
||||
|
||||
## 2. Can a pre-tool hook inspect arguments and deny or ask? Per target
|
||||
|
||||
| Provider | Event | Sees the command? | Deny | Ask (human approval) | Failure mode |
|
||||
|---|---|---|---|---|---|
|
||||
| **Claude Code** | `PreToolUse` | `tool_input.command` | exit 2 (stderr is the reason) or `permissionDecision: "deny"` | **Yes**, `permissionDecision: "ask"` | Fails open on error or timeout unless `"onFailure": "block"`. Runs in subagents too. |
|
||||
| **Copilot CLI / cloud agent** | `preToolUse` (`PreToolUse` alias) | `toolArgs` (camelCase) or `tool_input` (PascalCase) | `permissionDecision: "deny"` | **CLI yes. Cloud agent treats `ask` as `deny`.** | Crashes and non-zero exits **fail closed**; timeouts fail open. |
|
||||
| **Copilot in VS Code** | `preToolUse` | `toolArgs` | `deny` | Documented only loosely | Preview. Also reads the repo's `.claude/settings.json` hooks. |
|
||||
| **Codex** | `PreToolUse` (covers shell and unified exec as `Bash`, plus `apply_patch` and MCP) | `tool_input.command` | exit 2 or `permissionDecision: "deny"` | **No**: `ask` is "parsed but not supported yet" and the tool call **continues** | Errors and timeouts can let the tool run. Project hooks are skipped until a human trusts them (hash-pinned). |
|
||||
| **Gemini CLI** | `BeforeTool` | `tool_input` (raw tool args) | exit 2 or `decision: "deny"`/`"block"` | Not documented | Other exit codes are non-fatal and the call continues. Project hooks are fingerprinted, with a warning on change. |
|
||||
| **Cursor** | `beforeShellExecution` / `preToolUse` | `command` / `tool_input.command` | exit 2 or `permission: "deny"` | `beforeShellExecution` yes. `preToolUse` accepts `ask` in its schema but does not enforce it. | Fails open by default; `failClosed: true` per hook. |
|
||||
| **OpenCode** | none | n/a | n/a | n/a | No hooks. |
|
||||
|
||||
Sources: [Claude Code hooks](https://code.claude.com/docs/en/hooks),
|
||||
[Copilot hooks reference](https://docs.github.com/en/copilot/reference/hooks-configuration),
|
||||
[VS Code agent hooks](https://code.visualstudio.com/docs/copilot/customization/hooks),
|
||||
[Codex hooks](https://learn.chatgpt.com/docs/hooks) (redirected from developers.openai.com),
|
||||
[Gemini CLI hooks](https://geminicli.com/docs/hooks/) and its
|
||||
[reference](https://geminicli.com/docs/hooks/reference/),
|
||||
[Cursor hooks](https://cursor.com/docs/agent/hooks).
|
||||
|
||||
**Every vendor says hooks are not a boundary.** Codex: "Treat tool hooks as a useful guardrail, not
|
||||
a complete enforcement boundary". Claude's `if` field docs: "use the permission system rather than a
|
||||
hook to enforce a hard allow or deny". Claude permissions: a Bash rule "isn't a security boundary
|
||||
around the program", and the docs point to the sandbox for enforcement that doesn't depend on the
|
||||
command text ([Claude permissions](https://code.claude.com/docs/en/permissions)).
|
||||
|
||||
**Exit code 2 plus a stderr reason is the lowest common denominator for deny.** Claude, Codex,
|
||||
Gemini and Cursor document it, and Copilot fails closed on any non-zero exit. A single script can
|
||||
therefore deny portably. Only *ask* differs per provider.
|
||||
|
||||
## 3. Portable alternatives where hooks don't reach
|
||||
|
||||
| Layer | Mechanism | Strength | apm-shippable? |
|
||||
|---|---|---|---|
|
||||
| Host permission rules | Claude `permissions.deny`/`ask` (`Bash(kubectl apply *)`, `Read(**/.vault_pass*)`). Deny, then ask, then allow; a hook `allow` cannot override a deny or ask rule. Compound commands and subshells are split. | Matches the text Claude writes. It "doesn't match the same program invoked in a different form" (path, `sh -c`). | **No.** Settings keys are not an apm primitive and would be drift in `.claude/settings.json`. Use managed settings, user settings or `settings.local.json`. |
|
||||
| Claude sandbox | `sandbox.filesystem.denyRead` on the vault password file, `allowUnsandboxedCommands: false`, `failIfUnavailable: true`. OS-level (bubblewrap/Seatbelt) and covers child processes. | Strong for file reads, whatever the command text. Command hooks and MCP servers run outside it. | No (settings). Claude only. |
|
||||
| Wrapper scripts on PATH | `kubectl`/`helm`/`tofu` shims that refuse mutating verbs. | Weak: bypassed by an absolute path, `command -p` or a different PATH. Breaks humans who share the PATH. | No portable channel (apm `bin/` is user-scope, Claude-only, not on PATH). **Not recommended.** |
|
||||
| pre-commit / pre-push | e.g. reject a committed file that should be vault-encrypted but lacks the `$ANSIBLE_VAULT` header. | Catches mistakes at commit time. Client-side and skippable with `--no-verify`. Cannot stop a runtime apply. | Out of scope for apm (`.pre-commit-config.yaml` in the infra repo). |
|
||||
| Kubernetes RBAC | Agent kubeconfig bound to the built-in `view` ClusterRole. "This role does not allow viewing Secrets, since reading the contents of Secrets enables access to ServiceAccount credentials" ([k8s RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/)). | **Boundary.** `kubectl apply/delete` and `helm upgrade` fail server-side, whatever the shell form. It also keeps the Sealed Secrets controller key out of reach. `kubectl diff` needs server-side dry-run, which may need more than `view` (not verified here). | No: infra and credential setup. |
|
||||
| Separate apply credentials | tofu: the agent gets plan-only or read-only provider and state credentials, and apply runs with credentials held by the human or CI. Ansible: no vault password and no privileged SSH key in the agent's environment. | **Boundary.** | No: infra and credential setup. |
|
||||
| Forge branch protection | The Flux-watched branch accepts only reviewed merges, and the agent's Gitea token cannot push or merge to it. | **Boundary** for the GitOps path. | No: Gitea settings. |
|
||||
|
||||
## 4. Gaps named per provider
|
||||
|
||||
- **Claude Code: best covered.** The hook deploys and is honoured, with argument-level deny and real
|
||||
`ask`. Gaps: the hook fails open on error unless `onFailure: block` is set. A user's
|
||||
`disableAllHooks` turns off project hooks, and only `allowManagedHooksOnly` with managed hooks
|
||||
prevents that. The permission rules and sandbox that would harden it are not apm-deliverable.
|
||||
- **Copilot CLI: well covered.** Deny and ask both work, and errors fail closed. On the **cloud
|
||||
agent** `ask` becomes `deny`, so HITL commands are simply blocked there, which is the correct
|
||||
outcome. **VS Code** reads both `.github/hooks/` and `.claude/settings.json`. A package installed
|
||||
for both `copilot` and `claude` targets therefore runs the guard twice in VS Code. That is
|
||||
harmless for a deny-only idempotent script, but noisy.
|
||||
- **Codex: deny only.** `ask` silently degrades to *allow* (the run is marked failed and the tool
|
||||
call continues). The script must therefore emit `deny` for HITL commands on Codex, never `ask`.
|
||||
apm skips the hook entirely unless `.codex/` exists, and Codex skips it until a human trusts it.
|
||||
A fresh install is unguarded until someone runs `/hooks` to review it.
|
||||
- **Gemini CLI: deny only, and the matcher does not translate.** A `Bash` matcher never fires on
|
||||
`run_shell_command`, so ship the hook with no matcher (or `*`) and dispatch inside the script. apm
|
||||
skips it unless `.gemini/` exists.
|
||||
- **Cursor: not reliably reachable through apm 0.28.0.** The installed source applies no event
|
||||
rename and no reshape for `cursor`, so a Claude-shaped `PreToolUse` entry lands verbatim in
|
||||
`.cursor/hooks.json`, while Cursor's native events are camelCase with a flat
|
||||
`{command, matcher}` schema. The apm docs say "Cursor accepts Claude aliases and maps them to
|
||||
native names". Cursor's docs say it "supports loading hooks from third-party tools like Claude
|
||||
Code", but the page fetched here did not detail the mapping. **I'm not certain this works.** Verify
|
||||
with a real Cursor install before claiming coverage. Even when it works, `preToolUse` does not
|
||||
enforce `ask` and fails open unless `failClosed: true`.
|
||||
- **OpenCode and other hookless targets: no hook layer.** Only the credential layers apply.
|
||||
|
||||
## 5. Recommended layered design
|
||||
|
||||
1. **Instructions (intent).** Infra skills state the stance and tell the agent to propose the
|
||||
command and stop. This costs nothing, but it is not enforcement.
|
||||
2. **One portable guard hook shipped by the infra package (fast feedback, best-effort).**
|
||||
- A single `.apm/hooks/` file on the `PreToolUse`/`preToolUse` event, **with no tool matcher**.
|
||||
The script normalises the payload (`tool_input.command`, `toolArgs`, `command`) and ignores
|
||||
non-shell tools.
|
||||
- **Always deny:** `kubectl apply|delete|patch|replace|edit|create`, `helm install|upgrade|
|
||||
uninstall|rollback`, `ansible-vault decrypt|view|edit|rekey`, `kubeseal --recovery-unseal`,
|
||||
and commands naming the vault password file.
|
||||
- **HITL** (`ansible-playbook` without `--check`/`-C`, `tofu apply|destroy`, `git push` to the
|
||||
Flux branch): emit `ask` where it is honoured (Claude Code, Copilot CLI) and `deny` everywhere
|
||||
else, with a reason telling the agent to hand the command to the human.
|
||||
- Signal the decision with **exit 2 plus stderr** as well as the JSON, so a provider that ignores
|
||||
the JSON still blocks. Keep the script POSIX `sh` and `jq`-optional.
|
||||
- Consumers approve it through the apm executable-trust gate (version-blind grant, ADR-0019
|
||||
correction).
|
||||
3. **Host hardening, documented and not shipped.** The package README or skill tells the operator
|
||||
what to set per provider. Claude: deny and ask rules, plus sandbox `denyRead` on the vault
|
||||
password file with `allowUnsandboxedCommands: false`, ideally in managed settings with
|
||||
`allowManagedHooksOnly` so the guard cannot be disabled. Codex: trust the hook after review.
|
||||
4. **Credentials (the actual boundary).** A `view`-role kubeconfig for agent sessions, apply
|
||||
credentials for tofu that the agent never holds, a vault password file that the agent's OS user
|
||||
cannot read, and an agent forge token without push or merge rights on the Flux branch. These hold
|
||||
whatever the shell form and on every provider, including hookless ones.
|
||||
5. **Repo gates.** The infra repo's pre-commit catches unencrypted secrets. Forge branch protection
|
||||
and CI catch what client hooks miss.
|
||||
|
||||
**Trade-off.** Layer 4 is outside apm and needs per-environment setup, so the package can document it
|
||||
but not install it. That is the price of actual enforcement. Layers 1–3 alone are bypassable by
|
||||
construction.
|
||||
|
||||
## 6. Open issue for the map: `--check` needs the vault
|
||||
|
||||
The stance allows `ansible-playbook --check --diff` freely but forbids reading vault password files.
|
||||
A playbook that loads vaulted variables needs the vault secret to run at all, check mode included.
|
||||
That is my understanding of Ansible's variable loading; I did not verify it against the Ansible docs
|
||||
in this pass. Any layer that truly stops the agent's processes reading the password file (sandbox
|
||||
`denyRead`, file permissions) will therefore also break the agent's check runs. The hook layer
|
||||
cannot tell the agent reading the file from Ansible reading it on the agent's behalf. Possible
|
||||
resolutions: run checks in CI, use a `--vault-password-file` client script that prompts the human,
|
||||
or accept that Ansible (not the agent) reads it and enforce only "no direct read or decrypt
|
||||
command". This needs a decision ticket on map #166.
|
||||
@@ -1,269 +0,0 @@
|
||||
# Multi-agent team patterns in practice
|
||||
|
||||
Research findings for Gitea issue #167, "Multi-agent team patterns in practice", which is part of
|
||||
map #166. Researched 2026-11-12. This note gathers evidence and makes a recommendation. It does not
|
||||
decide anything; the decision belongs to the map's owner.
|
||||
|
||||
## Question
|
||||
|
||||
Which provider-agnostic multi-agent "team" patterns are actually used to take work from specs to
|
||||
tickets to code to review? And which of them fit an apm package in this repo? The sub-questions:
|
||||
|
||||
1. Role-specialist agents versus a small set of generic role agents that load skills on demand
|
||||
2. Orchestration shapes, and how state and hand-offs travel without a provider runtime
|
||||
3. What apm primitives can carry portably across Claude Code, Copilot, Codex, Gemini and Cursor
|
||||
4. A verdict on this repo's `*-orchestrate` agents
|
||||
5. How much the `mattpocock` dependency already covers
|
||||
|
||||
## Answer in brief
|
||||
|
||||
- **Generic roles plus on-demand skills is the dominant pattern in coding tools.** Every coding
|
||||
harness checked ships a few *generic* built-in agents: an explorer/investigator, a planner and a
|
||||
general worker. Tech-stack specialists are not among them. Anthropic positions skills explicitly
|
||||
as the alternative to "fragmented, custom-designed agents". Role-persona teams (CrewAI, MetaGPT,
|
||||
ChatDev) also use functional roles such as Product Manager, Architect and Engineer, not tool
|
||||
specialists. Tool-specialist agents ("kubernetes-architect") show up mainly in community
|
||||
catalogues.
|
||||
- **Orchestrator–worker is the production shape.** Its workers run in isolated contexts and pass
|
||||
back only references or summaries. Pipeline/hand-off and generator–critic review are the other
|
||||
two shapes in common use. Peer-to-peer teams with a shared task list exist, but only as an
|
||||
experimental, Claude-specific runtime feature, and vendors steer you away from them for coding
|
||||
work that writes code.
|
||||
- **The issue tracker and the files are the portable state carriers.** None of the harnesses
|
||||
checked carries a multi-agent runtime that another harness can read. What *is* portable is
|
||||
SKILL.md (the Agent Skills open standard), AGENTS.md, and files, branches and tracker issues
|
||||
referenced by pointer.
|
||||
- **The `mattpocock` dependency already ships the pipeline as skills.** The chain is wayfinder →
|
||||
to-spec → to-tickets → triage → implement / implement-spec → tdd → code-review. Its roles
|
||||
(exploration, implementer, merger, standards reviewer and spec reviewer) are defined inline as
|
||||
fresh-context subagent prompts. It ships no agent files.
|
||||
- **The `*-orchestrate` agents are an outlier, with two anti-pattern traits.** The narrow
|
||||
dispatcher shape itself is accepted practice. The traits are rules restated from the skills
|
||||
(the GLOSSARY "Delegation discipline" defect) and safety gates enforced only by prompt.
|
||||
|
||||
**Recommendation:** do not build role-specialist agents. If a team package is built at all, keep
|
||||
it domain-agnostic and thin. That means at most three or four generic role agents (planner,
|
||||
implementer, reviewer, and optionally operator) whose only job is to carry a tool fence. The
|
||||
procedure stays in skills, and most of those skills `mattpocock` already ships. State goes in the
|
||||
tracker and on git branches. The infra package then contributes *tool* skills (Ansible, k8s and so
|
||||
on) that those generic roles load on demand. The tradeoff is weaker per-agent tool restriction on
|
||||
harnesses that cannot express a fence, such as Gemini and Codex. On those harnesses, enforcement
|
||||
has to come from the session's own permissions and from hooks.
|
||||
|
||||
## 1. Role-specialist versus generic role agents
|
||||
|
||||
### What the vendors ship and recommend
|
||||
|
||||
| Source | Built-in or example agents | Shape |
|
||||
|---|---|---|
|
||||
| Claude Code subagents [S4] | Built-in: `Explore` (read-only), `Plan`, `general-purpose`. Examples: `code-reviewer`, `debugger` | Generic and functional |
|
||||
| Codex subagents [S12] | Built-in: `default`, `worker` ("execution-focused… implementation and fixes"), `explorer` ("read-heavy") | Generic |
|
||||
| Gemini CLI subagents [S13] | Built-in: `codebase_investigator`, `generalist`, `cli_help`, `browser_agent` | Generic |
|
||||
| Cursor subagents [S14] | Built-in: `Explore`, `Browser` | Generic |
|
||||
| GitHub Copilot custom agents [S10] | Examples: "Testing specialist", "Implementation planner" | Functional |
|
||||
| OpenAI Agents SDK [S8] | "Have specialized agents that excel in one task" | Functional specialisation |
|
||||
| CrewAI [S11] | `role`/`goal`/`backstory`. Examples: "Research Analyst", "Senior Python Developer" | Persona roles |
|
||||
| MetaGPT [S15] | "assembly line paradigm to assign diverse roles" encoding SOPs | Persona roles (PM, Architect, Engineer) |
|
||||
| ChatDev [S16] | "specialized agents" across "design, coding, and testing phases" | Persona roles by phase |
|
||||
|
||||
Two things stand out.
|
||||
|
||||
1. **No vendor ships a tech-stack specialist as a built-in.** The specialisation that vendors *do*
|
||||
recommend is by **function**: review, debug, test, plan or explore. Codex puts it directly:
|
||||
"The best custom agents are narrow and opinionated", meaning one clear job and a tool surface to
|
||||
match [S12]. A job is a function ("review"). It is not a technology ("Ansible").
|
||||
2. **Domain knowledge moves into skills.** Anthropic introduced skills so that, "instead of
|
||||
building fragmented, custom-designed agents for each use case", you specialise a
|
||||
general-purpose agent by packaging procedural knowledge it loads on demand. Anthropic has
|
||||
published the format as an open standard [S5]. LangChain lists "Skills: specialized prompts and
|
||||
knowledge loaded on-demand" as a first-class alternative to multi-agent setups, with a single
|
||||
agent keeping control [S17].
|
||||
|
||||
Claude Code wires the two together. An agent's `skills:` frontmatter preloads named skills, and
|
||||
"subagents can still invoke unlisted… skills through the Skill tool" [S4]. A generic `implementer`
|
||||
can therefore pick up an `ansible` skill without anyone writing an `ansible-engineer` agent.
|
||||
|
||||
### Where tool specialists do appear
|
||||
|
||||
Tool specialists do appear, in community catalogues. `wshobson/agents`, for example, ships 202
|
||||
agents next to 185 skills across 94 plugins [S18]. Those catalogues show that people *write* such
|
||||
agents. They do not show that teams *run* them as the working structure, and I found no primary
|
||||
vendor source that recommends the tool-specialist layout. **Not certain:** no usage telemetry
|
||||
compares the two approaches, so "more used" rests on what vendors ship and recommend, not on
|
||||
measured adoption.
|
||||
|
||||
### Why generic roles win: the reasons the sources give
|
||||
|
||||
- **Context and cost.** Multi-agent systems use "about 15× more tokens than chats" [S2]. Each extra
|
||||
agent costs a full context window, and Claude Code also warns once the combined subagent
|
||||
descriptions pass 15,000 tokens [S4]. A roster of N tech specialists grows linearly in
|
||||
descriptions that are always loaded. Skills cost about 100 tokens each until they are activated
|
||||
[S6].
|
||||
- **Coding parallelises poorly.** Anthropic notes that "most coding tasks have fewer parallelizable
|
||||
subtasks than research", and that domains needing shared context are a poor fit [S2]. Cognition
|
||||
argues that "actions carry implicit decisions, and conflicting decisions carry bad results", and
|
||||
recommends a single-threaded linear agent [S3]. Specialists that split one change *by
|
||||
technology* (an Ansible role plus the k8s manifests it deploys) are exactly the kind of agents
|
||||
that make conflicting implicit decisions.
|
||||
- **Measured failure modes.** The MAST study annotated 1,600+ traces across 7 multi-agent
|
||||
frameworks and found 14 failure modes in three groups: system design, inter-agent misalignment
|
||||
and task verification. It found that "performance gains on popular benchmarks are often minimal"
|
||||
[S19].
|
||||
- **Start simple.** Anthropic's advice is to "find the simplest solution possible, and only
|
||||
increasing complexity when needed" [S1]. LangChain says "not every complex task requires this
|
||||
approach" [S17].
|
||||
|
||||
This repo's earlier factory research reached the same answer independently: six *functional*
|
||||
roles that run sequentially, because "concurrent agent teams compound error rates and explode
|
||||
token cost" (`docs/research/ai-coding-factory/ai-coding-factory-principles.md` §4–5).
|
||||
|
||||
## 2. Orchestration shapes and how state travels
|
||||
|
||||
| Shape | First-party description | Fit for spec → code → review |
|
||||
|---|---|---|
|
||||
| Orchestrator–worker | "a central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results" [S1]. A lead agent with parallel subagents [S2]. "Agents as tools… manager keeps control" [S8]. ADK "Coordinator/Dispatcher" and "Hierarchical decomposition" [S9] | **Primary.** It is the one shape every harness supports natively (subagents) |
|
||||
| Pipeline / hand-off | Prompt chaining [S1]. ADK "Sequential Pipeline… hands the baton" [S9]. OpenAI "handoffs: a triage agent routes… specialist takes over" [S8] | Good for phase boundaries (spec → tickets → code), each phase being a fresh session |
|
||||
| Generator–critic / review loop | Evaluator–optimizer [S1]. ADK "Generator and critic", "Iterative refinement" [S9] | Good for review. `code-review` is already a two-critic fan-out |
|
||||
| Parallel fan-out / gather | Parallelisation [S1]. ADK "Parallel Fan-Out/Gather" [S9] | Good for read-heavy work. Codex: be careful with write-heavy parallel work [S12] |
|
||||
| Peer team with a shared task list | Claude Code agent teams: lead, teammates, a shared task list with blocking, and mailboxes [S7] | **Experimental and Claude-only.** Vendor advice is to "start with research and review", because parallel implementation brings coordination problems [S7] |
|
||||
| Human-in-the-loop | ADK "Human-in-the-loop" [S9] | Needed before irreversible steps (governance rule) |
|
||||
|
||||
**State without a provider runtime.** First-party sources converge on *external artifacts passed by
|
||||
reference*:
|
||||
|
||||
- Anthropic: "Subagents call tools to store their work in external systems, then pass lightweight
|
||||
references back to the coordinator" [S2].
|
||||
- Delegation needs "an objective, an output format, guidance on the tools and sources to use, and
|
||||
clear task boundaries" [S2].
|
||||
- ADK passes state through `session.state`, with each agent writing to an `output_key` [S9]. That
|
||||
is runtime-specific. Its portable equivalent is a file or an issue.
|
||||
- Claude agent teams keep their task list in `~/.claude/tasks/…`. That is session-scoped and
|
||||
"one team per session", so it is not portable and not shareable [S7].
|
||||
|
||||
The portable carriers are therefore these:
|
||||
|
||||
- **Issue tracker:** tickets, native blocking links as the task graph, assignee as the claim,
|
||||
comments as the resolution record. This is the mechanism `wayfinder` and `implement-spec` already
|
||||
use.
|
||||
- **Git:** an integration branch per spec and one worktree plus branch per worker
|
||||
(`implement-spec`).
|
||||
- **Files:** research notes, specs and ADRs.
|
||||
- **AGENTS.md:** standing conventions. More than 20 tools read it, including Codex, Copilot's
|
||||
coding agent, Cursor, Gemini CLI, Jules, Devin, Zed and VS Code [S20].
|
||||
|
||||
## 3. What is portable across harnesses
|
||||
|
||||
| Primitive | Portable? | Evidence |
|
||||
|---|---|---|
|
||||
| Skill (`SKILL.md`) | **Yes.** It is the open standard, and apm copies it verbatim to every target (`.agents/skills/` for most, `.claude/skills/` for Claude) | [S6]. `plugins/kyberforge/docs/research/docs/microsoft-apm/agent-primitive-schema.md:64-66` |
|
||||
| AGENTS.md | **Yes.** It is read natively by 20+ tools | [S20] |
|
||||
| Agent (`.agent.md`) | **Partly.** `name`, `description` and the body survive everywhere apm deploys agents. Claude, Copilot and Cursor get a verbatim copy. Codex gets a TOML rebuild in which `model` and `tools` are dropped. Kiro strips `name`. Apm's research records that Gemini and Windsurf get no agent at all | `agent-primitive-schema.md:27-37`. ADR-0016 |
|
||||
| Tool fence on an agent | **No.** `tools:` vocabularies conflict. `disallowedTools` is honoured by Claude, but its meaning on Copilot is unverified, and Codex drops it | ADR-0016 and its 2026-08-14 amendment. Codex: "To prevent edits, set sandbox and approval controls on the parent session, not in agent instructions" [S12] |
|
||||
| Skill preload on an agent (`skills:`) | Claude only. Agent-team teammates ignore it even in Claude [S7] | [S4], [S7] |
|
||||
| Peer-team runtime | **No.** Experimental and Claude-only | [S7] |
|
||||
|
||||
**A gap to verify.** Apm's research says Gemini "has no agents primitive" (`agent-primitive-schema.md:37`).
|
||||
Gemini CLI now documents `.gemini/agents/*.md` subagents, with `name`/`description`/`tools`/`model`
|
||||
frontmatter, enabled by default [S13]. Cursor reads `.claude/agents/` and `.codex/agents/` as
|
||||
compatibility paths [S14]. Apm's Gemini mapping may therefore be stale. Check the current apm
|
||||
release before relying on it either way.
|
||||
|
||||
Consequence: in this repo, **a role agent can portably carry only a name, a description and a body
|
||||
of prose.** So a generic-role agent is cheap to make portable. A specialist agent whose value
|
||||
depends on a tool fence or a skill preload is not portable at all.
|
||||
|
||||
## 4. Verdict on the `*-orchestrate` agents
|
||||
|
||||
The three agents are `git-orchestrate`, `gitea-orchestrate` and `apm-orchestrate`
|
||||
(`plugins/{git,gitea,kyberforge}/.apm/agents/`). Each is a dispatcher for one tool domain. An
|
||||
*agent* caller sends it an `operation` plus `confirm`. It enforces "Hard rules", routes to that
|
||||
domain's skills, and returns JSON.
|
||||
|
||||
| Aspect | Judgement | Basis |
|
||||
|---|---|---|
|
||||
| Narrow job, an isolated context, a structured result | **Accepted** | Codex "narrow and opinionated" [S12]. Anthropic's delegation contract (objective, output format, boundaries) [S2]. ADK Coordinator/Dispatcher [S9] |
|
||||
| Read-only fence (`disallowedTools` on gitea/apm) | Accepted intent, **Claude-only effect** | §3 above. On Codex the fence is dropped, and the vendor says to put it on the session instead [S12] |
|
||||
| Specialised by *tool domain* (git, Gitea, apm), not by function | **Outlier.** In the sources reviewed, no vendor or framework puts a dispatcher agent between an agent and a set of skills. The vendor pattern is that the working agent loads the skill itself [S4], [S5], [S17] | §1 |
|
||||
| "Hard rules" restated from the domain skills | **Anti-pattern** (GLOSSARY "Delegation discipline": restatement). `git-orchestrate` says it outright: "Sub-skills carry their own local copies of these rules" | `plugins/git/.apm/agents/git-orchestrate.agent.md` |
|
||||
| Safety gates enforced only by the prompt (`confirm: true`, never force-push `main`) | **Anti-pattern for invariants.** Governance makes deterministic tooling the enforcement layer ("Agent instructions alone cannot enforce what deterministic tooling must enforce"), and vendors put it in session permissions or hooks [S7], [S12] | `core/instructions/governance.md`. Pre-push hooks in `.pre-commit-config.yaml` are the repo's existing deterministic layer |
|
||||
| Code-smell view | "Middle Man: a class or function that mostly just delegates onward → cut it" | mattpocock `code-review` baseline |
|
||||
|
||||
Net: **an outlier, not accepted practice for a team pattern.** The parts worth keeping are the
|
||||
domain gotchas, such as the Gitea `delete_release` id-versus-tag asymmetry and 404-means-forbidden.
|
||||
Those belong in the domain skills. Irreversible-action gates belong in hooks and permissions. A
|
||||
generic implementer or operator agent would then call `git-commits` or `gitea-prs` directly, which
|
||||
also saves a nesting level against Claude's default subagent depth limit of three [S4].
|
||||
`lint-runner` is the one agent of this kind that sits closer to accepted practice: it is a
|
||||
read-only, function-scoped worker ("run linters, report findings").
|
||||
|
||||
## 5. Overlap with `mattpocock`
|
||||
|
||||
`plugins/mattpocock/apm.yml` pins 20 upstream skills at `v1.3.2`. Mapped onto the pipeline:
|
||||
|
||||
| Pipeline stage | Skill already shipped | Roles it defines inline |
|
||||
|---|---|---|
|
||||
| Fog → decisions | `wayfinder` (tracker map, typed tickets, frontier, claim by assignee, research subagents on `research/<name>` branches) | Research subagent |
|
||||
| Spec | `to-spec`, `grill-with-docs`, `domain-modeling` | — |
|
||||
| Tickets | `to-tickets` (vertical slices, native blocking edges, expand–contract for wide refactors) | — |
|
||||
| Ready-for-agent | `triage` (`ready-for-agent` / `ready-for-human` states, agent briefs) | — |
|
||||
| Code | `implement` (single session), `implement-spec` (integration branch, frontier-driven parallel implementers in worktrees, merger subagent, "communicate primarily through context pointers") | Exploration, implementer and merger subagents |
|
||||
| Test-first | `tdd`, `codebase-design` | — |
|
||||
| Review | `code-review` (Standards and Spec as parallel fresh-context subagents, not merged or reranked) | Standards reviewer and spec reviewer |
|
||||
| Learn | `retro` | — |
|
||||
|
||||
`implement-spec` already *is* the orchestrator–worker shape with tracker and git state that §2
|
||||
recommends. Its roles are generic (implementer, reviewer) and load skills (`tdd`). So the pipeline
|
||||
and the generic roles are covered. What is not covered:
|
||||
|
||||
1. **No named role-agent files.** The roles exist only as prompts inside the orchestrating skill,
|
||||
so they cannot carry a tool fence and cannot be reused on their own.
|
||||
2. **No operator or deploy role.** Nothing covers plan/apply against infrastructure with a HITL
|
||||
gate. Today that is the infra package's territory.
|
||||
3. **The entry points are hand-invoked only.** `wayfinder`, `to-tickets`, `to-spec`, `implement`,
|
||||
`implement-spec` and `triage` set `disable-model-invocation: true`, so another agent cannot
|
||||
route to them through the Skill tool (`plugins/mattpocock/apm.yml` comments). A team package
|
||||
could not chain them autonomously without a local wrapper.
|
||||
4. **There is a tracker dependency.** They read the tracker doc that `setup-matt-pocock-skills`
|
||||
writes, and here that is Gitea through the `gitea-*` skills (`docs/agents/issue-tracker.md`).
|
||||
|
||||
## Options for the map (evidence, not a decision)
|
||||
|
||||
| Option | For | Against |
|
||||
|---|---|---|
|
||||
| A. No team package. Use `mattpocock` as is, and the infra package adds tool skills only | Zero new surface. Matches vendor guidance and §5 coverage | Roles stay unfenced prompts, and the pipeline is hand-driven stage by stage |
|
||||
| B. **Thin generic-roles package** (recommended): `planner`, `implementer`, `reviewer`, optional `operator` agents, each a short body that names the skills to load. Reviewer and planner fenced read-only with `disallowedTools`. State in Gitea and branches | Matches what vendors ship ([S4], [S12], [S13]). Portable as name, description and body. Reusable as subagents and as Claude teammates [S7] | Fences hold on Claude only. Needs a skill-level wrapper to start the hand-invoked `mattpocock` entry points |
|
||||
| C. Role-specialist roster (`ansible-engineer`, `k8s-reviewer`, …) | Familiar from CrewAI and community catalogues | Linear description cost, overlapping implicit decisions [S3], no vendor precedent, couples the team to the infra domain, which the brief rules out |
|
||||
|
||||
## Sources
|
||||
|
||||
Primary sources were fetched 2026-11-12. Quotations are verbatim from the fetched page.
|
||||
|
||||
- [S1] Anthropic, "Building effective agents" — <https://www.anthropic.com/engineering/building-effective-agents>
|
||||
- [S2] Anthropic, "How we built our multi-agent research system" — <https://www.anthropic.com/engineering/multi-agent-research-system>
|
||||
- [S3] Cognition, "Don't build multi-agents" — <https://cognition.com/blog/dont-build-multi-agents>
|
||||
- [S4] Claude Code docs, "Subagents" — <https://code.claude.com/docs/en/sub-agents>
|
||||
- [S5] Anthropic, "Equipping agents for the real world with Agent Skills" — <https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills>
|
||||
- [S6] Agent Skills specification — <https://agentskills.io/specification>
|
||||
- [S7] Claude Code docs, "Agent teams" — <https://code.claude.com/docs/en/agent-teams>
|
||||
- [S8] OpenAI Agents SDK, "Orchestrating multiple agents" — <https://openai.github.io/openai-agents-python/multi_agent/>
|
||||
- [S9] Google Developers Blog, "Developer's guide to multi-agent patterns in ADK" — <https://developers.googleblog.com/en/developers-guide-to-multi-agent-patterns-in-adk/>
|
||||
- [S10] GitHub Docs, "Creating custom agents" — <https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/create-custom-agents>
|
||||
- [S11] CrewAI docs, "Agents" — <https://docs.crewai.com/en/concepts/agents>
|
||||
- [S12] OpenAI Codex docs, "Subagents" — <https://learn.chatgpt.com/docs/agent-configuration/subagents>
|
||||
- [S13] Gemini CLI docs, "Subagents" — <https://geminicli.com/docs/core/subagents/>
|
||||
- [S14] Cursor docs, "Subagents" — <https://cursor.com/docs/context/subagents>
|
||||
- [S15] Hong et al., "MetaGPT" — <https://arxiv.org/abs/2308.00352>
|
||||
- [S16] Qian et al., "ChatDev" — <https://arxiv.org/abs/2307.07924>
|
||||
- [S17] LangChain docs, "Multi-agent" — <https://docs.langchain.com/oss/python/langchain/multi-agent>
|
||||
- [S18] wshobson/agents (community catalogue, practitioner evidence) — <https://github.com/wshobson/agents>
|
||||
- [S19] Cemri et al., "Why Do Multi-Agent LLM Systems Fail?" (MAST) — <https://arxiv.org/abs/2503.13657>
|
||||
- [S20] AGENTS.md — <https://agents.md/>
|
||||
|
||||
Repo sources: ADR-0015, ADR-0016 (and its 2026-08-14 amendment), ADR-0024; `GLOSSARY.md`
|
||||
("Delegation discipline"); `plugins/kyberforge/docs/research/docs/microsoft-apm/agent-primitive-schema.md`;
|
||||
`plugins/mattpocock/apm.yml`; the upstream `mattpocock/skills` SKILL.md files at `v1.3.2`
|
||||
(installed under `apm_modules/`); `plugins/*/.apm/agents/*.agent.md`.
|
||||
|
||||
**Not reached:** OpenAI's "A practical guide to building agents" PDF could not be read as text, and
|
||||
LangGraph's legacy multi-agent concepts page redirected away, so neither is cited. AutoGen was not
|
||||
consulted separately.
|
||||
Reference in new issue
Block a user