ACPpotamia

Advanced guide / Chapter 3 of 7

Loop detection and the kill switch.

The most expensive bug in agent systems is the quiet loop: an agent calls a tool, gets the same error, and tries again, all night. Nobody notices until the invoice. ACPpotamia compares each call with the session's recent calls and stops the session once it starts repeating itself.

Loop detection: a session that repeats the same call too often is stopped#1search: q=refund#2read: order 4412#3search: q=refund#4search: q=refund#5summarise#6search: q=refund#7search: q=refund#8(new call)The session's last calls (its ring), each reduced to a fingerprint of its last messages, tool calls and tool results5th match within 60 secondsSession stopped: HTTP 429 loop_detectedOther sessions keep runningMatching ignores numbers, timestamps and ids,so retries that differ only in those still count.Near matches count too (similarity ≥ 0.92 by default).
Each session remembers its last few calls. Too many matches in a short window and the session is stopped.

How a match is decided

Tuning it

SettingDefaultRaise it whenLower it when
Matching requests to stop at5agents legitimately poll the same toolloops are costly (large models)
Time window60 sagents are slow between stepsyou want faster stops
Similarity0.92different questions look alikeloops vary their wording
Requests remembered16loops alternate several callsrarely needed
Tip. Send a new X-ControlPlane-Session-Id for each task (a ticket, a job, a conversation). Loop detection and session limits then stop only the stuck task, never your whole agent.

The kill switch, at three levels

LevelStopsHow
SessionOne taskConsole → Agents → Stop, or POST /v1/controlplane/kill with a sessionId
TeamEvery agent on the teamConsole → Overview → Stop all agents, or POST /v1/controlplane/kill
OrganizationEvery agent in every teamConsole → Organization → Stop everything

A stop applies to the next call, in every region. Calls that are already streaming are allowed to finish, and new ones get HTTP 429. When you revive a session its loop memory is cleared too, so it starts with a clean slate.

Stop and revive one session from your own tools

curl -X POST https://acp.examopotamia.com/v1/controlplane/kill \
  -H "Authorization: Bearer acp_your_admin_key" \
  -d '{"sessionId":"ticket-99812","reason":"retrying a broken tool"}'

curl -X POST https://acp.examopotamia.com/v1/controlplane/revive \
  -H "Authorization: Bearer acp_your_admin_key" \
  -d '{"sessionId":"ticket-99812"}'

Be told when it happens (Enterprise)

Add a webhook on the Limits page and ACPpotamia will send you session.killed and team.killed events, signed with HMAC-SHA256. Use them to page whoever is on call or to open a ticket. The user guide shows how to verify the signature.