Overview
Headless mode runs OpenHands without the interactive terminal UI, making it ideal for:
- CI/CD pipelines
- Automated scripting
- Integration with other tools
- Batch processing
Requirements
- Must specify a task with
--task or --file
Headless mode always runs in always-approve mode. The agent will execute all actions without any confirmation. This cannot be changed—--llm-approve is not available in headless mode.
Basic Usage
JSON Output Mode
The --json flag enables structured JSONL (JSON Lines) output, streaming events as they occur:
Each line is a JSON object representing an agent event:
Use Cases for JSON Output
- CI/CD pipelines: Parse events to determine success/failure
- Automated processing: Feed output to other tools
- Logging: Capture structured logs for analysis
- Integration: Connect OpenHands with other systems
Example: Capture Output to File
See Also