Skip to content

[P2][sight] tool_sequence_repetition flags consecutive same-tool calls as dead_loop (critical) #2691

Description

@Daydreamer-Li

Component

sight

What happened?

Agents that were working normally (multi-step tasks, all completed successfully) were flagged with dead_loop / critical interruption events by the tool_sequence_repetition rule:

- {"repeated_tools":["terminal"],"repeat_count":5,"rule":"tool_sequence_repetition"}
- {"repeated_tools":["exec"],"repeat_count":5,"rule":"tool_sequence_repetition"}

In one flagged case the 5 consecutive terminal calls each ran a different command (pip listfindcat → a detect script → an install script), made clear progress, and the task finished successfully — there was no loop.

What I expected: normal multi-step work that naturally invokes the same tool repeatedly (terminal/exec-heavy workflows) should not be classified as a critical dead loop.

Root cause analysis

In src/agentsight/src/interruption/loop_detector.rs, rule 1 (detect_tool_sequence_loop) compares only the tool name sequence (tool_call_names) of the last N tool-bearing calls. It does not look at the tool call arguments/commands, so five different commands executed via the same tool are indistinguishable from a genuine loop.

Additionally:

  • The threshold tool_sequence_repeat_threshold exists in LoopDetectorConfig, but the call site in src/agentsight/src/unified.rs constructs LoopDetector::default(), so the config value is effectively hardcoded to 5 and cannot be tuned via config.json.
  • InterruptionType::DeadLoop has a fixed default severity of Critical (src/agentsight/src/interruption/types.rs), so every false positive is reported at the highest severity.

How can we reproduce it?

  1. Run agentsight trace with interruption detection enabled (default).
  2. Have any agent perform a normal multi-step task that issues 5+ consecutive calls to the same tool with different arguments (e.g. a shell/terminal tool running different commands).
  3. Observe a dead_loop / critical event with rule: tool_sequence_repetition even though the task progresses and completes.

Anything else?

Suggested fixes:

  1. Improve precision: require the same tool arguments/command to repeat (not just the same tool name) before flagging a dead loop. This needs RecentCallSummary to carry an argument fingerprint.
  2. Wire tool_sequence_repeat_threshold (and related loop-detector knobs) into config.json instead of always using LoopDetector::default() at the call site.
  3. Reconsider severity: name-only repetition could be reported at a lower severity, reserving critical for repetitions with identical arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component:sightsrc/agentsight/type:bugA confirmed defect or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions