AutoFixTask
Executes shell commands and automatically repairs failures using LLM-driven patch generation. Ideal for CI/CD pipelines, automated builds, and self-healing infrastructure.
Category: Execution
Side-Effect: Destructive
Model: GPT-4 Preferred
AutoFixTaskExecutionConfigData.json
JSON
{
"commands": [
{
"command": ["./gradlew", "test"],
"workingDir": "services/api"
}
],
"task_description": "Run API tests and fix failures"
}
→
Session UI / Transcript
RENDERED
# Self-Healing Task Execution
✖ Command Failed: ./gradlew test
Analyzing stack trace...
ℹ Applying Patch to UserAuth.kt:142
✔ Retrying... Success.
Live Results Showcase
Explore actual artifacts, logs, and generated patches from the AutoFixTask test workspace.
Execution Configuration
| Field | Type | Description |
|---|---|---|
commands * |
MutableList<CommandWithWorkingDir> |
A list of commands to execute. Each contains a command (List of strings) and an optional workingDir. |
task_description |
String |
Human-readable description of the intent of this execution. |
task_dependencies |
List<String> |
IDs of tasks that must complete before this one starts. |
CommandWithWorkingDir
| Field | Type | Description |
|---|---|---|
command * | MutableList<String> | The command and its arguments (e.g. ["npm", "install"]). |
workingDir | String? | Relative path of the working directory. |
Type Configuration
| Field | Type | Default |
|---|---|---|
model |
ApiChatModel |
null (Uses system default smart model) |
promptTemplate |
String |
The system prompt used to guide the self-healing logic. |
Task Lifecycle
- Initialization: Resolves tool executables from
UserSettingsand validates the working directories. - Execution: Launches
CmdPatchAppto run the specified shell commands. - Monitoring: Captures STDOUT/STDERR and streams it to a multi-format transcript (MD, HTML, PDF).
- Self-Healing: If a command returns a non-zero exit code, the task invokes the LLM with the error context to generate and apply source code patches.
- Verification: Re-runs the command to verify the fix.
- Completion: Finalizes the report and updates the session state. Supports interactive approval if
autoFixis disabled.
Embedded Usage (UnifiedHarness)
Use the UnifiedHarness to run AutoFix as a headless agent in CI/CD pipelines or Gradle tasks.
// 1. Define the Execution Configuration
val executionConfig = AutoFixTaskExecutionConfigData(
commands = mutableListOf(
CommandWithWorkingDir(
command = mutableListOf("./gradlew", "test"),
workingDir = "services/api"
)
),
task_description = "Run API tests and fix failures"
)
// 2. Run via Harness
harness.runTask(
taskType = AutoFixTask.AutoFix,
executionConfig = executionConfig,
workspace = File("./project-root"),
autoFix = true // Enable autonomous repair
)
Direct Task Instantiation
val task = AutoFixTask(
orchestrationConfig = orchestrationConfig,
planTask = AutoFixTaskExecutionConfigData(
commands = mutableListOf(
CommandWithWorkingDir(
command = mutableListOf("npm", "run", "build"),
workingDir = "frontend"
)
)
)
)
Prompt Segment
The following instructions are injected into the LLM context during healing:
SelfHealing - Run a command and automatically fix any issues that arise
* Specify the commands to be executed along with their working directories
* Each command's working directory should be specified relative to the root directory
* Provide the commands and their arguments in the 'commands' field
* Each command should be a list of strings
* Available commands:
{executables}