Inspiration

In modern software development, CI/CD pipeline failures block deployments and slow down engineering velocity. Developers often waste hours digging through hundreds of lines of raw logs just to find a single missing dependency or syntax error. We wanted to build an AI agent that doesn't just answer questions, but autonomously acts as an SRE—finding the failing job, reading the real logs, and diagnosing the root cause instantly.

What it does

The GitLab Pipeline Fixer Agent is a Conversational AI that autonomously diagnoses pipeline failures. When a user provides a GitLab Project ID and Pipeline ID, the agent:

  1. Calls the GitLab API to find the exact job that failed within the pipeline.
  2. Fetches the raw execution trace/logs from the GitLab runner for that specific job.
  3. Analyzes the logs, identifies the root cause (e.g., a missing package-lock.json for npm ci), and provides actionable, step-by-step remediation instructions to the developer.

How we built it

  • Google Cloud Agent Builder: We used Gemini to orchestrate the agent's logic, allowing it to autonomously plan and execute multi-step API calls.
  • GitLab MCP Proxy (Cloud Run): We built a Python-based secure proxy deployed on Google Cloud Run. This proxy acts as a secure bridge, injecting the GITLAB_TOKEN server-side so credentials are never exposed to the LLM.
  • OpenAPI Schema: We defined a custom OpenAPI v3 schema that acts as the "Model Context Protocol" (MCP), teaching the agent exactly how to interact with our Cloud Run proxy to fetch pipeline jobs and traces.

Challenges we ran into

One major challenge was dealing with 64-bit integers. GitLab job IDs are massive numbers (e.g., 14731744756). Initially, the OpenAPI schema treated these as standard 32-bit integers, which caused integer overflow parsing errors, resulting in the agent receiving empty data. We solved this by architecting the Cloud Run proxy to cast all massive IDs into strings before returning them to the agent, ensuring perfect data fidelity.

Accomplishments that we're proud of

We successfully built a true autonomous agent. It doesn't rely on hardcoded paths; if you give it a pipeline with 10 jobs where only the 4th one failed, the agent intelligently searches the array, identifies the failure, and extracts only the relevant trace. We are incredibly proud of achieving this seamless "Action -> Observation -> Diagnosis" loop.

What we learned

We learned a massive amount about how Google Cloud Conversational Agents parse OpenAPI schemas. We learned how to write strict, LLM-optimized OpenAPI descriptions so the agent knows exactly which path parameters to use. We also learned how to securely architect API proxies using Cloud Run so that third-party LLMs can interact with secure services without ever touching raw API tokens.

What's next for GitLab Pipeline Fixer Agent

The next step is proactive remediation. We want to extend the agent's capabilities so that after diagnosing a failure, it can automatically create a GitLab Merge Request with the suggested code fix!

Built With

Share this project:

Updates