Learn R Programming

aisdk (version 1.1.0)

auto_fix: Autonomous Data Science Pipelines

Description

Self-healing runtime for R code execution. Implements a "Hypothesis-Fix-Verify" loop that feeds error messages, stack traces, and context back to an LLM for automatic error correction.

Execute R code with automatic error recovery using LLM assistance. When code fails, the error is analyzed and a fix is attempted automatically.

Usage

auto_fix(
  expr,
  model = NULL,
  max_attempts = 3,
  context = NULL,
  verbose = TRUE,
  memory = NULL
)

Value

The result of successful execution, or an error if all attempts fail.

Arguments

expr

The R expression to execute.

model

The LLM model to use for error analysis (default: from options).

max_attempts

Maximum number of fix attempts (default: 3).

context

Optional additional context about the code's purpose.

verbose

Print progress messages (default: TRUE).

memory

Optional ProjectMemory object for learning from past fixes.

Examples

Run this code
if (FALSE) {
# Simple usage - auto-fix a data transformation
result <- auto_fix({
  df <- read.csv("data.csv")
  df %>%
    filter(value > 100) %>%
    summarize(mean = mean(value))
})

# With context for better error understanding
result <- auto_fix(
  expr = {
    model <- lm(y ~ x, data = df)
  },
  context = "Fitting a linear regression model to predict sales"
)
}

Run the code above in your browser using DataLab