Deploy Doctor Agent
A rule-based agent (no LLM yet). Feed it a failed CI/CD run. It tells you what kind of failure it is, shows the evidence, and proposes the top 3 fixes as diffs.
github.com/alihabbache/Deploy-Doctor-Agent · proof of concept v0.1.0 · Python standard library only
See it work
A Kubernetes rollout failed. Input is the raw log (8 lines here, usually thousands):
2026-03-11T13:05:02Z $ kubectl rollout status deployment/checkout-api --timeout=120s
2026-03-11T13:05:02Z Waiting for deployment "checkout-api" rollout to finish: 0 of 3 updated replicas are available...
2026-03-11T13:07:02Z error: timed out waiting for the condition
2026-03-11T13:07:03Z $ kubectl describe pod checkout-api-7d9f8b6c5-x2kqp
2026-03-11T13:07:03Z Warning Failed 2m kubelet Failed to pull image "ghcr.io/acme/checkout-api:3f9a1c2": rpc error: code = Unknown desc = failed to resolve reference: not found
2026-03-11T13:07:03Z Warning Failed 2m kubelet Error: ErrImagePull
2026-03-11T13:07:03Z Normal BackOff 1m kubelet Back-off pulling image "ghcr.io/acme/checkout-api:3f9a1c2"
2026-03-11T13:07:03Z Warning Failed 1m kubelet Error: ImagePullBackOff
Command: python3 -m deploy_doctor samples/k8s_imagepull.log. Output, unedited:
Diagnosis: Deployment rollout (Kubernetes / Helm) (rollout), confidence 95%
Analyzed 8 lines (generic).
Evidence:
line 3: error: timed out waiting for the condition
line 5: Warning Failed 2m kubelet Failed to pull image "ghcr.io/acme/checkout-api:3f9a1c2": rpc error: code = Unknown desc = failed to resolve reference: not found
line 6: Warning Failed 2m kubelet Error: ErrImagePull
Fix #1: Confirm `ghcr.io/acme/checkout-api:3f9a1c2` was actually pushed [risk: low]
Deploy jobs often run before, or without, the push that creates the tag. The registry reported the reference as not found.
$ docker manifest inspect ghcr.io/acme/checkout-api:3f9a1c2
Fix #2: Make the release roll back automatically on failure [risk: low]
`--atomic` reverts a failed Helm upgrade, so a bad release never stays half-deployed.
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -1 +1 @@
- - run: helm upgrade app ./chart --install
+ - run: helm upgrade app ./chart --install --atomic --timeout 5m
Fix #3: Add an imagePullSecret for `ghcr.io/acme/checkout-api:3f9a1c2` [risk: medium]
ImagePullBackOff means the node cannot fetch the image: wrong tag, missing push, or no pull credentials. The registry said the tag was not found, so check the push first.
--- a/k8s/deployment.yaml
+++ b/k8s/deployment.yaml
@@ -1,4 +1,6 @@
spec:
+ imagePullSecrets:
+ - name: regcred
containers:
- name: app
image: ghcr.io/acme/checkout-api:3f9a1c2
Proposals only. Nothing was applied to your repo.
Note the ranking. The registry said the tag was not found, so "was it pushed?" ranks above "add pull credentials". The agent reads the evidence and doesn't just match on the category.
Same tool, a different failure
Diagnosis: Configuration / secrets (config), confidence 75%
Analyzed 7 lines (github).
Evidence:
line 3: Error: DATABASE_URL is not set
Fix #1: Pass `DATABASE_URL` into the deploy job [risk: low]
`DATABASE_URL` is read at runtime but the workflow never provides it.
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -1 +1,3 @@
- run: ./deploy.sh
+ env:
+ DATABASE_URL: ${{ secrets.DATABASE_URL }}
Fix #2: Create the `DATABASE_URL` secret in the repository [risk: low]
Referencing a secret that does not exist yields an empty string, not an error, which surfaces later as a confusing failure.
$ gh secret set DATABASE_URL --repo <OWNER>/<REPO>
Fix #3: Document required settings and fail fast [risk: low]
Validate config at startup so a missing value fails in seconds with a clear message.
--- /dev/null
+++ b/.env.example
@@ -0,0 +1 @@
+DATABASE_URL=changeme
Proposals only. Nothing was applied to your repo.
How it works
Categories: auth dependency build test config infra rollout. A log that matches nothing returns unknown with no fixes. It refuses to guess.
Machine-readable output (--json), trimmed:
{
"category": "config",
"confidence": 0.75,
"entities": {
"env_var": "DATABASE_URL",
"exit_code": "1"
}
}
Design decisions
- Rules first, LLM later. A POC should be deterministic, offline and free, so every result can be explained and tested. An LLM fits best as a fallback for logs the rules can't classify.
- Confidence is capped at 95%. It measures how strongly rules matched and how far ahead the winner is. It is not a probability.
- Every fix is a proposal. Each carries a risk level. High-risk fixes (for example
terraform force-unlock) are labelled. Nothing is applied automatically. - Evidence is cited by line number so a human can verify the diagnosis in seconds.
How well does it work?
Three sets of labelled logs: a development set the rules were built against, a holdout set written afterwards in a different style, and 3 real failed runs from public repos.
real_setup_python_runner.log: this project's own CI failed on its first push (ubuntu-latest moved to an image without Python 3.9). The agent said unknown, so I added a rule and fix for it. On the other holdout logs the categories were right first time, but the Maven log got a generic top fix, so I added an extractor and a template for it. So the holdout is no longer fully unseen. Real accuracy on production logs is unknown. Measuring it is the first roadmap item.unknown for 14, mostly lint, format and type-check failures. I added a lint category and a rule for warnings promoted to errors. Three of those logs (flask, pandas, requests) are now in samples/real/, labelled by reading each log, and all 3 are diagnosed correctly. I wrote the rules against these three, so this shows the rules work on them. It does not show that coverage improved. The other 17 were not re-run.| Log | Expected | Got | Conf. | Top fix | |
|---|---|---|---|---|---|
github_aws_auth.log | auth | auth | 75% | Replace static cloud keys with OIDC role assumption | pass |
npm_peer_conflict.log | dependency | dependency | 75% | Upgrade `react-datepicker` to a release that supports your current `react` | pass |
flaky_pytest.log | test | test | 95% | Retry flaky tests in CI, not the whole pipeline | pass |
jest_port_timeout.log | test | test | 95% | Stop hard-coding port 3000 in tests | pass |
missing_env_var.log | config | config | 75% | Pass `DATABASE_URL` into the deploy job | pass |
oom_build.log | infra | infra | 75% | Raise the Node heap limit for the build | pass |
k8s_imagepull.log | rollout | rollout | 95% | Confirm `ghcr.io/acme/checkout-api:3f9a1c2` was actually pushed | pass |
terraform_lock.log | infra | infra | 80% | Release the stale Terraform state lock | pass |
typescript_error.log | build | build | 75% | Fix TS2345 at src/billing/invoice.ts:48 | pass |
gitlab_registry_denied.log | auth | auth | 70% | Log in to the container registry before pushing | pass |
unknown_noise.log | unknown | unknown | 0% | no fixes (by design) | pass |
maven_resolution.log | dependency | dependency | 61% | Publish or resolve `com.acme:shared-models:2.4.0` before this build | pass |
docker_rate_limit.log | infra | infra | 75% | Authenticate to Docker Hub to lift pull limits | pass |
liveness_probe.log | rollout | rollout | 95% | Give the app time to start before probing | pass |
python_module.log | dependency | dependency | 75% | Add `structlog` to requirements | pass |
disk_full.log | infra | infra | 68% | Free disk space before the heavy step | pass |
github_perms.log | auth | auth | 80% | Give the workflow token the permission it is missing | pass |
real_setup_python_runner.log | infra | infra | 80% | Pin the runner image so `3.9` is available | pass |
real/psf_requests | lint | lint | 95% | Run `ruff format` locally and commit what it changes | pass |
real/pandas-dev_pandas | lint | lint | 95% | Fix the type error at pandas/core/base.py:1002 | pass |
real/pallets_flask | test | test | 90% | Stop `DeprecationWarning` from failing the run while you migrate | pass |
What I'd measure to prove the impact
The impact claim (lower MTTR) is a hypothesis, not a result. The POC has not been tried on real incidents. To test it:
- Time to first correct hypothesis: failed run → engineer knows the cause. Compare with and without the agent.
- Top-3 hit rate: share of failures where the right fix is in the 3 proposed. Target ≥ 70% before wider rollout.
- Unknown rate: share of logs the rules cannot classify. It drives which rules to write next.
- Wrong-but-confident rate: high-confidence misdiagnoses. This is the trust-killing metric, so keep it near zero.
Roadmap
| Phase | Scope | Exit criterion |
|---|---|---|
| 0. POC (this repo) | Rules, 8 categories, top-3 fixes with diffs, CLI, tests, eval harness | Done |
| 1. Real data | Collect 100+ real failed logs, label them, widen the eval, add a GitHub log fetcher (gh run view --log-failed) | Measured top-3 hit rate |
| 2. LLM fallback | Send only the evidence window to an LLM when confidence is low; generate diffs from the user's real files instead of templates | Unknown rate < 10% |
| 3. Where engineers are | GitHub Action / App that comments on failed runs; optional "open fix PR" with human approval | Pilot with one team, MTTR compared |
| 4. Breadth | GitLab, Jenkins, CircleCI adapters; per-team custom rules | Second team onboarded |
Known limits
- Diffs are templates. They show the shape of the change with placeholders such as
<ACCOUNT_ID>, not a patch against your real files. - Only the log is analysed. It doesn't see the repo, the previous green run, or the commit diff.
- English log messages only. Only one root cause is reported. When several categories match, the others are listed as "also matched".
- Rules are regexes, so a new tool with a new error format needs a new rule.
Try it
git clone https://github.com/alihabbache/Deploy-Doctor-Agent.git
cd Deploy-Doctor-Agent
python3 -m deploy_doctor samples/oom_build.log
python3 -m deploy_doctor samples/flaky_pytest.log --markdown
cat my_failed_run.log | python3 -m deploy_doctor - --json
python3 -m deploy_doctor.evaluate # accuracy on labelled logs
python3 -m unittest discover -s tests # 27 tests
Exit codes: 0 diagnosed, 1 unknown, 2 bad input. Handy for gating a CI step.