AgentFuse: putting a circuit breaker on an agent's tool calls
A proxy between an agent and its MCP servers that cuts semantic loops, budget overruns and risky tool calls; its default mode only observes.
What it does today
Sits between an agent and its MCP server, sees every tools/call, and stops repeating loops, sessions that exceed a duration or call budget, and tools the policy forbids. Anyone running agents that call tools over MCP can try it with `npm i -g @tunedness/agentfuse` (0.1.0).
- Started
- September 2026 — Ongoing
Form
Technologies
The first measurement of my loop breaker missed its target: on a 200-session synthetic corpus, 87.0% detection and 0.0% false positives. The target was 90%. Closing the last three points meant lowering the threshold to 0.845, which pushed false positives to 16%, so I did not lower it. This entry is about that trade and the tool that makes it: AgentFuse.
A proxy between the agent and the server
AgentFuse is an MCP proxy. It sits between the agent and a tool server, sees every tools/call, and decides whether the call goes through. If nothing trips, the result flows straight through; if something does, the agent gets a refusal it can read and act on instead of another wasted round trip. As long as the agent reaches its tools over MCP, it does not matter whether it is LangGraph, CrewAI, the Claude Agent SDK or a hand-written loop; no code changes on either side. Behaviour lives in one fusepolicy.yaml: loop thresholds, budget limits and per-tool allow / warn / deny / require_approval rules.
The default mode is warn. It computes every decision, builds the report and forwards the call anyway. A circuit breaker that cuts in the wrong place gets removed, and then it catches nothing; a loop it misses is only expensive. The would_trip count on your own traffic tells you whether enforce is safe.
Catching a loop in two tiers
The first tier is rule-based and needs no model or network: a byte-identical repeat of the same arguments (with the results agreeing too), the same error signature repeated, and short cycles like A→B→A→B. The second tier is semantic: each call is embedded locally, off the hot path, and the sliding-window score is the smaller of the average pairwise cosine similarity and answer staleness. One axis was not enough: on similarity alone the positive sessions sat below the negatives, with page 1 versus page 2 of a paginated search scoring 0.9971 and a genuine reworded retry scoring 0.9791. Staleness separates that pair. The semantic tier needs the optional @tunedness/agentfuse-embeddings-local package.
What I measured
The corpus is committed to the repository: 100 positive and 100 negative sessions from a seeded generator. At the operating point I calibrated (window: 5, threshold: 0.905) detection is 87.0%, false positives 0.0%, precision 1.000, and detection latency p95 is 5 turns. All 13 sessions I missed are one scenario: the same request repeated in different words. Added latency per call, in the worst configuration I measured (a real stdio pipe, semantic tier and telemetry both on), is 4.84 ms at p95.
On budgets, two limits are exact: max_duration and max_calls. Token and dollar limits are estimates, because a proxy on tools/call does not see the model’s own tokens; those figures are a lower bound on real usage and carry _estimated in their names.
What it covers in alpha, and what is next
Alpha. @tunedness/agentfuse is on npm as 0.1.0: npm i -g @tunedness/agentfuse installs the agentfuse command, and it needs Node.js ≥ 20.19. Protection is in wrap mode, in front of a wrapped stdio server; the serve command currently binds the HTTP endpoint and resolves the session identity but does not forward calls; every request gets an error pointing to wrap mode; it is not a guarded gateway. It does not see agent traffic that does not use MCP.
Next is getting detection to 90%. Both routes are known: a second tier for windows near the threshold, or a stronger embedding model, which reopens the install-size decision. For the security side of the same family, see the McpGuard entry.