Agent Loop Detector
agent.loop_detect
Overview
You send 2 to 5,000 events with action, optional target, stateFingerprint and outcome. window (2-200, default 20) and repeatThreshold (2-20, default 3) bound the search. similarity EXACT uses all four fields; ACTION_TARGET ignores state and outcome. We pick the earliest span, then the shortest cycle. We do not stop an agent or judge task success.
An agent that retries the same click against an unchanged page burns quota without a typed loop signal.
Reliability
Deterministic earliest-then-shortest selection; no clock or network. LOOP_EVENTS_INVALID — trigger: fewer than 2 events or an unknown similarity; retryable: no; next: send two or more closed events. LOOP_EVENT_LIMIT_EXCEEDED — trigger: more than 5,000 events; retryable: no; next: window the trace.
Context footprint
Span indices and cycle length only. A successful call costs 1 execution credit.
When to use it
When a trace of actions might be cycling and you want the earliest shortest span.
When you need to halt the agent, compare embeddings, or explain why the task failed.
Scope
Non-goals
- Does not stop an agent
- Does not use embeddings
- Does not judge task success
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response does not contain submitted content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| events | array | Yes | Bounded array of 1 through 10001 events; runtime requires 2 and accepts at most 5000. |
| window | integer | No | Cycle length ceiling from 2 through 200. Omit it for 20. |
| repeatThreshold | integer | No | Consecutive copies required, from 2 through 20. Omit it for 3. |
| similarity | string | No | EXACT or ACTION_TARGET. Omit it for EXACT. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| loopDetected | boolean | Yes | Whether a span met the threshold. |
| similarity | string | Yes | Applied similarity rule EXACT or ACTION_TARGET after defaulting. |
| window | integer | Yes | Applied cycle-length ceiling after defaulting omitted values. |
| repeatThreshold | integer | Yes | Applied consecutive-copy threshold after defaulting omitted values. |
| cycleLength | integer | Yes | Chosen cycle length, or 0. |
| confidence | string | Yes | NONE, MEDIUM or HIGH for the chosen span. |
| eventIndices | array | Yes | Bounded array of 0 through 5000 indices covering the chosen span. |
| spans | array | Yes | Bounded array of 0 through 8 chosen spans; v1 reports at most one. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"agent.loop_detect","input":{"events":[{"action":"a"},{"action":"a"},{"action":"a"}]}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("agent.loop_detect", {"events":[{"action":"search","target":"web","outcome":"ok","stateFingerprint":"s1"},{"action":"click","target":"r1","outcome":"ok","stateFingerprint":"s2"},{"action":"search","target":"web","outcome":"ok","stateFingerprint":"s1"},{"action":"click","target":"r1","outcome":"ok","stateFingerprint":"s2"},{"action":"search","target":"web","outcome":"ok","stateFingerprint":"s1"},{"action":"click","target":"r1","outcome":"ok","stateFingerprint":"s2"}]});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
| LOOP_EVENTS_INVALID | 400 | No | The request payload failed this skill's input validation. |
| LOOP_EVENT_LIMIT_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not stop an agent
- Does not use embeddings
- Does not judge task success
- Halting a running agent
- Semantic similarity of free text
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "agent.loop_detect",
"input": {
"events": [
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "s1"
},
{
"action": "click",
"target": "r1",
"outcome": "ok",
"stateFingerprint": "s2"
},
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "s1"
},
{
"action": "click",
"target": "r1",
"outcome": "ok",
"stateFingerprint": "s2"
},
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "s1"
},
{
"action": "click",
"target": "r1",
"outcome": "ok",
"stateFingerprint": "s2"
}
]
}
}Examples
A search-click cycle repeating three times
{
"events": [
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "s1"
},
{
"action": "click",
"target": "r1",
"outcome": "ok",
"stateFingerprint": "s2"
},
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "s1"
},
{
"action": "click",
"target": "r1",
"outcome": "ok",
"stateFingerprint": "s2"
},
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "s1"
},
{
"action": "click",
"target": "r1",
"outcome": "ok",
"stateFingerprint": "s2"
}
]
}{
"spans": [
{
"start": 0,
"end": 5,
"cycleLength": 2,
"repeats": 3
}
],
"confidence": "MEDIUM",
"cycleLength": 2,
"eventIndices": [
0,
1,
2,
3,
4,
5
],
"window": 20,
"repeatThreshold": 3,
"similarity": "EXACT",
"loopDetected": true
}Same action with changing state is not an EXACT loop
{
"similarity": "EXACT",
"events": [
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "a"
},
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "b"
},
{
"action": "search",
"target": "web",
"outcome": "ok",
"stateFingerprint": "c"
}
]
}{
"spans": [],
"confidence": "NONE",
"cycleLength": 0,
"eventIndices": [],
"window": 20,
"repeatThreshold": 3,
"similarity": "EXACT",
"loopDetected": false
}Recommended use cases
- Catch a search-click cycle before another retry
- Ignore state changes when only action and target repeat
Avoid for
- Halting a running agent
- Semantic similarity of free text
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.