Skip to Content
v0.8.0 · shippedNative iOS / Android / Flutter / Capacitor SDKs, A2A discovery, SOC 2 readiness, residency, BYO storage, BYOK. Read the changelog →
ConceptsAgent contract

Agent contract

Mushi exposes its closed loop to AI coding agents through the MCP server. This page defines the bidirectional contract: what the agent should read and do, and what Mushi commits to in return.

The evolution loop (what you’re plugging into)

User reports a bug → Mushi captures screenshot + intent + logs → classify-report triages severity, category, blast radius → fix-worker opens a draft PR (Cursor / Claude Code) → qa-story-runner verifies the fix → judge-batch scores it → lesson library ingests the pattern → next agent reads the lesson and doesn't repeat the mistake

The loop is self-reinforcing. Every PR the agent opens eventually feeds the lesson library, which makes the next agent’s fix smarter.

What the agent reads before opening a PR

These are the minimum reads. Agents that skip them produce fixes with higher recurrence rates (tracked by judge_batch.recurrence_score).

StepMCP callWhy
Get the fix briefget_fix_context(reportId)Root cause, smallest file set, repro steps, blast-radius warnings
Check lessonslessons.query or read .mushi/lessons.jsonAnti-patterns from past fixes on similar components
Inspect blast radiusget_blast_radius(componentId)Other components that will break if this one changes
Read privacy postureprivacy://status resourceConfirm whether client data leaves the project LLM account

Run mushi setup --ide cursor --with-rules to write a .cursorrules file that embeds these steps as persistent agent instructions.

What the agent does after merging the PR

StepMCP callWhat it triggers
Record the outcomesubmit_fix_result(fixId, branch, prUrl, files, lines)Judge batch queues the fix for scoring
(Optional) trigger judge nowtrigger_judge(fixId)Runs Sonnet-as-Judge immediately instead of waiting for nightly batch

What Mushi commits to in return

When an agent follows this contract, Mushi promises:

  1. A judge score within 24 hoursjudge_results row with correctness, safety, blast_radius, test_coverage, and a recommendation (ship / iterate / dismiss).
  2. Lesson induction — if the fix addresses a pattern seen 3+ times, the lesson library gains a new rule. The rule appears in the next mushi sync-lessons output.
  3. Prompt-version credit — if the fix scores recommendation=ship, the prompt version that generated it is promoted as a candidate in the prompt lab. The lesson library bias shifts toward that prompt’s framing.
  4. Evolution history — the event is visible in evolution://history so future agents can see the loop converging.

Self-bootstrap (Claude Code and similar)

Agents that run in a repo without Mushi configured can self-bootstrap using the setup_repo_for_mushi tool (requires mcp:write scope):

// In the agent's context: "Set up this repo for Mushi" // The agent calls: setup_repo_for_mushi({ repo_root: ".", project_name: "my-app" })

This writes:

  • .mushi/lessons.json — pre-filled with current project lessons
  • .cursorrules — evolution-loop coding rules for Cursor
  • MUSHI.md — this contract as a human-readable doc in the repo

Privacy contract

Before dispatching a fix that touches user data fields, read privacy://status. The response tells you:

FieldWhat it means
byok_configuredtrue = your LLM key; false = platform key (data transits Mushi’s account)
storage_providerWhere screenshots and logs are stored
retention_daysHow long raw report data is kept
regionData residency region

If byok_configured = false and the fix touches PII fields, consider configuring BYOK first (Settings → API Keys → BYOK) so all LLM calls run against your own account.

Scopes

ScopeWhat it grants
mcp:readAll read tools and resources including privacy://status, evolution://history
mcp:writeEverything in mcp:read plus submit_fix_result, dispatch_fix, setup_repo_for_mushi

Mint keys in Admin console → Settings → API Keys. Pick the smallest scope that works — mcp:read is enough for agents that only read context.

Last updated on