Learning resourcesReviewed · OpenRouter

Detect Stuck and Looping Agents with ScaleDown Classify

This OpenRouter tutorial teaches TypeScript agent developers to detect stalled or repeating runs, but its paid model checks need tuning and let runs continue when checks fail. It uses ScaleDown Classify through the Decisions API to choose whether an agent should continue, receive a nudge or halt.

Researched 14 Nov 2026

In short.

This OpenRouter tutorial shows developers with an existing TypeScript AI agent how to add a supervisor, but its paid checks depend on thresholds that can miss blocked or repeating runs. It periodically sends the transcript to ScaleDown Classify and turns structured answers into continue, nudge or halt decisions. Evidence is limited to source-reported checks on three synthetic transcripts, and the completion-score explanation contains a numerical inconsistency. Real-world reliability, latency and total operating cost remain unknown.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected documentation page at [https://openrouter.ai/docs/cookbook/building-agents/detect-agent-loops-with-scaledown.md], including its code, synthetic examples, captured outputs, cost warning and linked references. Linked pages, model listings, API documentation and legal terms are excluded. Installation, execution, live responses, production reliability, latency and current pricing were not assessed.

The overview

Identity

The resource is an OpenRouter cookbook tutorial containing TypeScript code for supervising an existing agent loop. It uses the scaledown/classify-1 model through OpenRouter’s Decisions API. The original page is [https://openrouter.ai/docs/cookbook/building-agents/detect-agent-loops-with-scaledown.md].

Assessment

The tutorial provides a concrete integration pattern: define classification questions, validate the response, apply thresholds and connect the result to an agent loop. Its explicit thresholds and logging make the decisions inspectable.

The main adoption uncertainty is whether those thresholds work for a particular agent’s tasks. The page acknowledges narrow margins and model-version variation. Broad detection accuracy, false-stop rates and savings on real workloads are not established.

Users

It fits developers who control an agent’s execution loop and can access its message history, tool calls and tool results. Coding agents that repeatedly retry failed commands are the central example.

Beginners receive a staged explanation and sample code, but must already have a working TypeScript agent. Integrating other languages or frameworks is not covered.

Capabilities

The supervisor asks for a run-state classification covering progressing, stuck and looping; an estimate of whether identical tool calls repeat with identical results in the transcript’s last third; and a completion score from 0 to 2.

It can continue execution, insert a message asking the agent to change approach, or halt the loop. It logs decision probabilities, completion and usage. The completion score is recorded but does not influence the supplied action-selection function.

Using it

Requirements

The stated prerequisites are Node.js 20+ or Bun, ES modules, the corresponding runtime type definitions, zod 4 and OPENROUTER_API_KEY. The developer must supply an existing agent loop and a way to render its history as text.

The integration also requires network access to the Decisions API and paid requests through an OpenRouter account. Account eligibility, service limits and the model’s context limit are not specified.

Mechanism

judgeRun posts the transcript as state.text with three questions to [https://openrouter.ai/api/alpha/decisions]. It uses a 60-second timeout and Zod schemas to validate the response, including answer types, numeric ranges and usage fields.

The policy halts when looping and repetition estimates are both at least 0.8. Otherwise, looping at least 0.5 or stuck at least 0.4 triggers a nudge. Remaining cases continue. The sample checks every five steps; request or validation errors are logged and return continue.

Setup

Define the questions and label criteria, add the API client and response schemas, then connect supervise to the existing loop. The host application supplies history, agentStep, MAX_STEPS and renderTranscript.

Include tool arguments and results in the rendered history. Implement halting and nudge insertion, preserve the decision logs, and adapt the progressing description if legitimate work involves many similar calls. The page also supplies synthetic transcripts for evaluating the integration.

Example

The worked example uses three fictional histories for the same billing-test task. One repeats the same failing test command sixty times. Another tries twelve unsuccessful approaches to a permissions-blocked fixture. The third describes fixing an import-time clock dependency and completing the task.

The page reports halt, nudge and continue respectively in three trials per history. These nine reported checks demonstrate the intended policy on the supplied examples; performance on actual agent sessions remains unknown.

Assessment & evidence

Limitations

Detection happens only at scheduled checks. A missed classification or failed request allows execution to continue, so the supervisor does not guarantee that a loop stops. The page’s 0.4 stuck threshold and 0.8 repetition threshold have little margin in its examples.

Legitimate repetitive work can receive a nudge. Actual false-stop and missed-loop rates are unknown, and completion does not trigger stopping. The complete rendered transcript is transmitted to the API; suitability for sensitive histories depends on data-handling terms absent from the evidence.

Reasoning

The policy uses numeric estimates because a winning classification label can still have low probability. Requiring agreement between looping and repetition is intended to reduce false stops, while a single strong signal earns a nudge.

As a design inference, this agreement does not establish independent confirmation: both answers come from the same model reading the same transcript. Probability calibration is unknown. The API provides no written rationale, so the logs explain which thresholds fired rather than why the model judged the run that way.

Alternatives

The page places this supervisor alongside step and cost limits. It also points to transcript compaction [https://openrouter.ai/docs/cookbook/building-agents/compact-agent-sessions-with-scaledown.md] and a separate tool-call gate that blocks on errors [https://openrouter.ai/docs/cookbook/building-agents/gate-tool-calls-with-jev.md].

Those linked implementations are outside the supplied evidence. Their costs, effectiveness and suitability have not been assessed, and the page provides no comparative benchmark against other loop detectors.

Evidence

Evidence consists of the complete cookbook page, embedded code, synthetic histories, captured API responses and a results table. The reported trials are supplied by the page’s author. No code was executed, and live API behavior has not been independently verified.

The completion explanation contains an arithmetic inconsistency: the JSON reports 0.2888, its probabilities imply approximately 0.289, and the prose says 0.0929. This affects the explanation of the score; the supplied action-selection logic does not use completion.

Access & freshness

Costs

Each supervisor check is a paid request. The page says each question reads the whole transcript, so question count, transcript growth and check frequency affect consumption. Its looping example records 15,682 input tokens, 3 output tokens and usage.cost of 0.00062728. The supplied page does not state the currency or a general pricing schedule.

Increasing CHECK_EVERY reduces check frequency, and removing the unused completion question reduces the work requested. Current rates, total session cost, latency and net savings are unknown.

Rights

The supplied page does not state a license or redistribution permission for its text and code. Reuse rights therefore remain unknown. API terms, transcript retention and data-handling commitments are also not established by this page.

Freshness

The page was captured on 14 November 2026 at 20:33:33.255 UTC. Its snapshot SHA-256 is b84c9bd05fb5d725f52b8c664f86e76a278c85a13b12fae37b9bc1cdaefba47f.

Requests use the scaledown/classify-1 alias; one captured response identifies scaledown/classify-1-20260928. The page acknowledges scores moving between model versions. Publication and update dates, the alias’s current target, current availability and current prices are unknown.

Actions

Before adoption, evaluate labeled histories from the intended agent, including valid repetitive work, blocked tasks and actual loops. Measure missed loops, false nudges, false stops, action stability, latency and cost before choosing thresholds and a check interval.

Confirm whether continuing during API failures fits the application, retain independent step and cost limits, and review transcript-handling terms. Remove the completion question if it serves no operational purpose, and recheck the policy when the model version changes.

Evidence for this report

selected-page.txtselected · checked 2026-11-14