Skip to content

Jobs

A Job represents a single execution of an agent. Each time an agent runs—whether triggered by a schedule, manual invocation, or trigger event—herdctl creates a job to track that execution from start to finish.

PropertyTypeDescription
idstringUnique job identifier (UUID)
agentstringName of the agent executing this job
schedulestringSchedule that triggered this job (if scheduled)
statusenumCurrent job status
exitReasonenumWhy the job ended (set on completion)
sessionIdstringClaude session ID for resume capability
startedAttimestampWhen the job started execution
completedAttimestampWhen the job finished (success or failure)
outputstringPath to job output file (JSONL format)
errorstringError message if job failed

Jobs progress through a defined lifecycle:

PENDING → RUNNING → COMPLETED
→ FAILED
→ CANCELLED
StatusDescription
runningJob is currently executing
completedJob finished successfully
failedJob terminated due to an error
cancelledJob was manually stopped

When a job completes, it records an exit reason explaining why it ended:

Exit ReasonDescription
successJob completed all tasks successfully
errorJob failed due to an error
timeoutJob exceeded its configured time limit
manual_cancelJob was cancelled by user intervention
{
"id": "job-550e8400-e29b",
"agent": "bragdoc-coder",
"schedule": "daily-standup",
"status": "completed",
"exitReason": "success",
"sessionId": "sess-a1b2c3d4",
"startedAt": "2024-01-15T09:00:00Z",
"completedAt": "2024-01-15T09:15:32Z",
"output": "~/.herdctl/jobs/job-550e8400-e29b/output.jsonl"
}

Job output is stored in JSONL (JSON Lines) format, where each line is a separate JSON object representing an event during execution:

{"type":"start","timestamp":"2024-01-15T09:00:00Z","message":"Job started"}
{"type":"tool_use","timestamp":"2024-01-15T09:00:05Z","tool":"Read","file":"src/index.ts"}
{"type":"output","timestamp":"2024-01-15T09:00:10Z","content":"Reading file contents..."}
{"type":"tool_use","timestamp":"2024-01-15T09:00:15Z","tool":"Edit","file":"src/index.ts"}
{"type":"complete","timestamp":"2024-01-15T09:15:32Z","exitReason":"success"}
TypeDescription
startJob execution began
outputText output from Claude
tool_useTool invocation
tool_resultTool execution result
errorError occurred
completeJob finished
Terminal window
# Stream job output
herdctl jobs logs <job-id>
# Follow output in real-time
herdctl jobs logs <job-id> --follow
# Show only errors
herdctl jobs logs <job-id> --level error
# Export to file
herdctl jobs logs <job-id> > job-output.log
Terminal window
# List all jobs
herdctl jobs list
# Filter by status
herdctl jobs list --status running
herdctl jobs list --status completed
herdctl jobs list --status failed
herdctl jobs list --status cancelled
# Filter by agent
herdctl jobs list --agent bragdoc-coder
# Filter by time range
herdctl jobs list --since 24h
herdctl jobs list --since "2024-01-15"
Terminal window
# Show full job details
herdctl jobs show <job-id>
# Show job in JSON format
herdctl jobs show <job-id> --json
Terminal window
# Cancel a running job
herdctl jobs cancel <job-id>
# Cancel all jobs for an agent
herdctl jobs cancel --agent bragdoc-coder

Jobs store their Claude session ID, enabling resume after interruption. This is useful when:

  • Network connectivity was lost
  • The job was manually paused
  • The system was restarted during execution
Terminal window
# Resume a specific job
herdctl jobs resume <job-id>
# Resume with additional context
herdctl jobs resume <job-id> --prompt "Continue from where you left off"

Jobs are persisted to disk for history and recovery. See State Management for details on storage backends and configuration.

~/.herdctl/
├── jobs/
│ └── <job-id>/
│ ├── job.json # Job metadata
│ └── output.jsonl # Execution output
└── logs/
└── <agent>/
└── <job-id>.log # Agent-specific logs