Skip to content

E10: Loop guard — detect repeated identical tool calls via message fingerprint #22

Closed

Description

@ajianaz

What

Detect and abort runaway loops where the model repeats the same tool call (same tool + same input) N times consecutively, using a cheap content fingerprint — no second model needed.

Why

Adopted from oh-my-pi's advisor loop-guard + message-fingerprint (see research notes). A stuck model burning provider budget on identical calls is the cheapest failure mode to detect deterministically. Tole already has MAX_STEPS: 32 as a hard ceiling; this adds a semantic tripwire before that ceiling — catching the loop at call 3 instead of call 32.

Design sketch

  • In drive() (tole-core/src/turn.rs): hash each tool call as (tool_name, canonical_json(input)) → e.g. u64 via std hasher
  • Track consecutive identical hashes; threshold e.g. 3
  • On trip: durable ERROR entry (loop guard) + new TurnOutcome::LoopDetected { tool, count }
  • Pure function, Tier A testable with MockProvider scripts

Acceptance criteria

  • Consecutive identical calls (≥3) trip the guard with durable record
  • Non-identical calls never trip it
  • Identical calls with interleaved different call resets the streak
  • Unit tests for the fingerprint function itself
  • e2e test: MockProvider scripts a 3× identical call loop → LoopDetected
  • cargo clippy clean, cora review clean

Activity

  1. added
    enhancement
    on Aug 27, 2026
  2. added a commit that references this issue on Aug 27, 2026
    d64dd8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions