Skip to content

Commit f546d05

Browse files
committed
fix(memory-core): force exit after memory search --json output
Fixes #91821
1 parent 52bc2a1 commit f546d05

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

extensions/memory-core/src/cli.runtime.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,23 @@ export async function runMemorySearch(
12711271
typeof (manager as { status?: () => { workspaceDir?: string } }).status === "function"
12721272
? manager.status().workspaceDir
12731273
: undefined;
1274+
if (opts.json) {
1275+
defaultRuntime.writeJson({ results });
1276+
if (dreamingEnabled && workspaceDir) {
1277+
void recordShortTermRecalls({
1278+
workspaceDir,
1279+
query,
1280+
results,
1281+
timezone: dreaming.timezone,
1282+
}).catch(() => {
1283+
// Recall tracking is best-effort and must not block normal search results.
1284+
});
1285+
}
1286+
if (!process.env.VITEST) {
1287+
setImmediate(() => process.exit(process.exitCode ?? 0));
1288+
}
1289+
return;
1290+
}
12741291
if (dreamingEnabled) {
12751292
void recordShortTermRecalls({
12761293
workspaceDir,
@@ -1281,10 +1298,6 @@ export async function runMemorySearch(
12811298
// Recall tracking is best-effort and must not block normal search results.
12821299
});
12831300
}
1284-
if (opts.json) {
1285-
defaultRuntime.writeJson({ results });
1286-
return;
1287-
}
12881301
const identityWarning =
12891302
typeof manager.status === "function"
12901303
? formatMemoryIndexIdentityWarning(manager.status(), agentId)

0 commit comments

Comments
 (0)