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

ProblemFailed deployments waste hours. The log is long, but the cause is usually a known pattern.
SolutionAn agent that ingests the failed run, classifies it, and proposes 3 ranked fixes with diffs.
ImpactLower mean time to recovery (MTTR) by removing the "read 3,000 lines" step.
52
detection rules
8
failure categories
40
fix templates
27
automated tests

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

1. IngestStrip ANSI codes, timestamps and CI prefixes. Keep original line numbers. Detect GitHub, GitLab, Jenkins or CircleCI.
2. Classifyweighted rules score 8 categories. Output: ranked categories, tags, evidence lines and confidence.
3. ExtractPull concrete names: env var, package, image, test, lock ID, IAM action, TS error.
4. ProposeFill the 44 templates with those names. Rank by fit × category share. Keep 3.
5. ReportText, JSON or Markdown (for PR comments).

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

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.

100%
category accuracy, dev (11 logs)
100%
category accuracy, holdout (7 logs)
11/11
top fix correct, dev
7/7
top fix correct, holdout
3/3
category and top fix correct, real logs (rules written against them)
Read this number honestly. 18 logs is a smoke test, not a benchmark. I wrote all but one of the logs myself. The exception is 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.
Real-log check. The first run on 20 recent failed GitHub Actions logs from public repos returned 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.
LogExpectedGotConf.Top fix
github_aws_auth.logauthauth75%Replace static cloud keys with OIDC role assumptionpass
npm_peer_conflict.logdependencydependency75%Upgrade `react-datepicker` to a release that supports your current `react`pass
flaky_pytest.logtesttest95%Retry flaky tests in CI, not the whole pipelinepass
jest_port_timeout.logtesttest95%Stop hard-coding port 3000 in testspass
missing_env_var.logconfigconfig75%Pass `DATABASE_URL` into the deploy jobpass
oom_build.loginfrainfra75%Raise the Node heap limit for the buildpass
k8s_imagepull.logrolloutrollout95%Confirm `ghcr.io/acme/checkout-api:3f9a1c2` was actually pushedpass
terraform_lock.loginfrainfra80%Release the stale Terraform state lockpass
typescript_error.logbuildbuild75%Fix TS2345 at src/billing/invoice.ts:48pass
gitlab_registry_denied.logauthauth70%Log in to the container registry before pushingpass
unknown_noise.logunknownunknown0%no fixes (by design)pass
maven_resolution.logdependencydependency61%Publish or resolve `com.acme:shared-models:2.4.0` before this buildpass
docker_rate_limit.loginfrainfra75%Authenticate to Docker Hub to lift pull limitspass
liveness_probe.logrolloutrollout95%Give the app time to start before probingpass
python_module.logdependencydependency75%Add `structlog` to requirementspass
disk_full.loginfrainfra68%Free disk space before the heavy steppass
github_perms.logauthauth80%Give the workflow token the permission it is missingpass
real_setup_python_runner.loginfrainfra80%Pin the runner image so `3.9` is availablepass
real/psf_requestslintlint95%Run `ruff format` locally and commit what it changespass
real/pandas-dev_pandaslintlint95%Fix the type error at pandas/core/base.py:1002pass
real/pallets_flasktesttest90%Stop `DeprecationWarning` from failing the run while you migratepass

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:

Roadmap

PhaseScopeExit criterion
0. POC (this repo)Rules, 8 categories, top-3 fixes with diffs, CLI, tests, eval harnessDone
1. Real dataCollect 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 fallbackSend only the evidence window to an LLM when confidence is low; generate diffs from the user's real files instead of templatesUnknown rate < 10%
3. Where engineers areGitHub Action / App that comments on failed runs; optional "open fix PR" with human approvalPilot with one team, MTTR compared
4. BreadthGitLab, Jenkins, CircleCI adapters; per-team custom rulesSecond team onboarded

Known limits

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.