fix(memory): reject unknown --agent ids and keep the hint runnable (#126570)

The memory CLI resolved --agent by returning the caller's string verbatim,
so an id that is not configured produced a confident empty result:
`memory status` rendered a panel for it, `memory index` fabricated a
workspace-<id> path, and `memory search` reported No matches. A typo read
as an empty memory rather than a nonexistent agent, while hooks, status
--usage, capability, migrate, and session targets already rejected unknown
ids.

Consolidate that duplicated check into resolveConfiguredAgentId beside the
agent roster owner, reuse it at the matching core sites, and route memory
to it through the existing memory-core host-runtime facade so no new
plugin SDK surface is added.

The canonical hint uses formatCliCommand rather than a literal: under a
profile or container the bare command is wrong, so consolidating on a
literal would have regressed the hooks and migrate hints and left the
status, capability, and session-target hints unrunnable.
This commit is contained in:
Peter Steinberger
2026-08-20 00:32:59 -07:00
committed by GitHub
parent a19d924797
commit 75fcb1fbb9
12 changed files with 177 additions and 44 deletions
+5 -7
View File
@@ -3,7 +3,10 @@ import {
parseStrictPositiveInteger,
} from "@openclaw/normalization-core/number-coercion";
import type { Command } from "commander";
import { listAgentIds, resolveAgentOperationAgentId } from "../../agents/agent-scope-config.js";
import {
resolveAgentOperationAgentId,
resolveConfiguredAgentId,
} from "../../agents/agent-scope-config.js";
import { resolveAgentDir } from "../../agents/agent-scope.js";
import {
listProfilesForProvider,
@@ -117,12 +120,7 @@ export function resolveCapabilityProviderAgentId(
surface,
hint: "Pass --agent <id> or set agents.defaults.systemAgent.agentId.",
});
if (!listAgentIds(cfg).includes(agentId)) {
throw new Error(
`Unknown agent id "${agentId}". Run \`openclaw agents list\` to see configured agents.`,
);
}
return agentId;
return resolveConfiguredAgentId(cfg, agentId);
}
export function resolveCapabilityAgentOption(