Skip to main content

AI Error Analysis

Latest release ai-error-analysis 0.2.1

The Gruntwork-provided AI Error Analysis hook explains why a Terragrunt run failed and how to fix it. The model is given each failed unit's error together with the Terragrunt and any OpenTofu/Terraform files of the units in the run, so it can trace an error back to the code that caused it. When no unit reports an error, it is given the output of the failed steps instead.

Usage​

repository {
error_hook "ai-error-analysis" {
commands = ["plan", "apply"]
on_errors = ["."]
execute = ["pipelines", "hook", "ai-error-analysis@v0.2"]

env {
PIPELINES_HOOK_AI_ERROR_ANALYSIS_PROVIDER = "<REQUIRED>"
PIPELINES_HOOK_AI_ERROR_ANALYSIS_MODEL = "<REQUIRED>"
}
}
}

PIPELINES_HOOK_AI_ERROR_ANALYSIS_API_KEY is a secret. Supply it from execute, as Authentication & Secrets describes.

Outputs​

The hook posts its analysis on the pull or merge request:

AI Error Analysis CommentAI Error Analysis Comment

The summary line states the cause. Below it, each distinct cause gets one finding, numbered when there is more than one. A finding names the units it affects, the issue, and the fix.

Inputs​

Configure inputs in the hook's env block.

Required

VariableDescription
PIPELINES_HOOK_AI_ERROR_ANALYSIS_PROVIDERWho serves the model. For anthropic, the hook configures the model to check Terragrunt fixes against the Terragrunt docs, through their MCP server. One of anthropic, openrouter.
PIPELINES_HOOK_AI_ERROR_ANALYSIS_MODELFor example: 'claude-sonnet-5' on anthropic, 'anthropic/claude-sonnet-5' on openrouter.
PIPELINES_HOOK_AI_ERROR_ANALYSIS_API_KEYAPI key for the chosen provider.

Optional

VariableDescription
PIPELINES_HOOK_AI_ERROR_ANALYSIS_MAX_OUTPUT_TOKENSMost tokens the model may write, thinking included. Defaults to 4000.
PIPELINES_HOOK_AI_ERROR_ANALYSIS_LOG_LEVELLog verbosity. A more verbose PIPELINES_LOG_LEVEL overrides it. One of trace, debug, info, warning, error, fatal, panic. Defaults to info.