Tasks & Checkpoints
Tasks are the core unit of work in Kage. A task represents a goal you want an agent to achieve, with built-in checkpointing, iteration limits, and success/abort criteria.
Task Lifecycle
┌─────────┐
│ Pending │
└────┬────┘
│ Agent picks up
▼
┌─────────┐
┌─────│ Running │─────┐
│ └────┬────┘ │
│ │ │
User pauses │ Iteration limit
│ │ │
▼ │ ▼
┌────────┐ │ ┌────────┐
│ Paused │◄─────┼─────│ Paused │
└────┬───┘ │ └────┬───┘
│ │ │
User resumes │ User resumes
│ │ with guidance
└──────────┼──────────┘
│
┌───────────────┼───────────────┐
│ │ │
Success Abort User
criteria criteria cancels
met met
│ │ │
▼ ▼ ▼
┌───────────┐ ┌────────┐ ┌───────────┐
│ Completed │ │ Failed │ │ Cancelled │
└───────────┘ └────────┘ └───────────┘
Creating Tasks
Basic Example
With Options
Iterations
An iteration is one cycle of the agent working on the task. Kage tracks iterations to:
- Prevent runaway agents — Agents pause at the iteration limit
- Enable checkpointing — Save state at regular intervals
- Allow human review — Opportunity to provide guidance
Iteration Limits
# Set max iterations (default: 10)
When the limit is reached:
- Agent pauses automatically
- Checkpoint is saved
- You can review progress and resume with additional iterations
Resuming with More Iterations
Checkpoints
Checkpoints capture the agent’s state at a point in time, allowing:
- Resume from interruption — Recover from crashes or pauses
- Review progress — See what the agent has done
- Provide guidance — Give feedback for the next phase
Automatic Checkpoints
# Checkpoint every N iterations (default: 2)
Managing Checkpoints
# List checkpoints for a task
# View checkpoint details
# View a specific checkpoint
# Clean up old checkpoints (keep last 3)
What’s in a Checkpoint?
- Agent context and memory
- Files modified so far
- Iteration count
- Task progress state
- Timestamp
Success Criteria
Define conditions that mark a task as complete:
Available Criteria
| Criteria | Format | Description |
|---|---|---|
| Pattern match | pattern:REGEX | Match regex in agent output |
| File exists | file-exists:PATH | Check if file was created |
| File contains | file-contains:PATH:PATTERN | Check file for pattern |
| Command success | command:CMD | Run command, check exit code |
| Tests pass | tests-pass | Auto-detect and run test suite |
Examples
# Complete when tests pass
# Complete when specific file is created
# Complete when agent says it's done
# Complete when build succeeds
# Multiple criteria (all must be met)
Abort Criteria
Define conditions that should stop the task:
Available Criteria
| Criteria | Format | Description |
|---|---|---|
| Error count | error-count:MAX:PATTERN | Abort if errors exceed threshold |
| Repeated output | repeated-output:MIN:WINDOW | Detect stuck loops |
| Output contains | output-contains:PHRASE1,PHRASE2 | Match abort phrases |
| No progress | no-progress:ITERATIONS | Abort if no file changes |
Examples
# Abort after 5 compilation errors
# Abort if same output repeats 3 times in 10 iterations
# Abort on specific error messages
# Abort if no file changes for 5 iterations
Task Dependencies
Create tasks that depend on other tasks:
# Create a parent task
# Returns: task_abc123
# Create dependent task
# Create another dependent
Dependent tasks remain pending until their dependencies are completed.
Priority
Tasks are scheduled by priority (0-255, higher = more urgent):
# High priority
# Normal priority (default: 100)
# Low priority / batch work
Task Status
| Status | Description |
|---|---|
pending | Waiting to be picked up or for dependencies |
running | Agent is actively working |
paused | Paused by user or iteration limit |
completed | Success criteria met |
failed | Abort criteria met or error |
cancelled | Cancelled by user |
Viewing Tasks
# List all tasks
# Filter by status
# Filter by namespace
# Show task details
Workflow Examples
Simple Fix
Guarded Feature Development
Multi-Stage Pipeline
# Stage 1: Research
# Returns: task_1
# Stage 2: Implementation (depends on Stage 1)
# Returns: task_2
# Stage 3: Documentation (depends on Stage 2)
Overnight Batch Work