graphlit-client
Version:
Graphlit API Client for TypeScript
31 lines (30 loc) • 1.15 kB
TypeScript
import type { TurnResult, StuckEvaluation } from "../types/agent.js";
/**
* Stateful detector that tracks patterns across harness turns and identifies
* when the agent is stuck in a loop.
*
* Uses a two-strike system: first detection of a pattern triggers an intervention
* (the harness injects a diagnostic prompt). If the same pattern is detected again,
* the harness gives up and terminates.
*/
export declare class StuckDetector {
private toolCallHistory;
private responseHistory;
private errorHistory;
private emptyTurnCount;
private interventions;
/**
* Evaluate a completed turn for stuck patterns.
* Checks patterns in priority order: repeating tools → repeating responses →
* error loop → empty turns.
*/
evaluate(turn: TurnResult): StuckEvaluation;
/**
* Two-strike system: first occurrence triggers intervention, second gives up.
*/
private strike;
/** Reset all state (for fresh runs). */
reset(): void;
/** Replay existing turn results to rebuild state (for resume scenarios). */
initializeFromHistory(turnResults: TurnResult[]): void;
}