---
title: "Detect agent loops with Weka"
description: "Grade an agent trace from repeated steps, recurring errors, and new evidence so the runtime can continue, retry, or escalate."
slug: "models/weka/use-cases/detect-agent-loops-with-weka"
sidebar:
  label: "Detect agent loops"
seo:
  canonical: "https://autohand.ai/use-cases/detect-agent-loops-with-weka/"
---
Detect agent loops with Weka is a Weka typed-decision workflow that grade an agent trace from repeated steps, recurring errors, and new evidence so the runtime can continue, retry, or escalate. It returns a bounded answer and probabilities so application code can keep final policy enforcement deterministic.

## At a glance

| Question | Answer |
| --- | --- |
| Best for | Stop repeated work when no new evidence appears |
| Input | Minimal JSON state built from observable evidence |
| Weka returns | A calibrated stop probability that helps the runtime break loops without discarding useful progress. Available through the Weka API, Autohand SDK, and Console Playground. |
| Policy boundary | Your code owns thresholds, permissions, retries, audit logs, and the final action |

Use Weka to turn a recent agent trace into a calibrated continue-or-stop signal. Weka is in Public Preview and is available only through the Autohand API, SDK, and Console Playground.

## Summarize the trace as state

Include repeated action signatures, recurring errors, files changed, test movement, new evidence, elapsed time, and remaining budget. Prefer compact counters and hashes over an unbounded transcript.

## Ask whether progress has stopped

```json
{
  "model": "weka",
  "state": {
    "repeated_steps": 5,
    "same_error_count": 4,
    "new_evidence": false,
    "tests_improved": false
  },
  "questions": {
    "should_stop": {
      "type": "noul",
      "instructions": "Has this run stopped making measurable progress?"
    }
  }
}
```

## Choose the runtime action deterministically

Use the stop probability with hard limits for turns, cost, and elapsed time. A medium-confidence result can ask the agent to gather different evidence; a high-confidence result can stop the loop and hand the trace to a person.

## Review before accepting

Replay successful, recovering, and stuck traces. Confirm that the gate notices new evidence and does not stop a run merely because one step repeats.

## Source and validation signals

Autohand AI maintains this page as first-party Weka product guidance. Verify the current request contract in the [Weka model guide](/models/weka) and build application flows with the [Autohand SDK](https://autohand.ai/code/sdk/). Community patterns from the [AY Automate Jev builds index](https://www.ayautomate.com/jev-builds) and [dabit3/jev-experiments](https://github.com/dabit3/jev-experiments) informed the use-case taxonomy. Their measurements describe their own Jev implementations and are not Weka benchmarks.

## Frequently asked questions

**What is Detect agent loops with Weka?**

Detect agent loops with Weka is a Weka typed-decision workflow that grade an agent trace from repeated steps, recurring errors, and new evidence so the runtime can continue, retry, or escalate. It returns a bounded answer and probabilities so application code can keep final policy enforcement deterministic.

**When should a team use Detect agent loops with Weka?**

Stop repeated work when no new evidence appears. Use it when the next software step needs one bounded decision and the application can preserve the evidence, probability, and policy outcome.

**What does Weka return for this workflow?**

A calibrated stop probability that helps the runtime break loops without discarding useful progress. Available through the Weka API, Autohand SDK, and Console Playground.

**Does Weka take the final action?**

No. Weka evaluates the state and returns a typed answer. Application code remains responsible for authorization, thresholds, deterministic safety rules, logging, retries, and the final action.

## Related resources

**[Guide: Weka model guide](/models/weka)**

Build calibrated stop questions and deterministic runtime thresholds.

**[Playground: Console Playground](https://console.autohand.ai/playground/)**

Tune loop-detection state against example traces.

**[SDK: Autohand SDK](https://autohand.ai/code/sdk/)**

Evaluate trace summaries from an agent runtime.

**[Samples: Weka samples on GitHub](https://github.com/autohandai/weka-samples)**

Run typed release, CI, patch, data, research, and Code Agent SDK examples.

## API request starter

```text
POST /v1/decisions with model "weka", recent trace state, and a should_stop noul question
```
