Skip to content

Agent health checks (abt doctor)

abt doctor runs static checks on compiled agents (and optional LLM review) to catch common issues before you spend tokens on a run: missing guardrails, deep delegation chains, prompts that crowd the model's context window, tool/prompt mismatches, and prompt wording or model settings that current models handle badly.

Compile-first

Every invocation compiles the project first (same bootstrap as abt run / abt test): abt.yaml and agent files are validated, context is resolved, and manifest.json is written to the workspace target. You do not need to run abt compile manually first.

  • No --target: the default target from profiles.yaml is used (same as other commands).
  • -s / --select: narrows the compile scope — the named agent and the agents it can call through subagents: are compiled in full and checked, and only their referenced context is fetched. manifest.json still lists every agent. Bare agent name only (see Selectors).

Usage

Static checks need no model and no credentials, so they run in a PR check as is. Only --deep calls a model. A CI gate is abt doctor --fail-on warning.

abt doctor --project-root .
abt doctor -s my_agent --project-root .
abt doctor --tag infra --project-root .
abt doctor --deep --project-root . --target dev --profiles-dir ~/.abt
Flag Meaning
-s, --select Optional. Narrows the compile scope (same rule as abt compile -s: a bare agent name).
--tag TAG Post-compile filter: only run checks on agents whose tags include TAG. A tag that matches no agent exits 1 (No agents found with tag 'x'. Useabt list --tagsto browse.).
--deep Run an extra LLM prompt review per agent using config.testing.judge_model_id from abt.yaml, or the profile's default model when that is unset (one model call per rubric dimension per agent, up to four per agent). Needs an active profile.
--show-suppressed Also list the findings that doctor.disable muted, in a dim section. --format json always includes them.
--fail-on {error,warning} Exit 1 when any finding is at that severity or worse, so a CI job can gate on the report; the report is still printed and the last line says how many findings tripped the gate. Default: always exit 0. To adopt it on a project that already has findings, record them with --write-baseline and gate only new ones with --baseline (below).
--baseline FILE With --fail-on: findings already recorded in FILE do not trip the gate; the report still lists everything. A finding is matched by agent and rule, not message, so changing numbers in its text does not make it new. Needs --fail-on; cannot be combined with --write-baseline.
--write-baseline FILE Record the current findings in FILE (sorted JSON, safe to commit and review) and exit 0. Re-run it to accept new findings.
--format {text,json} json prints agents_checked, findings, suppressed, suppressed_findings and skipped_rules_no_profile for CI tooling, instead of the text report.
--project-root, --target, --profiles-dir, --workspace Same as abt run / abt test.
--lazy / --no-lazy Same context materialization behavior as other commands.
--live Compile live: start MCP servers, and fail on a failed external-context or remote-skill fetch. Without the flag, the default follows flags.live_compile / ABT_LIVE_COMPILE (off unless set).
--vars Template vars for compile-time Jinja (same as abt compile).
--debug / --no-debug Verbose logging (no short flag).
-fr, --final-response Print only the report, suppressing progress output.

Filters vs -s: -s/--select changes which agents are compiled in full and checked. --tag compiles the full project (unless you also pass -s), then narrow which agents receive static rules and --deep. Rules that need the whole delegation chain (for example deep_delegation) still see the full compiled manifest.

Exit code

  • 0 — Doctor finished and printed a report (including when there are warnings or info findings). The command is advisory by default: it does not fail CI or scripts when issues are found.
  • 1 — Doctor could not check the whole project: no agent was checked, or an agent's env_var() is unset so its rules could not run (the report names the agent and the variable, and suggests setting it or giving a default such as {{ env_var('NAME', '<default>') }}). This holds with or without --fail-on, so a broken project never passes a CI gate. Also, with --fail-on error or --fail-on warning, at least one finding reached that severity (--fail-on warning also trips on errors). Exit 1 also covers compile/bootstrap failures, so read the last line of the output to tell the two apart: compile/bootstrap failed, --tag matched no agent, or an unexpected error during checks. --deep with no active profile also exits 1 (--deep needs a model profile, but none is active …, with a hint to run abt init or pass --profiles-dir). A failed LLM call itself is caught per-agent and reported as a warning finding, not a command failure.
  • 2 — Invalid CLI arguments (for example bad --vars YAML, or a --profiles-dir you pass that has no profiles.yaml).

With no --profiles-dir, a missing profiles.yaml does not fail static abt doctor — it exits 0 and skips the rules that need a resolved model (those say so in the rules table); only --deep needs a profile.

Rules (static)

Rule Severity What it checks
missing_guardrails warning Agent has tools but none of run_timeout, model_call_limit or token_budget middleware is set.
deep_delegation warning Longest subagents: chain (within the compiled manifest) exceeds 3 edges.
circular_delegation warning The agent sits on a cycle in the subagents: graph (A delegates to B, B back to A).
context_bloat warning The prompt the model receives plus few_shots take 25% or more of the agent's own model's context window. Large context.*() content that is passed as a file pointer does not count. Needs an active profile that resolves the model's max_input_tokens; silent otherwise.
tool_prompt_mismatch warning Tools are configured but no tool name appears in the system prompt (case-insensitive).
empty_description warning description is very short and another agent delegates to this one through subagents: (callers choose subagents by description).
duplicate_tool_names warning The same tool name appears more than once in the agent config.
high_temperature_with_tools warning tools is non-empty and temperature ≥ 0.8 (risky for stable tool selection).
aggressive_prompt_language info The agent runs on Claude 4.5 or newer (its model_id, else the profile's) and the prompt body has three or more shouted directives (MUST, NEVER, ALWAYS, CRITICAL, IMPORTANT, REQUIRED) or “if in doubt, use …” phrasing. Those models follow the system prompt closely, so emphasis written for older ones makes them over-trigger tools and instructions; on older models emphasis is how you got tools used, so they are not flagged.
unbounded_retry_language info An agent with tools or subagents is told to "keep trying", "retry until", "continue until", "never give up" and similar, in a sentence that states no bound ("at most 3 attempts", "up to", a timeout). Judged sentence by sentence.
confusable_subagents warning Two subagents of the same agent have descriptions that share 80% or more of their words (descriptions under four words are skipped). The model picks between subagents by description alone.
thinking_budget_tokens_deprecated warning model_kwargs.thinking.budget_tokens is set and the agent's model (its own model_id, else the profile's) is Claude 4.6 or newer. It is deprecated on 4.6 and rejected (HTTP 400) on 4.7 and later; use adaptive thinking with reasoning_effort. Claude 4.5 and earlier have no other way to enable thinking, so they are not flagged.
handler_refs_resolved warning An on_success/on_failure handler references a class that isn't in the compiled manifest (stale after a rename or deleted handler file).
blocked_package_write_specs error Agent lists a write package spec (for example gh__gh_pr_merge, git__git_push, databricks__databricks_run_cancel) but config.packages blocks writes.
package_abt_core_incompatible error An installed package's requires-abt-core (in abt_package.yaml) doesn't match the running abt version. Run abt deps --upgrade, or align the installed abt version.
invalid_package_tool_specs error Agent lists an unknown or malformed package spec (for example git__investigation, databricks__unknown, git__clone__invalid).
package_mcp_duplication info Both package and MCP specs may cover the same capability — prefer package tools (zero MCP schema cost).
package_missing_credentials warning Agent uses package tools but required credentials (or local binaries for git) appear missing.
access_private_dispatch_reminder info Agent is access: private, but abt run -s <agent> still runs it directly. The access/group gate applies to subagents: edges only; workflow edges are not checked.
reasoning_effort_outside_model_profile warning The agent's model_kwargs.reasoning_effort is not among the levels its model's LangChain profile declares. Advisory: silent when the profile declares no levels or the model can't be resolved (needs an active profile). See Reasoning effort.
compaction_trigger_exceeds_model_window warning Compaction's trigger (absolute token count) exceeds the agent's own model's resolvable max_input_tokens, so it will be clamped down at runtime. Requires an active profile to resolve the model; silently skipped otherwise (no active profile, missing credentials, or unrecognized model id).
abt_packages_yml warning abt_packages.yml exists but can't be parsed. Project-level, so only config.doctor.disable can silence it.
missing_provider_extra error The agent's model provider needs an extra that is not installed (for example openai: without the openai extra). The finding gives the install command. Needs an active profile to resolve the model; silent otherwise.
unknown_resource_type error A type: in sources/, exposures/ or retrievers/ matches no registered provider, usually a typo (slack_threadd). The message suggests the closest type and lists the available ones. Project-level, so only config.doctor.disable can silence it. Checked here and not at compile because the type is only resolved when a workflow runs.
unknown_disabled_rule warning A doctor.disable list names an id that matches no rule (details).

The same three package specs (blocked_package_write_specs, package_abt_core_incompatible, invalid_package_tool_specs) are also checked during every compile, which raises PackageWriteViolation / IncompatibleAbtCoreVersion / InvalidPackageToolSpec and aborts before doctor's rules run at all (exit code 1). They show up as doctor findings only when you pass doctor a manifest that was not compiled by abt compile.

--deep (LLM)

Each agent is judged against a four-part rubric, one separate model call per dimension so one verdict cannot colour another:

Dimension Question
exit_conditions Does the prompt give the agent a clear way to know it is done, or could its instructions make it loop?
tool_routing Is it clear which tool or subagent to use when, with no overlapping or unexplained choices?
contradictions Do any instructions contradict each other?
altitude Is the prompt written as goals and reasons, or as brittle if-else logic and a laundry list of edge-case rules?

The judge returns a structured verdict (pass, fail or unknown) with a quote as evidence. Only fail verdicts become findings, shown as [dimension] message; unknown is never reported, so the judge is not pushed to guess. The judge sees the agent's tool names, subagents: and output schema. exit_conditions and tool_routing are skipped for an agent with neither tools nor subagents: it answers once, so it cannot loop and has nothing to route (two calls instead of four). contradictions and altitude only fail when the judge can quote the offending text, so a short, goal-oriented prompt passes.

Findings carry the rule id llm_prompt_review (the dimension is in the message). When the judge is the same model as agents it reviews, one project-level info finding, llm_judge_same_model, says so.

Configure the model under config.testing in abt.yaml (judge_model_id, judge_temperature) — same block as abt test. With no judge_model_id, the profile's default model reviews. A judge tends to favor its own style, so a different model, ideally another family, is a better judge than the agents' own. If judge_model_id is pinned to the same model as an agent it reviews, doctor adds an llm_judge_same_model info finding.

Only agents the compile rendered are reviewed (the same scope as the static rules), so -s and --tag also bound the model cost.

Reviews run in parallel across agents with a bounded concurrency cap (default 4); an agent's four dimensions run one after another. Lower or raise the cap with config.doctor.deep_max_concurrency in abt.yaml if you hit rate limits or want more throughput. The resulting value is further capped by the global --threads budget so a run-wide cap always wins over per-subsystem settings.

If a model call fails, the agent keeps the verdicts already collected and gets a warning that the review failed.

What a clean report does not mean

Checks that resolve the model (context_bloat, compaction_trigger_exceeds_model_window, reasoning_effort_outside_model_profile, and the model-version checks aggressive_prompt_language and thinking_budget_tokens_deprecated) stay silent when no profile is active. Doctor says so after the report, and --format json lists them under skipped_rules_no_profile, so a clean result is not read as "these passed".

Output

The first line is the verdict, as in abt bench: ✓ nothing to fix, ! warnings, ✗ errors or an unchecked project.

! 82 agents checked: 11 warnings, 1 info (17 suppressed).

Findings follow, grouped by agent, then the agents that passed, listed in as few lines as fit 100 columns. The report goes to stdout; errors and the --fail-on reason go to stderr. The CLI uses color when stdout is a TTY and NO_COLOR is unset (see CLI reference — Terminal output). Warnings are yellow, info blue.

Python SDK

from abt.runner import AbtRunner

runner = AbtRunner(project_root=".")
res = await runner.ainvoke(["doctor"])
# res.result is a DoctorReport (dataclass-like): findings, agents_checked, agent_names_checked, muted
res2 = await runner.ainvoke(["doctor", "--deep"])
res3 = await runner.ainvoke(["doctor", "--tag", "infra"])

--deep is only valid for doctor (pass deep=True as a kwarg to ainvoke / invoke).

Programmatic kwarg: filter_tag="...". abt test has no equivalent filter flag — its closest analog is --only-agent (it narrows which agent's suite runs and leaves that agent's subagents: tree wired; see Testing). Separately: abt dispatch -s <workflow> runs a workflow and abt run -s <agent> runs a single agent plus its subagents: tree (see Selectors).

Plugin rules

Third-party or project packages can register extra checks via the abt.doctor_rules entry-point group. Unlike the built-in static rules (one per agent), a plugin rule runs once per project and receives project_root + the resolved ProjectConfig — not the compiled manifest:

# my_pkg/doctor_rules.py
from pathlib import Path
from typing import Any
from abt.doctor.models import DoctorFinding


class ProfilesGitignoredRule:
    name = "profiles_yaml_gitignored"
    description = "Warns if profiles.yaml exists but isn't excluded by .gitignore (credential leak risk)."

    def evaluate(self, *, project_root: Path, config: Any) -> list[DoctorFinding]:
        profiles = project_root / "profiles.yaml"
        if not profiles.is_file():
            return []
        gitignore = project_root / ".gitignore"
        patterns = gitignore.read_text(encoding="utf-8").splitlines() if gitignore.is_file() else []
        if any(p.strip() == "profiles.yaml" for p in patterns):
            return []
        return [
            DoctorFinding(
                agent="(project)",
                rule=self.name,
                severity="error",
                message="profiles.yaml exists but is not excluded by .gitignore.",
                tip="Add 'profiles.yaml' as its own line in .gitignore — it holds live credentials.",
            )
        ]


profiles_yaml_gitignored_rule = ProfilesGitignoredRule()
[project.entry-points."abt.doctor_rules"]
profiles_yaml_gitignored = "my_pkg.doctor_rules:profiles_yaml_gitignored_rule"

The registered object must be an instance (not a bare class) with an evaluate(*, project_root, config) -> list[DoctorFinding] method. Users disable a plugin rule by its name, so use name as the rule of its findings.

Suppressing rules

Two places, both lists of rule ids (from the rules table and the --deep section). They add up; there is no way to re-enable a rule an outer list disabled.

One agent: an intentional finding goes under doctor.disable in that agent's frontmatter.

---
name: scribe
description: Rewrites text and never calls a tool.
tools: [git__git_log]
doctor:
  disable: [tool_prompt_mismatch]
---

Whole project: a rule you don't want anywhere goes under config.doctor.disable in abt.yaml. This is also the only way to silence project-level findings such as abt_packages_yml, unknown_resource_type or llm_judge_same_model.

config:
  doctor:
    disable: [high_temperature_with_tools]

Disabled findings are dropped from the text and --format json reports, --deep findings included, and --baseline / --fail-on never see them. The first line and the JSON suppressed count say how many were dropped (✓ 2 agents checked: no findings (3 suppressed).), and --show-suppressed lists them, so a muted check leaves a trace.

A single string works too (disable: context_bloat). An id that matches no rule is reported as an unknown_disabled_rule warning (it cannot be disabled itself), so a typo never mutes silently. It counts as a warning, so --fail-on warning fails on it. An unknown key under doctor: in abt.yaml (for example disabel:) fails the compile. In an agent's frontmatter the compile fails and names the file.