5K

Continuous Autonomous Task Loop Pattern

Runs a loop where subagents pick the next task from a todo file, execute it in fresh context, commit it, and back off on rate limits

established Updated 2026-03-11 By Nikola Balic (@nibzard) Based on Internal Practice
View .md Edit on GitHub
Add to Pack
or

Saved locally in this browser for now.

Cite This Pattern
APA
Nikola Balic (@nibzard) (2026). Continuous Autonomous Task Loop Pattern. In *Awesome Agentic Patterns*. Retrieved September 28, 2026, from https://agentic-patterns.com/patterns/continuous-autonomous-task-loop-pattern
BibTeX
@misc{agentic_patterns_continuous-autonomous-task-loop-pattern,
  title = {Continuous Autonomous Task Loop Pattern},
  author = {Nikola Balic (@nibzard)},
  year = {2026},
  howpublished = {\url{https://agentic-patterns.com/patterns/continuous-autonomous-task-loop-pattern}},
  note = {Awesome Agentic Patterns}
}

Use when

  • A todo file holds discrete, well-defined tasks
  • Manual task selection and Git commits slow down work
  • Rate limits interrupt long agent sessions

Avoid when

  • Tasks are complex or poorly defined
  • Each task decision needs human oversight
  • Elevated execution permissions are not allowed

Problem

Traditional development workflows require constant human intervention for task management:

  • Manual Task Selection: Developers spend time deciding what to work on next from todo lists
  • Context Switching Overhead: Moving between different types of tasks interrupts flow state
  • Rate Limit Interruptions: API rate limits break development momentum and require manual waiting
  • Repetitive Git Operations: Each task completion requires manual staging, committing, and status checking
  • Error Recovery: Failed tasks need manual diagnosis and restart

This manual orchestration reduces overall productivity and prevents developers from focusing on higher-level problem solving.

Solution

Implement a continuous autonomous loop that handles task selection, execution, and completion without human intervention. This pattern operationalizes the ReAct paradigm (Thought → Action → Observation) as a continuous execution cycle:

  1. Fresh Context Per Iteration: Each task starts with a clean context to avoid contamination
  2. Autonomous Task Selection: Use specialized subagents to pick the next appropriate task
  3. Automated Git Management: Handle commits and status updates through dedicated subagents
  4. Intelligent Rate Limit Handling: Detect rate limits and implement exponential backoff
  5. Stream-Based Progress Tracking: Real-time feedback through JSON streaming
  6. Configurable Execution Limits: Safety bounds to prevent runaway execution

The pattern operates in a continuous loop until stopped manually or reaching iteration limits.

Example

sequenceDiagram participant Script as Autonomous Script participant TaskAgent as Task Master Subagent participant MainAgent as Main Agent participant GitAgent as Git Master Subagent participant System as File System loop Continuous Task Processing Script->>TaskAgent: Select next task from TODO.md TaskAgent-->>Script: "Implement user authentication" Script->>MainAgent: Execute task autonomously Note over MainAgent: --dangerously-skip-permissions<br/>Fresh context, focused execution MainAgent->>System: Implement code changes MainAgent-->>Script: Task completed successfully Script->>GitAgent: Commit changes GitAgent->>System: git add, commit with message GitAgent-->>Script: Changes committed alt Rate Limit Detected Script->>Script: Exponential backoff wait Note over Script: Intelligent delay before retry end Script->>Script: Update progress counters Note over Script: Continue to next iteration end

How to use it

Prerequisites

  • CLI agent tool (Claude Code, etc.) with autonomous execution capabilities
  • Git repository with TODO.md or similar task file
  • JSON parsing tools (jq) for stream processing

Implementation Steps

  1. Task File Setup: Create structured todo file with discrete, actionable tasks
  2. Configure Loop Script: Set iteration limits and rate limit handling parameters
  3. Subagent Configuration: Define specialized agents for task selection and git operations
  4. Safety Configuration: Set appropriate permission levels and monitoring
  5. Launch Loop: Start autonomous execution with configured parameters

Key Configuration Options

# Example configuration
MAX_ITERATIONS=50           # Safety limit
CLAUDE_CLI="claude"         # CLI tool choice
RATE_LIMIT_BACKOFF=300     # Seconds to wait on rate limit
STREAM_JSON=true           # Real-time progress tracking

Safety Considerations

  • Always set maximum iteration limits
  • Use version control for rollback capability
  • Monitor execution logs for unexpected behavior
  • Start with small task batches to validate behavior

Trade-offs

Pros:

  • Complete Autonomy: Eliminates manual task orchestration overhead
  • Continuous Progress: Maintains development momentum without human intervention
  • Fresh Context: Each task gets clean reasoning context
  • Intelligent Error Handling: Automated recovery from common failure modes
  • Git Automation: Maintains clean commit history automatically
  • Rate Limit Resilience: Handles API constraints gracefully

Cons/Considerations:

  • Reduced Human Oversight: Less control over individual task decisions
  • Permission Requirements: Needs elevated execution permissions for autonomy
  • Runaway Risk: Potential for unintended extensive execution
  • Task Quality Dependency: Effectiveness depends on well-structured task definitions
  • Limited Complex Problem Solving: Best for discrete, well-defined tasks
  • Resource Consumption: Continuous execution uses computational resources

References