mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 14:14:32 +00:00
fix(doctor): use gateway health status for memory search key check (#22327)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 2f02ec9403
Co-authored-by: therk <901920+therk@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
bf373eeb43
commit
8d69251475
@@ -12,7 +12,16 @@ import { resolveUserPath } from "../utils.js";
|
||||
* Check whether memory search has a usable embedding provider.
|
||||
* Runs as part of `openclaw doctor` — config-only, no network calls.
|
||||
*/
|
||||
export async function noteMemorySearchHealth(cfg: OpenClawConfig): Promise<void> {
|
||||
export async function noteMemorySearchHealth(
|
||||
cfg: OpenClawConfig,
|
||||
opts?: {
|
||||
gatewayMemoryProbe?: {
|
||||
checked: boolean;
|
||||
ready: boolean;
|
||||
error?: string;
|
||||
};
|
||||
},
|
||||
): Promise<void> {
|
||||
const agentId = resolveDefaultAgentId(cfg);
|
||||
const agentDir = resolveAgentDir(cfg, agentId);
|
||||
const resolved = resolveMemorySearchConfig(cfg, agentId);
|
||||
@@ -54,15 +63,28 @@ export async function noteMemorySearchHealth(cfg: OpenClawConfig): Promise<void>
|
||||
if (hasRemoteApiKey || (await hasApiKeyForProvider(resolved.provider, cfg, agentDir))) {
|
||||
return;
|
||||
}
|
||||
if (opts?.gatewayMemoryProbe?.checked && opts.gatewayMemoryProbe.ready) {
|
||||
note(
|
||||
[
|
||||
`Memory search provider is set to "${resolved.provider}" but the API key was not found in the CLI environment.`,
|
||||
"The running gateway reports memory embeddings are ready for the default agent.",
|
||||
`Verify: ${formatCliCommand("openclaw memory status --deep")}`,
|
||||
].join("\n"),
|
||||
"Memory search",
|
||||
);
|
||||
return;
|
||||
}
|
||||
const gatewayProbeWarning = buildGatewayProbeWarning(opts?.gatewayMemoryProbe);
|
||||
const envVar = providerEnvVar(resolved.provider);
|
||||
note(
|
||||
[
|
||||
`Memory search provider is set to "${resolved.provider}" but no API key was found.`,
|
||||
`Semantic recall will not work without a valid API key.`,
|
||||
gatewayProbeWarning ? gatewayProbeWarning : null,
|
||||
"",
|
||||
"Fix (pick one):",
|
||||
`- Set ${envVar} in your environment`,
|
||||
`- Add credentials: ${formatCliCommand(`openclaw auth add --provider ${resolved.provider}`)}`,
|
||||
`- Configure credentials: ${formatCliCommand("openclaw configure")}`,
|
||||
`- To disable: ${formatCliCommand("openclaw config set agents.defaults.memorySearch.enabled false")}`,
|
||||
"",
|
||||
`Verify: ${formatCliCommand("openclaw memory status --deep")}`,
|
||||
@@ -82,14 +104,28 @@ export async function noteMemorySearchHealth(cfg: OpenClawConfig): Promise<void>
|
||||
}
|
||||
}
|
||||
|
||||
if (opts?.gatewayMemoryProbe?.checked && opts.gatewayMemoryProbe.ready) {
|
||||
note(
|
||||
[
|
||||
'Memory search provider is set to "auto" but the API key was not found in the CLI environment.',
|
||||
"The running gateway reports memory embeddings are ready for the default agent.",
|
||||
`Verify: ${formatCliCommand("openclaw memory status --deep")}`,
|
||||
].join("\n"),
|
||||
"Memory search",
|
||||
);
|
||||
return;
|
||||
}
|
||||
const gatewayProbeWarning = buildGatewayProbeWarning(opts?.gatewayMemoryProbe);
|
||||
|
||||
note(
|
||||
[
|
||||
"Memory search is enabled but no embedding provider is configured.",
|
||||
"Semantic recall will not work without an embedding provider.",
|
||||
gatewayProbeWarning ? gatewayProbeWarning : null,
|
||||
"",
|
||||
"Fix (pick one):",
|
||||
"- Set OPENAI_API_KEY, GEMINI_API_KEY, VOYAGE_API_KEY, or MISTRAL_API_KEY in your environment",
|
||||
`- Add credentials: ${formatCliCommand("openclaw auth add --provider openai")}`,
|
||||
`- Configure credentials: ${formatCliCommand("openclaw configure")}`,
|
||||
`- For local embeddings: configure agents.defaults.memorySearch.provider and local model path`,
|
||||
`- To disable: ${formatCliCommand("openclaw config set agents.defaults.memorySearch.enabled false")}`,
|
||||
"",
|
||||
@@ -145,3 +181,21 @@ function providerEnvVar(provider: string): string {
|
||||
return `${provider.toUpperCase()}_API_KEY`;
|
||||
}
|
||||
}
|
||||
|
||||
function buildGatewayProbeWarning(
|
||||
probe:
|
||||
| {
|
||||
checked: boolean;
|
||||
ready: boolean;
|
||||
error?: string;
|
||||
}
|
||||
| undefined,
|
||||
): string | null {
|
||||
if (!probe?.checked || probe.ready) {
|
||||
return null;
|
||||
}
|
||||
const detail = probe.error?.trim();
|
||||
return detail
|
||||
? `Gateway memory probe for default agent is not ready: ${detail}`
|
||||
: "Gateway memory probe for default agent is not ready.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user