feat: add configurable tool loop detection

This commit is contained in:
Peter Steinberger
2026-02-17 00:17:01 +01:00
parent dacffd7ac8
commit 076df941a3
14 changed files with 557 additions and 30 deletions

View File

@@ -138,6 +138,30 @@ export type MediaToolsConfig = {
export type ToolProfileId = "minimal" | "coding" | "messaging" | "full";
export type ToolLoopDetectionDetectorConfig = {
/** Enable warning/blocking for repeated identical calls to the same tool/params. */
genericRepeat?: boolean;
/** Enable warning/blocking for known no-progress polling loops. */
knownPollNoProgress?: boolean;
/** Enable warning/blocking for no-progress ping-pong alternating patterns. */
pingPong?: boolean;
};
export type ToolLoopDetectionConfig = {
/** Enable tool-loop protection (default: false). */
enabled?: boolean;
/** Maximum tool call history entries retained for loop detection (default: 30). */
historySize?: number;
/** Warning threshold before a warning-only loop classification (default: 10). */
warningThreshold?: number;
/** Critical threshold for blocking repetitive loops (default: 20). */
criticalThreshold?: number;
/** Global no-progress breaker threshold (default: 30). */
globalCircuitBreakerThreshold?: number;
/** Detector toggles. */
detectors?: ToolLoopDetectionDetectorConfig;
};
export type SessionsToolsVisibility = "self" | "tree" | "agent" | "all";
export type ToolPolicyConfig = {
@@ -235,6 +259,8 @@ export type AgentToolsConfig = {
exec?: ExecToolConfig;
/** Filesystem tool path guards. */
fs?: FsToolsConfig;
/** Runtime loop detection for repetitive/ stuck tool-call patterns. */
loopDetection?: ToolLoopDetectionConfig;
sandbox?: {
tools?: {
allow?: string[];
@@ -497,6 +523,8 @@ export type ToolsConfig = {
exec?: ExecToolConfig;
/** Filesystem tool path guards. */
fs?: FsToolsConfig;
/** Runtime loop detection for repetitive/ stuck tool-call patterns. */
loopDetection?: ToolLoopDetectionConfig;
/** Sub-agent tool policy defaults (deny wins). */
subagents?: {
/** Default model selection for spawned sub-agents (string or {primary,fallbacks}). */