tektoncd / tektoncd/pipelines-as-code

feat: Include Kubernetes Events for failed tasks in LLM context

Open
#2,304 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement llm priority/low
Dominant language
Go
Stars
214
Forks
144
Avg merge
2d 11h
Merged PRs (30d)
27

Description

Description

Include Kubernetes Events associated with failed TaskRuns in the LLM context to provide richer diagnostic information for AI-powered analysis.

Context

This was suggested in PR #2292 review comment: https://github.com/openshift-pipelines/pipelines-as-code/pull/2292#discussion_r2468174103

Currently, the LLM context for failed tasks (pkg/llm/context/assembler.go:232-248) includes:

  • Task name, reason, message
  • Log snippet
  • Display name and completion time

But does not include Kubernetes Events, which can provide valuable diagnostic information such as:

  • Pod scheduling issues
  • Container failures
  • Resource constraints (memory/CPU limits)
  • Image pull errors
  • Volume mount issues
  • Other system-level failures

Proposed Changes

  1. Extend TaskInfos struct (pkg/apis/pipelinesascode/v1alpha1/types.go:72):

    type TaskInfos struct {
        Name           string       `json:"name"`
        Message        string       `json:"message,omitempty"`
        LogSnippet     string       `json:"log_snippet,omitempty"`
        Reason         string       `json:"reason,omitempty"`
        DisplayName    string       `json:"display_name,omitempty"`
        CompletionTime *metav1.Time `json:"completion_time,omitempty"`
        Events         []Event      `json:"events,omitempty"`  // NEW
    }
    
  2. Update CollectFailedTasksLogSnippet (pkg/kubeinteraction/status/task_status.go:76):

    • For each failed TaskRun, call kinteract.GetEvents(ctx, namespace, "TaskRun", taskRunName)
    • Add events to the TaskInfos struct
  3. Update buildErrorContent (pkg/llm/context/assembler.go:232):

    • Include events in the failedTask map when building context

Benefits

  • Better root cause analysis for failures related to infrastructure/platform issues
  • LLM can distinguish between application failures vs platform failures
  • More comprehensive context for suggesting fixes

Implementation Notes

The infrastructure already exists:

  • GetEvents method available in pkg/kubeinteraction/events.go:11
  • Already used for Repository and PipelineRun objects in pkg/cmd/tknpac/describe/describe.go:190,207

Priority

This is a future enhancement and not blocking for the initial LLM analysis feature.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading CollectFailedTasksLogSnippet in pkg/kubeinteraction/status/task_status.go and the TaskInfos definition in pkg/apis/pipelinesascode/v1alpha1/types.go. Review GetEvents in pkg/kubeinteraction/events.go and buildErrorContent in pkg/llm/context/assembler.go. Done means events from failed TaskRuns are carried in TaskInfos and appear in the failed-task LLM context.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, devops
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.