Skip to content

fix(doctor): stop false failures on multi-agent profiles - #124010

Merged
steipete merged 2 commits into
mainfrom
steipete/doctor-multi-agent-check
Aug 15, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/doctor-multi-agent-check

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where openclaw doctor invented failures on an ordinary explicit multi-agent roster. A profile created by openclaw agents add with main, helper, and third plus agents.defaults.systemAgent.agentId = "main" produced this JSON error:

{
  "checkId": "core/doctor/skill-workshop-tool-policy",
  "severity": "error",
  "message": "health check threw: Multiple agents are configured, but this operation has no explicit owner."
}

The same findings also made bare doctor --json exit 1 while human Doctor exited 0, so selecting machine-readable output changed the advisory command's success contract.

Why This Change Was Made

The Workshop check called detectSkillWorkshopToolPolicyDiagnostic without its supported agentId argument. That fell through resolveDefaultAgentId, which correctly rejects an unowned 2+ agent operation. Doctor now evaluates every configured agent and emits one targeted warning per affected agent; selecting only the ambient system agent would have hidden broken helper-agent policy, and the finding already owns a target field.

The bounded sweep also moves other Doctor/setup paths to their actual owner boundary:

  • channel setup resolves its one discovery workspace through the legacy owner or configured system agent;
  • agent-less legacy cron diagnostics reuse cron's ambient system-agent resolver;
  • model-catalog Doctor migrations enumerate configured agent directories instead of redundantly asking for a legacy default;
  • context-engine Doctor inspection uses the legacy/system owner;
  • Memory LanceDB assigns unscoped legacy rows to the configured system agent only under explicit ownership, while preserving legacy-default ownership.

Bare doctor --json still runs the default read-only checks and preserves ok: false plus the findings, but exits 0 after producing the payload. Explicit doctor --lint and doctor --lint --json retain threshold-based exit 1 for CI. Fatal errors before a report remain nonzero.

The exit decision is history-backed: ordinary Doctor's forced advisory success predates the current wrapper (0aa28c71cabb), installers treat nonzero Doctor as a failed install/update, and explicit lint gating was added separately in 9a5f2f61e76f with “without --lint, doctor runs unchanged.” The mismatch appeared when bare JSON began implying lint in 6093e3477d80.

Remaining setup-owner decisions are intentionally not blanket-rewritten: generic setup/onboard, memory-import migration staging, and system-agent inference activation need an explicit product decision about which agent owns an existing multi-agent setup. They continue to reject real ambiguity.

User Impact

Operators can run Doctor on supported explicit multi-agent profiles without false health check threw findings. Per-agent Workshop policy problems remain visible and actionable. Human and bare-JSON Doctor both preserve advisory exit 0; automation that wants a failing gate uses explicit --lint.

Evidence

Pre-fix, built from the original branch base on an isolated Testbox profile created with agents add:

BEFORE_EXIT human=0 json=1
errorFindings = [core/doctor/skill-workshop-tool-policy: health check threw: Multiple agents...]
human: doctor:auth-profiles run failed: Multiple agents...
human: doctor:skill-workshop-tool-policy run failed: Multiple agents...

Post-fix, exact rebased head, fresh build, isolated OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH, and OPENCLAW_SKIP_CHANNELS=1:

roster: ownership=explicit, entries=main/helper/third, systemAgent.agentId=main
AFTER_EXIT human=0 json=0 lint_json=1
errorFindings = []
workshopFindings = []
HUMAN_RUN_FAILURES = (none)

Focused regression command:

node scripts/run-vitest.mjs \
  src/flows/doctor-core-checks.test.ts \
  src/flows/doctor-core-skill-workshop-check.test.ts \
  src/flows/doctor-core-bootstrap-size-check.test.ts \
  src/cli/program/register.maintenance.test.ts \
  src/flows/channel-setup.status.test.ts \
  src/flows/channel-setup.test.ts \
  src/commands/doctor/cron/index.test.ts \
  src/commands/doctor/shared/context-engine-host-compat.test.ts \
  extensions/memory-lancedb/doctor-contract-api.test.ts \
  src/commands/doctor-plugin-model-catalog.test.ts \
  src/commands/doctor-model-catalog-credentials.test.ts

Result: 213 tests passed across 5 Vitest shards. The regression tests were first run against pre-fix source and failed for the intended Workshop throw and bare-JSON exit 1.

Additional proof:

  • exact-head pnpm build: passed;
  • core lint: 0 warnings/errors;
  • docs gate: formatting, Markdown/MDX, glossary, 6,495 links, and 1,174 config examples passed;
  • uncommitted autoreview: clean, no accepted/actionable findings;
  • changed gate passed formatting, Doctor closure guards, plugin boundaries, dead-code scan, and all core/UI/extension typechecks before the test-file split; exact-head retry reached dead-code but current origin/main cannot complete a frozen install because pnpm-lock.yaml lacks @oxc-parser/[email protected]. Focused exact-head tests and build passed independently.

Production LOC: +95/-49 (net +46) | Tests: +449/-111 | Docs: +25/-18. The positive production delta is the explicit ownership work needed to replace six throwing scalar/default-agent paths with roster iteration or legacy/system-agent ownership; it adds no config or compatibility fallback.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 15, 2026 04:38
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: memory-lancedb Extension: memory-lancedb cli CLI command changes commands Command implementations size: L maintainer Maintainer-authored PR labels Aug 15, 2026
@steipete
steipete merged commit 6e5bf3e into main Aug 15, 2026
250 checks passed
@steipete
steipete deleted the steipete/doctor-multi-agent-check branch August 15, 2026 04:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
…4010)

* fix(doctor): resolve multi-agent health owners

* fix(doctor): keep bare json exit advisory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: memory-lancedb Extension: memory-lancedb gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant