Skip to content

Commit f383456

Browse files
committed
fix(active-memory): match inherited missing memory tool errors
1 parent f6d959b commit f383456

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

extensions/active-memory/index.test.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,13 @@ describe("active-memory plugin", () => {
125125
"utf8",
126126
);
127127
};
128-
const makeMemoryToolAllowlistError = (reason: string) =>
128+
const makeMemoryToolAllowlistError = (
129+
reason: string,
130+
sources = "runtime toolsAllow: memory_recall, memory_search, memory_get",
131+
) =>
129132
new Error(
130133
`No callable tools remain after resolving explicit tool allowlist ` +
131-
`(runtime toolsAllow: memory_recall, memory_search, memory_get); ${reason}. ` +
134+
`(${sources}); ${reason}. ` +
132135
`Fix the allowlist or enable the plugin that registers the requested tool.`,
133136
);
134137
const hasDebugLine = (needle: string) =>
@@ -1683,6 +1686,32 @@ describe("active-memory plugin", () => {
16831686
expect(lines.join("\n")).not.toContain("status=unavailable");
16841687
});
16851688

1689+
it("skips missing memory tools when the allowlist error includes inherited sources", async () => {
1690+
const sessionKey = "agent:main:missing-memory-tools-with-policy-source";
1691+
hoisted.sessionStore[sessionKey] = {
1692+
sessionId: "s-missing-memory-tools-with-policy-source",
1693+
updatedAt: 0,
1694+
};
1695+
const error = makeMemoryToolAllowlistError(
1696+
"no registered tools matched",
1697+
"tools.allow: *, lobster; runtime toolsAllow: memory_recall, memory_search, memory_get",
1698+
);
1699+
expect(__testing.isMissingRegisteredMemoryToolsError(error)).toBe(true);
1700+
runEmbeddedPiAgent.mockRejectedValueOnce(error);
1701+
1702+
const result = await hooks.before_prompt_build(
1703+
{ prompt: "what wings should i order? missing memory tools with policy", messages: [] },
1704+
{ agentId: "main", trigger: "user", sessionKey, messageProvider: "webchat" },
1705+
);
1706+
1707+
expect(result).toBeUndefined();
1708+
expect(hasDebugLine("no memory tools registered")).toBe(true);
1709+
expect(hasWarnLine("No callable tools remain")).toBe(false);
1710+
expect(getActiveMemoryLines(sessionKey)).toEqual([
1711+
expect.stringContaining("🧩 Active Memory: status=empty"),
1712+
]);
1713+
});
1714+
16861715
it.each([
16871716
["disabled tools", "tools are disabled for this run"],
16881717
["models without tool support", "the selected model does not support tools"],

extensions/active-memory/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ const DEFAULT_TRANSCRIPT_DIR = "active-memory";
4242
const DEFAULT_CIRCUIT_BREAKER_MAX_TIMEOUTS = 3;
4343
const DEFAULT_CIRCUIT_BREAKER_COOLDOWN_MS = 60_000;
4444
const ACTIVE_MEMORY_TOOL_ALLOWLIST = ["memory_recall", "memory_search", "memory_get"] as const;
45-
const MISSING_REGISTERED_MEMORY_TOOLS_ERROR_MESSAGE =
46-
`No callable tools remain after resolving explicit tool allowlist (` +
47-
`runtime toolsAllow: ${ACTIVE_MEMORY_TOOL_ALLOWLIST.join(", ")}` +
48-
`); no registered tools matched. Fix the allowlist or enable the plugin that registers the requested tool.`;
4945
const TOGGLE_STATE_FILE = "session-toggles.json";
5046
const DEFAULT_PARTIAL_TRANSCRIPT_MAX_CHARS = 32_000;
5147
const DEFAULT_TRANSCRIPT_READ_MAX_LINES = 2_000;
@@ -500,8 +496,15 @@ function normalizeOptionalString(value: unknown): string | undefined {
500496
}
501497

502498
function isMissingRegisteredMemoryToolsError(error: unknown): boolean {
499+
if (!(error instanceof Error)) {
500+
return false;
501+
}
502+
const message = error.message.trim();
503503
return (
504-
error instanceof Error && error.message.trim() === MISSING_REGISTERED_MEMORY_TOOLS_ERROR_MESSAGE
504+
message.startsWith("No callable tools remain after resolving explicit tool allowlist (") &&
505+
message.includes(`runtime toolsAllow: ${ACTIVE_MEMORY_TOOL_ALLOWLIST.join(", ")}`) &&
506+
message.includes("; no registered tools matched.") &&
507+
message.endsWith("Fix the allowlist or enable the plugin that registers the requested tool.")
505508
);
506509
}
507510

0 commit comments

Comments
 (0)