This document outlines the implementation details of execution limits in SalmonLoop to prevent runaway processes and manage resource consumption.
Execution limits are enforced at multiple levels to ensure system stability and defensive operation.
- Total Execution Timeout: Maximum time allowed for a single
SalmonLooprun. - Phase Timeout: Individual phases (Plan, Patch, Verify) have their own configurable timeouts.
- LLM Call Timeout: Protection against hanging API calls.
- Max Retries: The loop will terminate after a specified number of failed attempts to fix an issue.
- Context Shrinking Limits: Limits on how many times context window reduction can occur.
- Memory Monitoring: The loop monitors its own memory usage and terminates if thresholds are exceeded.
- Diff Size Limits: Safety check before applying patches to prevent massive unintended changes.
Limits are configured via ExecutionLimits in src/core/types.ts.
export interface ExecutionLimits {
maxRetries: number;
totalTimeoutMs: number;
phaseTimeoutMs: number;
maxDiffSizeBytes: number;
memoryLimitBytes: number;
}The Monitor class is responsible for tracking these limits during execution. If any limit is breached:
- Current operations are halted.
- The system attempts a safe rollback (if in a worktree or if checkpointing is active).
- A detailed error is returned via the
SalmonLoopResult.
In Stage 10, we've enhanced these limits with:
- Dirty Workspace Protection: Ensuring existing changes are stashed or isolated in worktrees.
- Failure Rate Monitoring: Tracking checkpoint and cleanup failures to identify infrastructure issues.