An agentic AI that automatically reads a failed CI build log, inspects the source code, diagnoses the root cause, and posts a fix recommendation to Slack — all autonomously.
Two versions: Claude API (cloud) and Qwen3 via Ollama (100% local, zero cost).
| Video | Title | Link |
|---|---|---|
| Part 1 | Agentic AI in DevOps — The Skill Every Cloud Engineer Needs in 2026 | Watch |
| Part 2 | Local LLM vs Cloud API for DevOps Agents — Which Should You Use in 2026? | Watch |
| Part 3 | Wire Your AI Agent to Real GitHub Actions | 🔜 |
Cloud Advocate · GK
Traditional DevOps automation executes what you tell it to execute. Agentic AI reasons, decides, and acts on its own.
Pipeline fails
↓
Agent reads the build log ← Perceive
↓
LLM identifies the failing ← Plan
test and decides which file to inspect
↓
Agent reads the source code ← Act
↓
LLM diagnoses root cause ← Observe
↓
Fix recommendation posted to Slack ← Report
↓
Loop repeats until job is done ← ↻ Agentic loop
The key insight: The LLM is the manager. The tools are the workers. The manager never does the work itself — it delegates to the right worker at the right time.
agent.py |
agent_local.py |
|
|---|---|---|
| Model | Claude Sonnet (Anthropic) | Qwen3:14b (Ollama) |
| Cost | ~$0.01 per run | $0.00 forever |
| Privacy | Cloud API | 100% local |
| Internet | Required | Not required |
| Setup | API key only | Ollama + GPU |
| Diagnosis | ✅ Correct | ✅ Correct |
| Enterprise safe | Check policy | Always safe |
- Python 3.12+
- WSL2 / Linux / macOS
- Anthropic API key → console.anthropic.com
# 1. Clone the repo
git clone https://github.com/cloudadvocate/devops-agent.git
cd devops-agent
# 2. Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Set your API key
export ANTHROPIC_API_KEY=sk-ant-your-key-herepython agent.py
# Or use your own CI log
python agent.py --log /path/to/build.logZero API cost. Zero data leaves your machine.
- Python 3.12+
- WSL2 / Linux / macOS
- Ollama installed on your machine
- GPU recommended (see hardware table below)
| VRAM | Recommended model | Pull command |
|---|---|---|
| CPU only | qwen3:8b (slow) | ollama pull qwen3:8b |
| 8GB | qwen3:8b | ollama pull qwen3:8b |
| 12GB | qwen3:14b ← sweet spot | ollama pull qwen3:14b |
| 16GB | qwen3:30b-a3b | ollama pull qwen3:30b-a3b |
| 24GB | qwen3:32b | ollama pull qwen3:32b |
# 1. Install Ollama → https://ollama.com
# 2. Pull the model
ollama pull qwen3:14b
# 3. Start Ollama server (keep this running)
ollama serve
# 4. Clone the repo and set up venv
git clone https://github.com/cloudadvocate/devops-agent.git
cd devops-agent
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtOllama runs on Windows. WSL2 needs to point to it:
# Find your Windows host IP
ip route | grep default | awk '{print $3}'
# Set the host (replace with your IP)
export OLLAMA_HOST=http://172.24.48.1:11434
# Verify connection
curl http://172.24.48.1:11434/api/tagsexport OLLAMA_HOST=http://YOUR_WINDOWS_IP:11434
python agent_local.py════════════════════════════════════════════════════════════
🤖 DevOps Pipeline Failure Agent
════════════════════════════════════════════════════════════
Model: claude-sonnet-4-20250514
Log: samples/failed_build.log
⟳ Agent thinking... (step 1)
🔧 Calling tool: read_build_log
⟳ Agent thinking... (step 2)
🔧 Calling tool: read_source_file (file_path='gateway.py')
⟳ Agent thinking... (step 3)
🔧 Calling tool: post_slack_summary
────────────────────────────────────────────────────────────
📬 Slack #devops-alerts
────────────────────────────────────────────────────────────
🔴 Build Failure Diagnosed
Root cause: Timeout threshold (5s) too low for Stripe API
Affected file: gateway.py · Severity: HIGH
Fix: Increase DEFAULT_TIMEOUT to 15s
_Diagnosed by Cloud Advocate DevOps Agent · 14:23:01_
────────────────────────────────────────────────────────────
Tokens used — input: 2,847 output: 312
════════════════════════════════════════════════════════════
════════════════════════════════════════════════════════════
🤖 DevOps Agent — Local Edition (Qwen3:14b)
════════════════════════════════════════════════════════════
Model: qwen3:14b via Ollama (100% local)
Cost: $0.00
⟳ Agent thinking... (step 1)
🔧 Calling tool: read_build_log
⟳ Agent thinking... (step 2)
🔧 Calling tool: read_source_file (file_path='gateway.py')
⟳ Agent thinking... (step 3)
🔧 Calling tool: post_slack_summary
────────────────────────────────────────────────────────────
📬 Slack #devops-alerts
────────────────────────────────────────────────────────────
🔴 Build Failure Diagnosed
Root cause: PaymentGateway returns timeout instead of raising
Affected file: gateway.py · Severity: HIGH
Fix: raise PaymentGatewayTimeout() instead of returning result
_Diagnosed by Cloud Advocate Local Agent (Qwen3:14b) · 08:40:34_
────────────────────────────────────────────────────────────
Powered by: qwen3:14b running locally via Ollama
════════════════════════════════════════════════════════════
Parts 1 & 2 ran the agent by hand against a canned log. Part 3 wires it into a real
GitHub Actions pipeline: a real pytest suite fails on your own Ubuntu machine
(registered as a self-hosted runner), and that failure automatically triggers
agent_local.py — fully local, zero API cost, diagnosis posted straight to the
Actions job summary.
git push
↓
GitHub Actions dispatches the job to YOUR Ubuntu runner
↓
pytest tests/ runs for real → test_payment_retry_logic fails
↓
if: failure() triggers agent_local.py --log ci_output.log
↓
Qwen3:14b (via Ollama, same box) reads the log + gateway.py
↓
Diagnosis + fix written to $GITHUB_STEP_SUMMARY and printed to the job logs
- Ollama installed and running (
ollama serve), withqwen3:14bpulled — see Option 2 above. - Python 3.12+ and git.
- This repo pushed to your own GitHub remote (not a fork you don't control).
In your GitHub repo: Settings → Actions → Runners → New self-hosted runner → pick Linux/x64. GitHub shows you a one-time download + config script for your repo, e.g.:
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64.tar.gz -L https://github.com/actions/runner/releases/download/vX.Y.Z/actions-runner-linux-x64-X.Y.Z.tar.gz
tar xzf ./actions-runner-linux-x64.tar.gz
./config.sh --url https://github.com/YOUR_USER/devops-agent --token YOUR_REGISTRATION_TOKENRun it as a background service so it survives reboots and keeps listening for jobs:
sudo ./svc.sh install
sudo ./svc.sh start(Or ./run.sh in a terminal you keep open, if you'd rather watch it live for the demo.)
Push to main, open a PR, or trigger it manually from the Actions tab
(workflow_dispatch). Watch the run: pytest fails on test_payment_retry_logic,
and the Diagnose failure with local AI agent step kicks in — its output and the
job summary show the same root cause the Part 1/2 demos surfaced, but this time
diagnosed from a log that was generated by a real, live test run on your own hardware.
See .github/workflows/ci.yml — no secrets required for this path, since everything (tests, model, diagnosis) runs on your own box.
devops-agent/
├── agent.py # Cloud agent — Claude API
├── agent_local.py # Local agent — Qwen3 via Ollama
├── requirements.txt # Dependencies
├── samples/
│ ├── failed_build.log # Canned sample log (used for the standalone demo)
│ └── gateway.py # Buggy source file the agent inspects
├── tests/ # Real pytest suite — one test genuinely fails
│ ├── conftest.py
│ ├── test_payments.py # The failing test (mocked Stripe timeout)
│ ├── test_api.py
│ ├── test_auth.py
│ ├── test_health.py
│ └── test_utils.py
└── .github/
└── workflows/
└── ci.yml # Real GitHub Actions trigger on a self-hosted runner
The agent has exactly three tools — think of them as workers it can delegate to:
| Tool | What it does |
|---|---|
read_build_log |
Reads the CI failure output — stack traces, error messages, test results |
read_source_file |
Reads any source file from the repo to inspect the buggy code |
post_slack_summary |
Posts the diagnosis and fix recommendation to Slack |
The LLM (the manager) decides which tool to call, when, and in what order. You never hardcode that logic — the model reasons its way to it.
while True:
response = client.messages.create(
model=MODEL, tools=TOOLS, messages=messages
)
if response.stop_reason == "end_turn":
break
for block in response.content:
if block.type == "tool_use":
result = execute_tool(block.name, block.input)
messages.append({"role": "assistant", "content": response.content})
messages.append({"role": "user", "content": [tool_result]})while step < MAX_STEPS:
response = ollama.chat(
model=MODEL, messages=messages,
tools=TOOLS, think=False, options={"temperature": 0.1}
)
if not response.message.tool_calls:
break
for tool_call in response.message.tool_calls:
result = execute_tool(tool_call.function.name, tool_call.function.arguments)
messages.append({"role": "tool", "content": result})Key difference: Ollama uses OpenAI-compatible tool format. Claude uses Anthropic format. The agentic loop logic is identical — only the API client changes.
import requests
requests.post(
os.environ["SLACK_WEBHOOK_URL"],
json={"text": f"*{payload['root_cause']}*\nFile: `{payload['affected_file']}`\n```{payload['code_suggestion']}```"}
){"name": "create_github_pr", "description": "Create a PR with the fix"}
{"name": "query_datadog_metrics", "description": "Fetch metrics around failure time"}
{"name": "run_terraform_plan", "description": "Run terraform plan and return diff"}.github/workflows/ci.yml does this for real on a self-hosted runner with the local Qwen3 agent — see Part 3 above.
Prefer the cloud agent instead (e.g. on a GitHub-hosted runner, no local Ollama box)? Swap the last step for:
- name: Diagnose failure with Claude
if: failure()
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: python agent.py --log ci_output.log| Guardrail | Why |
|---|---|
| Dry-run mode | Agent shows what it would do before acting |
| Approval gate | Human approves fix in Slack before PR is raised |
| Scope limits | Agent cannot touch production without explicit flag |
| Audit logging | Every tool call logged with timestamp and reasoning |
| Secret scanning | Never pass API keys through agent context |
anthropic>=0.40.0
ollama>=0.4.0
requests>=2.31.0
| Version | Cost per run |
|---|---|
| Claude API | ~$0.01–0.02 |
| Qwen3 local | $0.00 |
- Claude API agent (Part 1)
- Local Qwen3 agent via Ollama (Part 2)
- GitHub Actions automatic trigger on build failure (Part 3)
- Self-hosted runner setup guide (Part 3)
- Real Slack webhook integration
- GitHub PR creation tool
- Multi-agent pattern — planner + executor + reviewer
- Datadog / CloudWatch metrics correlation
Built by GK — Cloud Architect and DevSecOps practitioner with 10+ years of enterprise networking and telecom experience.
Cloud Advocate is a YouTube channel covering AI on Cloud, DevSecOps, Multi-cloud, FinOps, and Cloud Career guidance with real-world hands-on depth.
📺 YouTube — Cloud Advocate 💼 LinkedIn
MIT License — free to use, modify, and distribute.
If this helped you, give the repo a ⭐ and subscribe to Cloud Advocate for more hands-on cloud and DevOps content.