Headless Methods
Starting a Headless Task
- prompt (
str
): Natural language instruction for the AI - editable_files (
List[str]
): Paths to files the AI may modify - readonly_files (
List[str]
, optional): Paths to files the AI may read but not change - task_id (
str
, optional): Custom identifier for the task
Checking Task Status
- task_id (
str
): The task identifier returned bycode_headless()
Quick Headless Example
Run the real headless example script included in the examples:- Create
src/calculator.py
- Start an asynchronous coding task with
code_headless()
- Poll for status and print the diff when completed
Advanced Usage
Tracking Multiple Tasks
Integration with Web Applications
Here’s how you might use headless mode in a web application:Best Practices
Task Management
- Generate unique task IDs if not provided
- Store task information for later reference
- Implement timeouts for polling to avoid infinite loops
- Use a proper task queue system for production applications
Error Handling
Performance Considerations
- For CPU-bound applications, limit the number of concurrent tasks
- Consider using a task queue system like Celery for production use
- Implement rate limiting to avoid exceeding API rate limits
- Store task results in a database for persistence