SingleFixTask

Execution GPT-4 Preferred

Analyzes a provided log file for errors and attempts to fix them in the codebase without executing commands. Performs one-pass analysis and fix generation.

Input vs. Output

⚙️ TaskConfig.json
{
  "task_type": "SingleFix",
  "logFile": "build/logs/compilation_errors.log",
  "task_description": "Fix compilation errors",
  "task_dependencies": ["CompileTask"],
  "state": "pending"
}
👁️ User UI

✓ Analysis Complete

Analyzed log file: build/logs/compilation_errors.log

Found 3 errors and generated fixes.

- Missing import: java.util.List
+ Added import statement
...
- Type mismatch in method signature
+ Corrected parameter types

Transcript: SingleFixTask_full_report_20240115143022.md

Configuration Parameters

Field Name Type Default Description
logFile Required String The path to the log file containing errors to analyze and fix.
task_description String null Optional description of the task for context and logging.
task_dependencies List<String> [] List of task names that must complete before this task executes.
state TaskState pending Current execution state of the task (pending, running, completed, failed).

Task Characteristics

  • Side-Effect Safe: Does not execute commands or modify files directly during analysis.
  • Single Pass: Analyzes the log file once and generates fixes in a single pass.
  • Model Requirement: GPT-4 or equivalent for accurate error analysis and fix generation.
  • Token Usage: Medium (depends on log file size, typically 2K-10K tokens).
  • Dependencies: Typically follows compilation or build tasks that generate error logs.

Output

The task generates a markdown transcript file containing:

  • Analysis of errors found in the log file
  • Proposed fixes with code diffs
  • File paths and line numbers affected
  • Execution summary and any errors encountered

Type Configuration

Static settings defined when the task is registered:

class SingleFixTaskTypeConfig(
    name: String? = "SingleFix",
    model: ApiChatModel? = null
) : TaskTypeConfig(name, name, model)
  • name: Task identifier (default: "SingleFix")
  • model: LLM model instance for error analysis (default: orchestration config model)

Runtime Configuration

Dynamic parameters provided at execution time:

class SingleFixTaskExecutionConfigData(
    @Description("The path to the log file containing errors")
    var logFile: String? = null,
    task_description: String? = null,
    task_dependencies: List<String>? = null,
    state: TaskState? = null
) : TaskExecutionConfig(...)

Task Process Lifecycle

1

Initialization

Validates the log file path and ensures the file exists. Loads project context and initializes the LLM model.

2

Log Analysis

Reads the log file and parses error messages. Identifies affected files and error types (syntax, type mismatch, missing imports, etc.).

3

Fix Generation

Uses the LLM to generate patch-based fixes for each error. Validates fixes against the codebase structure.

4

Transcript Generation

Creates a detailed markdown transcript with analysis results, proposed fixes, and execution summary.

5

Completion

Returns success status and provides link to the generated transcript for user review.

Error Handling

  • Missing Log File: Throws IllegalArgumentException with descriptive message.
  • Invalid Configuration: Validation fails if logFile is null or blank.
  • Execution Errors: Caught and logged; stack trace included in transcript if autoFix is enabled.
  • Recovery: Task completes with error status; user can review transcript and retry with corrected configuration.

Adding to OrchestrationConfig

Copy-pasteable Kotlin code to register this task:

import com.simiacryptus.cognotik.plan.tools.run.SingleFixTask

// In your OrchestrationConfig setup:
val singleFixTask = SingleFixTask(
    orchestrationConfig = this,
    planTask = SingleFixTask.SingleFixTaskExecutionConfigData(
        logFile = "build/logs/compilation_errors.log",
        task_description = "Fix compilation errors from build",
        task_dependencies = listOf("CompileTask")
    )
)

// Register in task orchestrator
taskOrchestrator.registerTask(
    SingleFixTask.SingleFix,
    SingleFixTask.SingleFixTaskTypeConfig(
        name = "SingleFix",
        model = orchestrationConfig.instance(ApiChatModel.GPT4)
    )
)

Prompt Segment

The text injected into the LLM prompt:

Analyze the log file '{logFile}' and fix any errors found.

This prompt is combined with the project context (file tree, code snippets) and the log file contents to guide the LLM in generating appropriate fixes.

Typical Workflow

  1. A build or compilation task generates an error log file
  2. SingleFixTask is triggered with the log file path
  3. Task analyzes errors and generates fixes using the LLM
  4. Fixes are presented in a transcript for user review
  5. User can apply fixes manually or integrate with automated patching

Configuration Example

{
  "tasks": [
    {
      "type": "CompileTask",
      "config": {
        "command": "gradle build"
      }
    },
    {
      "type": "SingleFixTask",
      "config": {
        "logFile": "build/logs/compilation_errors.log",
        "task_dependencies": ["CompileTask"],
        "task_description": "Analyze and fix compilation errors"
      }
    }
  ]
}