fix: avoid crash on memory embeddings errors (#1004)
This commit is contained in:
@@ -47,18 +47,23 @@ export function createMemorySearchTool(options: {
|
||||
if (!manager) {
|
||||
return jsonResult({ results: [], disabled: true, error });
|
||||
}
|
||||
const results = await manager.search(query, {
|
||||
maxResults,
|
||||
minScore,
|
||||
sessionKey: options.agentSessionKey,
|
||||
});
|
||||
const status = manager.status();
|
||||
return jsonResult({
|
||||
results,
|
||||
provider: status.provider,
|
||||
model: status.model,
|
||||
fallback: status.fallback,
|
||||
});
|
||||
try {
|
||||
const results = await manager.search(query, {
|
||||
maxResults,
|
||||
minScore,
|
||||
sessionKey: options.agentSessionKey,
|
||||
});
|
||||
const status = manager.status();
|
||||
return jsonResult({
|
||||
results,
|
||||
provider: status.provider,
|
||||
model: status.model,
|
||||
fallback: status.fallback,
|
||||
});
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
return jsonResult({ results: [], disabled: true, error: message });
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -91,12 +96,17 @@ export function createMemoryGetTool(options: {
|
||||
if (!manager) {
|
||||
return jsonResult({ path: relPath, text: "", disabled: true, error });
|
||||
}
|
||||
const result = await manager.readFile({
|
||||
relPath,
|
||||
from: from ?? undefined,
|
||||
lines: lines ?? undefined,
|
||||
});
|
||||
return jsonResult(result);
|
||||
try {
|
||||
const result = await manager.readFile({
|
||||
relPath,
|
||||
from: from ?? undefined,
|
||||
lines: lines ?? undefined,
|
||||
});
|
||||
return jsonResult(result);
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
return jsonResult({ path: relPath, text: "", disabled: true, error: message });
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user