Product 22 · SDK / CLI / MCP · Wave 2

Agent Maintenance Protocol

Long-lived agents need a checkup — with a human signature. Agent Maintenance Protocol gives an agent a disciplined way to tidy its own state: it surfaces maintenance pressure read-only, builds an executable preview, and then mutates state only after a matching typed approval. Review, approve, execute — strictly separated, never collapsed.

Wave 2 · v0.1.1 · on npm
← Product 21: Webhook & Event Dormancy Manager View All · Wave 2 Full Product Suite →

Self-maintenance is exactly the authority you don't want unsupervised.

An agent that runs for weeks accumulates cruft: duplicate or stale goals, repeated heartbeat motifs, memory tables that have outgrown their usefulness, handoff files that were never registered. Left unattended, this drift quietly degrades the agent. But the obvious fix — letting the agent clean up after itself — is dangerous, because self-maintenance is exactly the kind of broad, mutating authority you do not want an agent to exercise unsupervised.

The failure mode is a maintenance pass that reviews and edits in one motion: the agent decides something looks stale and deletes it in the same breath, with no checkpoint where a human could see the proposed change before it happened. A helper model proposing housekeeping is useful; a helper model that can directly mutate goals and memory is a liability.

Agent Maintenance Protocol enforces the separation that makes self-maintenance safe. A read-only review phase can look at everything and change nothing. A preview phase turns proposals into concrete, fingerprinted actions and a matching approval template. Execution mutates state only when a caller supplies a typed approval whose approval_token, preview_id, and action ids all match the preview. The phases cannot be short-circuited.

Review → Approve → Execute

Review (read-only)

get_maintenance_review returns a packet of maintenance pressure across goals, merged lineage, confidence outliers, heartbeat repetition, memory counts, shared-file bridge status, and helper-model posture. The packet is explicitly read_only: true, mutation_allowed: false — no provider, worker, or webhook calls, and nothing is changed.

Preview & human approve

preview_maintenance_execution normalizes proposed actions into executable previews, computes a preview_id, and emits the exact MAINTENANCE_EXECUTION_APPROVAL block a human must return. Helper output is never executed directly — between review and execute sits a real human gate: a person reads the preview and signs the typed approval, or nothing proceeds.

Execute (scoped)

execute_approved_maintenance mutates state only if the approval is approved=true, the approval_token matches, the preview_id matches the current preview, and every approved action id is known and executable. It then writes a change_log receipt. Any mismatch is blocked with a named reason.

Agent Maintenance Protocol is a decision-support layer. It structures self-maintenance into review → approve → execute and refuses to mutate without a matching human approval; it does not decide for you what maintenance is correct. The human approval gate between review and execute is the whole point — there is no path from a helper-model proposal to a state mutation that does not pass through a typed, person-signed approval.

Four phases, one human gate

The model below is derived directly from the originating agent's maintenance lane and its review/execution services. Each phase is individually inspectable, and the phases cannot be collapsed: review and preview never mutate, and execution rejects on any approval mismatch.

Review · Preview · Approve · Execute
PhaseWhat runsMutationGate
review Surface maintenance pressure across goals, heartbeat, memory, shared files, helper posture. None — read_only: true, mutation_allowed: false. n/a (no side effects).
preview Normalize actions into executable previews, list blockers, compute preview_id, emit approval template. None — read_only: true. Actions must be a supported type (goal_merge) and pass per-action checks.
approve A human returns a typed MAINTENANCE_EXECUTION_APPROVAL block. None. approved=true and correct approval_token and matching preview_id and known approved_action_ids.
execute Apply approved actions, then write a change_log receipt. Yes — scoped to approved action ids only. Preview must be executable (no blockers); unknown ids are rejected.
The typed approval block must match
FieldRequirement
approved Must be true; anything else blocks with a reason.
approval_token Must match the token the preview emitted — approval token missing or incorrect otherwise.
preview_id Must match the current preview — approval preview_id does not match current preview otherwise.
approved_action_ids Every id must be known and executable — approved_action_ids contains unknown action ids otherwise.

Separation guarantees (grounded in source): review and preview never mutate; execution rejects with a named reason on any mismatch (including preview has blockers); and a change_log receipt is written on every successful execution.

Lineage & scope note. The originating agent built exactly this separation — a read-only review surface and a preview-first, typed-approval-second execution lane in which helper output stays proposal-only until a concrete action is previewed and a matching approval is supplied. The proven slice supports a single action type, goal_merge, and an agent-specific approval token. Generalizing the action catalog (broader maintenance actions beyond goal_merge) and the approval identity (who may sign, and how their identity is verified) is proposed, not yet built.

MCP tools

The MCP tools below ship in the published package (v0.1.1). They were extracted from the originating agent's maintenance routes and services.

Review (read-only)
get_maintenance_review
Return the read-only maintenance review packet across goals, heartbeat, memory, shared files, and helper posture. Mutates nothing. (GET /review → build_maintenance_review)
Preview & approval
preview_maintenance_execution
Build executable previews, blockers, a preview_id, and the required typed approval block — without mutating state. (POST /execution/preview → build_maintenance_execution_preview)
get_approval_template
Return the exact MAINTENANCE_EXECUTION_APPROVAL block a human must sign for a given preview. (emitted by the preview; parse_maintenance_execution_approval consumes it)
Execution (scoped)
execute_approved_maintenance
Execute only the approved action ids after token / preview / id checks pass, then write a change-log receipt. (POST /execution/execute → execute_approved_maintenance)
More tools in the package
record_goal
Record a local goal so the review and goal_merge actions have data to work with.
list_goals
List recorded goals.
get_change_log
List change-log receipts written by successful executions.

Install

Agent Maintenance Protocol is a CertaWorks Wave 2 product — built, tested, and published on npm. The commands below install the package — an SDK, a CLI, and an MCP server, consistent with the rest of the suite — so you can see exactly what it exposes.

Running it, or want to help shape what comes next? Use the feedback form below.

Status — published on npm (v0.1.1)

The package @certaworks/agent-maintenance-protocol is live on npm. Install it globally, or point your MCP client at it with the config below (its MCP server command is agent-maintenance-mcp).

npm package
npm install -g @certaworks/agent-maintenance-protocol
Claude Desktop config
{
  "mcpServers": {
    "agent-maintenance-protocol": {
      "command": "npx",
      "args": ["-y", "-p", "@certaworks/agent-maintenance-protocol", "agent-maintenance-mcp"]
    }
  }
}
# The typed approval a human returns for a preview: MAINTENANCE_EXECUTION_APPROVAL approved: true approval_token: <token from preview> preview_id: <preview_id from preview> approved_action_ids: ["<goal_merge action id>"]

What Agent Maintenance Protocol does and does not do

Does
  • Surface maintenance pressure in a strictly read-only review
  • Turn proposals into concrete, fingerprinted, previewable actions with a preview_id
  • Require a typed approval whose token, preview id, and action ids all match
  • Execute only the approved action ids and write a change_log receipt
  • Keep each phase separable and individually inspectable
  • Run fully local as a CLI / MCP server / SDK
Does Not
  • Execute maintenance without explicit human approval
  • Mutate anything during review or preview
  • Execute helper-model output directly, or proceed on a missing, malformed, or mismatched approval
  • Run unsupported action types — the slice supports goal_merge only (broader actions proposed)
  • Call providers, start workers, or dispatch webhooks during maintenance
  • Replace human judgment about what maintenance is correct

Using Agent Maintenance Protocol? Tell us how it goes

Agent Maintenance Protocol is part of CertaWorks Wave 2 — a second set of built tools productized from a working cognitive agent. It's on npm now. Tell us what you're running it against, what broke, or what you'd want next — we read every note.

← Product 21: Webhook & Event Dormancy Manager View All · Wave 2 Full Product Suite →