Stop your AI agent from looping in circles
Agents repeat tool calls, burn tokens, and fail silently. Loret detects the loop, gives the agent a chance to recover, and escalates before the task fails.
In-process. No proxy. Deterministic detection. Works with LangChain, Vercel AI SDK, or any agent loop.
npm install @loret/sdk// Without Loret — agent runs until you kill it
check_health("payments-api") → timeout
check_health("payments-api") → timeout
check_health("payments-api") → timeout
check_health("payments-api") → timeout
check_health("payments-api") → timeout
...12 more calls, same result, task never completes
// With Loret — loop caught, agent recovers
check_health("payments-api") → timeout
check_health("payments-api") → timeout
check_health("payments-api") → timeout
[Loret] Loop detected. Stop calling check_health. Try a different approach.
get_deploy_status("payments-api") → v2.4.1 running, health check failing on /ready
"payments-api v2.4.1 is deployed but /ready endpoint is timing out..."Features
Detect, recover, escalate
Loret watches every tool call and intervenes when the agent gets stuck — before tokens are wasted.
Loop detection
Detects when your agent repeats the same tool call with identical results (Class A) or fails repeatedly with different approaches (Class B). Deterministic fingerprinting — no LLM calls needed.
Structured recovery
When a loop is detected, Loret injects a recovery message as the tool result. The agent reads it and changes approach — no crash, no manual intervention.
Hard stop escalation
If the agent ignores recovery and keeps looping, Loret terminates the run cleanly. The agent gets one final chance to summarize what it learned before shutdown.
Framework integrations
Drop-in support for LangChain and Vercel AI SDK. One function call wraps your agent or model — Loret handles tool interception, detection, and recovery automatically.
Budget enforcement
Block expensive requests before they happen. Set cost limits per call, per trace, or per workflow — violations throw typed errors before the request is ever sent.
In-process, no proxy
Runs inside your application. No network hop, no sidecar, no infrastructure to deploy. Data never leaves your process. Detection overhead is under 1ms.
How it works
One line. Loops handled.
LangChain
import { guard }
from "@loret/langchain"
const agent =
guard(createReactAgent,
{ llm, tools })
await agent.invoke({ messages })Vercel AI SDK
import { guard }
from "@loret/vercel"
const model =
await guard(openai("gpt-4.1"))
const result =
await generateText({
model, tools, prompt })No framework
import { loret }
from "@loret/sdk"
const session = loret()
const safe =
session.guard(checkHealth)
await safe("payments-api")What happens when an agent loops
Fingerprint
Agent calls a tool. Loret fingerprints it — tool name, arguments, result — using deterministic hashing.
Detect
If the fingerprint matches a loop pattern (same call repeated, or different args all failing), Loret replaces the result with a recovery message.
Recover or escalate
The agent reads the message and changes approach. If it ignores recovery and loops again, Loret terminates the run cleanly.
Are your agents looping right now?
Upload your agent logs and find out. See exactly which tools are repeating, how many calls are wasted, and what it's costing you. Runs in your browser — nothing is uploaded.
Try the log analyzerStay updated
Get notified on new releases
The SDK is free and open source on npm. Join for release updates and early access to new features.
No spam. Unsubscribe any time.