Introduction
Every developer wants their code to pass the build and tests without problems. However, build failures are a normal part of software development. A missing dependency, a failing unit test, an incorrect configuration, or a compilation error can stop a continuous integration (CI) pipeline.
When a build fails, developers usually open the CI logs, search for the error, check the affected files, and try to identify the cause. This process can take time, especially when a project has many tests and several build steps.
GitHub agentic workflows offer an approach to automating parts of this investigation. Instead of running only predefined commands, an AI agent can examine available information, identify possible causes, and suggest the next steps.
In this article, we will learn how agentic workflows can help investigate CI failures, how to build a practical failure-analysis workflow, and what developers should consider before using AI in their development pipelines.
What Are GitHub Agentic Workflows?
A traditional GitHub Actions workflow follows predefined instructions. For example, it can restore dependencies, build a .NET application, run tests, and stop when a command fails.
An agentic workflow adds an AI-assisted investigation step to this process. Depending on the tools and permissions available, an agent can inspect failure information, analyze logs, examine relevant source files, and prepare a report.
The goal is not to replace the CI pipeline. It is to help developers understand why the pipeline failed.
For example, imagine that a .NET application fails because one unit test expects a result of 100, but the application returns 90.
A traditional workflow reports that the test failed. An AI-assisted investigation may explain the assertion mismatch, identify the relevant test, and suggest where to investigate the application logic.
The suggestion still needs to be checked by a developer.
It is also important to distinguish the general idea of an agentic workflow from a specific GitHub feature. The available implementation depends on the agent, its integration with GitHub Actions, and the permissions provided to it.
Why Automate CI Failure Analysis?
Developers often spend time investigating problems that follow familiar patterns.
Common CI failures include:
- Compilation errors caused by incorrect code.
- Unit tests that fail after a code change.
- Missing or incompatible dependencies.
- Incorrect environment variables.
- Formatting or linting errors.
- Integration tests that cannot connect to a required service.
- Build failures caused by configuration differences.
Some failures are easy to understand, while others require checking several files and logs.
Automated analysis can help by collecting relevant information and presenting it in a consistent format.
For development teams, the main benefits are easier troubleshooting, faster access to useful error details, and less manual searching through long build logs.
However, an AI agent cannot always determine the root cause from the available information. It should clearly distinguish confirmed errors from possible explanations.
How an Agentic CI Failure Workflow Works
A typical workflow contains two parts: the normal CI pipeline and the failure-analysis process.
The normal pipeline builds the application and runs tests. If a step fails, a separate process collects the available failure information and sends it to an analysis tool.
The process can follow these steps:
- A developer pushes code or opens a pull request.
- GitHub Actions restores dependencies, builds the project, and runs tests.
- If a step fails, the workflow records the failure details.
- An analysis job collects relevant logs and error messages.
- An AI agent examines the information and prepares a report.
- The developer reviews the report and decides how to fix the problem.
This design keeps the build process separate from the AI investigation. If the analysis service is unavailable, the original build result should remain unchanged.
Step 1: Create a Basic CI Workflow
Start with a standard GitHub Actions workflow for a .NET application.
Create a file named .github/workflows/ci.yml in your repository.
name: .NET CI
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore MyApplication.sln
- name: Build application
run: dotnet build MyApplication.sln --no-restore
- name: Run tests
run: dotnet test MyApplication.sln --no-buildReplace MyApplication.sln with the actual solution file name in your repository. Also select a .NET SDK version supported by your project and available in the build environment.
This workflow performs three main operations.
The restore step downloads the required dependencies. The build step compiles the application. The test step runs the automated tests.
If compilation or testing fails, GitHub Actions marks the job as failed.
This is the foundation for failure analysis. The next step is to collect useful information about the failure.
Step 2: Capture the Failure Details
A useful failure report should contain enough information to understand the problem without collecting unnecessary data.
For a .NET project, the most useful details usually include the failed command, the error message, the test name if applicable, and the relevant section of the build log.
You can update the test step to save its output.
- name: Run tests
id: tests
continue-on-error: true
run: |
dotnet test MyApplication.sln --no-build \
--logger "console;verbosity=normal" \
2>&1 | tee test-results.log
- name: Upload test log
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results.log
if-no-files-found: ignore
- name: Fail job when tests fail
if: steps.tests.outcome == 'failure'
run: exit 1The continue-on-error: true setting allows the workflow to upload the test log before the job is marked as failed.
The final step restores the expected failure status when the test step fails.
This example captures test output. It does not automatically capture every possible build failure. If dependency restoration or compilation fails, those steps need their own log-capture strategy.
For more complex pipelines, consider saving separate logs for restore, build, and test operations.
Step 3: Add an AI Analysis Step
Once the failure information is available, an AI analysis service can examine it and produce a readable report.
The exact implementation depends on the AI tool you choose. A service might accept a prompt and log content through an API, while another integration may allow an agent to inspect selected repository files.
A useful analysis prompt could look like this:
You are helping investigate a failed CI pipeline.
Review the supplied build or test output.
Return the following information:
1. Summary of the failure.
2. Exact error message.
3. Most likely cause.
4. Evidence from the supplied logs.
5. Files or configuration that may need investigation.
6. Suggested steps to reproduce the problem.
7. Recommended fix, if the evidence supports one.
Separate confirmed facts from possible causes.
Do not invent missing information.
Do not claim that a fix has been tested unless test results
confirm it.
Do not expose secrets or repeat sensitive values found in logs.
Join the conversation! Your thoughts help the community grow.