openclaw - ✅(Solved) Fix [Bug]: doctor flags live agents/main store as orphaned when default agent id is not main [1 pull requests, 5 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74313Fetched 2026-04-30 06:25:39
View on GitHub
Comments
5
Participants
4
Timeline
12
Reactions
2
Timeline (top)
commented ×5mentioned ×3subscribed ×3cross-referenced ×1

openclaw doctor can flag ~/.openclaw/agents/main as an orphaned agent directory and suggest removing it, even though the same install still uses agents/main for live auth/session-related state.

This is dangerous because the warning is framed as cleanup guidance, but following it can delete live state.

Root Cause

This is dangerous because the warning is framed as cleanup guidance, but following it can delete live state.

Fix Action

Fixed

PR fix notes

PR #74438: fix: honor the configured default agent in models status and doctor

Description (problem / solution / changelog)

Summary

  • Problem: openclaw models status and openclaw models status --probe fell back to the compatibility agent dir when --agent was omitted, instead of using the configured default agent.
  • Why it matters: this made model/auth status inconsistent with the documented default-agent contract and could inspect the wrong auth store when the configured default agent was not main.
  • What changed: added shared agent-scope resolution for models status, threaded that scope through the probe path, and taught openclaw doctor not to flag the live compatibility agent dir as an orphan.
  • What did NOT change (scope boundary): this PR does not remove the legacy compatibility main store, and it does not rewrite unrelated resolveOpenClawAgentDir() call sites outside this issue.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #74313
  • Related #N/A
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: models status and its --probe path resolved omitted --agent calls through resolveOpenClawAgentDir() instead of the configured default agent, while doctor’s orphan-dir scan only compared on-disk agent dirs against agents.list and had no exception for the live compatibility store.
  • Missing detection / guardrail: there was no regression coverage for a non-main configured default agent with omitted --agent, and no doctor coverage for exempting the live compatibility dir.
  • Contributing context (if known): auth profile resolution intentionally still supports read-through compatibility from the main store, so the status/probe path and doctor warning drifted into contradictory behavior.

Regression Test Plan (if applicable)

  • Unit test
  • Seam / integration test
  • End-to-end test
  • Existing coverage already sufficient
  • Target test or file: src/commands/models/list.status.test.ts, src/commands/models/list.probe.targets.test.ts, src/commands/doctor-state-integrity.test.ts
  • Scenario the test should lock in: when the configured default agent is not main, models status and models status --probe use that default agent unless an agent-dir env override is set, and doctor does not warn on the live compatibility agent dir.
  • Why this is the smallest reliable guardrail: the bug lives at the command/config/path-resolution seam, so isolated helper tests would miss the real precedence and store-selection behavior.
  • Existing test that already covers this (if any): explicit --agent behavior already had coverage in src/commands/models/list.status.test.ts, but the omitted---agent default-agent path did not.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • openclaw models status now uses the configured default agent when --agent is omitted and no OPENCLAW_AGENT_DIR / PI_CODING_AGENT_DIR override is active.
  • openclaw models status --probe now probes the same resolved agent scope instead of silently reading the compatibility main store.
  • openclaw doctor no longer warns that the live compatibility agent dir is orphaned just because it is not listed in agents.list.

Diagram (if applicable)

Before:
[models status with no --agent] -> [resolveOpenClawAgentDir()] -> [compatibility main store]
[doctor orphan scan] -> [compare dirs only to agents.list] -> [warn on live compatibility dir]

After:
[models status with no --agent]
  -> [explicit --agent? else env override? else configured default agent]
  -> [correct agent dir]
  -> [status/probe use same store]

[doctor orphan scan]
  -> [exclude current live compatibility agent dir]
  -> [warn only on real orphan dirs]

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? Yes
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? Yes
  • If any Yes, explain risk + mitigation: the commands now read the intended configured default agent auth store instead of the compatibility main store when no explicit agent or env override is present; explicit --agent and env overrides still take precedence, and regression tests cover both the default-agent and compatibility-store paths.

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Node 22.14.0 for final verification
  • Model/provider: N/A for regression tests
  • Integration/channel (if any): None
  • Relevant config (redacted): agents.list default agent set to a non-main id; OPENCLAW_AGENT_DIR unset for the default-agent scenario and set for the compatibility-override scenario

Steps

  1. Configure agents.list so the default agent is not main, and keep the compatibility agents/main/agent dir on disk.
  2. Run openclaw models status and openclaw models status --probe without --agent.
  3. Run openclaw doctor.

Expected

  • models status and --probe inspect the configured default agent store unless an env override is active.
  • doctor does not warn that the live compatibility agent dir is orphaned.

Actual

  • Before this fix, models status and --probe read the compatibility store, and doctor warned on the live compatibility dir.
  • After this fix, the behavior matches the expected default-agent and compatibility-override contract.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Trace/log snippets:

  • npx -y [email protected] /usr/local/lib/node_modules/pnpm/bin/pnpm.cjs test src/commands/models/list.status.test.ts src/commands/models/list.probe.targets.test.ts src/commands/doctor-state-integrity.test.ts
  • Result: Test Files 3 passed, Tests 35 passed
  • npx -y [email protected] /usr/local/lib/node_modules/pnpm/bin/pnpm.cjs check:changed
  • Result: passed

Human Verification (required)

  • Verified scenarios: configured non-main default agent for models status, configured non-main default agent for models status --probe, explicit --agent, compatibility env override precedence, and doctor orphan-dir reporting.
  • Edge cases checked: env override still wins over configured default agent; doctor exempts only the current live compatibility dir rather than suppressing all orphan warnings.
  • What you did not verify: live provider probe traffic against real credentials, and a full end-to-end manual CLI repro outside the Node 22 test harness.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: some users may have relied on the old implicit models status compatibility-store fallback even when their configured default agent differed.
  • Mitigation: explicit --agent still works, env overrides still preserve the compatibility path, and regression tests lock the intended precedence.
  • Risk: doctor could suppress one warning that previously appeared.
  • Mitigation: the exemption is limited to the single currently resolved live compatibility dir; real orphan dirs are still reported.

Changed files

  • scripts/check-deadcode-unused-files.mjs (modified, +8/-1)
  • src/commands/doctor-state-integrity.test.ts (modified, +40/-0)
  • src/commands/doctor-state-integrity.ts (modified, +16/-2)
  • src/commands/models/list.probe.targets.test.ts (modified, +9/-2)
  • src/commands/models/list.probe.ts (modified, +0/-1)
  • src/commands/models/list.status-command.ts (modified, +75/-20)
  • src/commands/models/list.status.test.ts (modified, +194/-2)
  • test/scripts/check-deadcode-unused-files.test.ts (modified, +12/-0)

Code Example

Found 1 agent directory on disk without a matching agents.list entry.
Examples: main
Restore the missing agents.list entries or remove stale dirs after confirming they are no longer needed: ~/.openclaw/agents

---

Agent dir     : ~/.openclaw/agents/main/agent
Auth store    : ~/.openclaw/agents/main/agent/auth-profiles.json
RAW_BUFFERClick to expand / collapse

Bug type

Incorrect behavior without a crash

Summary

openclaw doctor can flag ~/.openclaw/agents/main as an orphaned agent directory and suggest removing it, even though the same install still uses agents/main for live auth/session-related state.

This is dangerous because the warning is framed as cleanup guidance, but following it can delete live state.

Steps to reproduce

On a host that started as a single-agent install and later moved to named agents:

  1. Configure agents.list with a non-main default agent, for example:
    • alfred with default: true
  2. Keep an existing ~/.openclaw/agents/main/ directory from the earlier/default install path.
  3. Run:
    • openclaw doctor
  4. Observe the state-integrity warning.
  5. Then run:
    • openclaw models status
    • optionally inspect openclaw docs/examples for default session/agent paths.

Expected behavior

One of these should happen:

  1. openclaw doctor recognizes that agents/main is still intentionally used by current OpenClaw commands/docs and does not suggest deleting it, or
  2. openclaw doctor downgrades the warning and clearly states that agents/main may still be a live compatibility/default store and must be verified before removal.

Actual behavior

openclaw doctor warns:

Found 1 agent directory on disk without a matching agents.list entry.
Examples: main
Restore the missing agents.list entries or remove stale dirs after confirming they are no longer needed: ~/.openclaw/agents

But on the same install, openclaw models status still reports:

Agent dir     : ~/.openclaw/agents/main/agent
Auth store    : ~/.openclaw/agents/main/agent/auth-profiles.json

So the warning reads like safe cleanup advice, but the path is still live.

OpenClaw version

2026.4.26

Operating system

macOS

Install method

npm global

Model

ollama/kimi-k2.6:cloud

Provider / routing chain

Multi-agent config with named agents (alfred, donna, krause, gilfoyle, etc.), but retained agents/main compatibility/default store on disk.

Additional provider/model setup details

This came from a real host that now has:

  • agents.list[].id = alfred with default: true
  • other named agents like donna, gilfoyle, krause
  • ~/.openclaw/agents/main/ still present and still referenced by at least some commands / state resolution paths

Logs, screenshots, and evidence

Relevant doctor source appears to decide orphaned directories by comparing on-disk directory names to configured agent ids:

  • src/commands/doctor-state-integrity.ts:109-145

Relevant docs still describe main as the default single-agent state root:

  • docs/concepts/multi-agent.md:55-59
    • single-agent mode defaults to main
    • state defaults to ~/.openclaw/agents/main/agent
  • docs/cli/sessions.md:42-52
  • docs/cli/sessions.md:92-101
    • examples still use agents/main/sessions/sessions.json

The main issue is not that main exists on disk. The issue is that doctor currently presents it as removable stale data, while docs and at least some CLI resolution paths still treat it as live/default state.

Impact and severity

Potential data loss or auth loss if operators follow the cleanup suggestion and remove ~/.openclaw/agents/main.

At minimum this is a false-positive warning. In worse cases it is unsafe guidance because it can direct users toward deleting a still-live store.

Additional information

This may be related to other doctor/orphan false positives, but the specific problem here is the mismatch between:

  • doctor's orphan-directory heuristic
  • docs/examples that still use agents/main
  • live command output on the same install that still points at agents/main

If the intended model is that agents/main is no longer special once a named default agent exists, then the docs and any remaining command resolution paths should be aligned before doctor suggests deletion.

extent analysis

TL;DR

The openclaw doctor command should be updated to recognize ~/.openclaw/agents/main as a potentially live directory even when a named default agent is configured, to prevent suggesting its removal when it still contains relevant state.

Guidance

  • Review the src/commands/doctor-state-integrity.ts file to understand how orphaned directories are currently identified and consider updating the logic to account for the main directory being used as a compatibility/default store.
  • Verify that the docs/concepts/multi-agent.md and docs/cli/sessions.md documentation is aligned with the intended behavior regarding the use of agents/main as a default state root.
  • Consider adding a check in the openclaw doctor command to detect if ~/.openclaw/agents/main is still being used by any commands or state resolution paths before suggesting its removal.
  • Update the warning message to clearly indicate that agents/main may still be a live compatibility/default store and should be verified before removal.

Example

No code example is provided as the issue requires a review of the existing codebase and documentation rather than a straightforward code fix.

Notes

The solution may involve updating both the openclaw doctor command and the relevant documentation to ensure consistency and prevent potential data loss.

Recommendation

Apply a workaround by manually verifying the contents of ~/.openclaw/agents/main before removing it, and consider updating the openclaw documentation and command logic to align with the intended behavior regarding the use of agents/main as a default state root. This is because the current implementation may lead to data loss if the suggested cleanup is followed without proper verification.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

One of these should happen:

  1. openclaw doctor recognizes that agents/main is still intentionally used by current OpenClaw commands/docs and does not suggest deleting it, or
  2. openclaw doctor downgrades the warning and clearly states that agents/main may still be a live compatibility/default store and must be verified before removal.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: doctor flags live agents/main store as orphaned when default agent id is not main [1 pull requests, 5 comments, 4 participants]