fix(cli): upgrade legacy mcp session reuse

This commit is contained in:
Ayaan Zaidi
2026-04-22 15:12:30 +05:30
parent 18869acf46
commit 7a2203be50
2 changed files with 32 additions and 1 deletions

View File

@@ -178,6 +178,37 @@ describe("cli-session helpers", () => {
).toEqual({ invalidatedReason: "mcp" });
});
it("falls back to legacy MCP config hashes when stored resume hashes are absent", () => {
const binding = {
sessionId: "cli-session-1",
authProfileId: "anthropic:work",
authEpoch: "auth-epoch-a",
extraSystemPromptHash: "prompt-a",
mcpConfigHash: "mcp-config-a",
};
expect(
resolveCliSessionReuse({
binding,
authProfileId: "anthropic:work",
authEpoch: "auth-epoch-a",
extraSystemPromptHash: "prompt-a",
mcpConfigHash: "mcp-config-a",
mcpResumeHash: "mcp-resume-a",
}),
).toEqual({ sessionId: "cli-session-1" });
expect(
resolveCliSessionReuse({
binding,
authProfileId: "anthropic:work",
authEpoch: "auth-epoch-a",
extraSystemPromptHash: "prompt-a",
mcpConfigHash: "mcp-config-b",
mcpResumeHash: "mcp-resume-a",
}),
).toEqual({ invalidatedReason: "mcp" });
});
it("clears provider-scoped and global CLI session state", () => {
const entry: SessionEntry = {
sessionId: "openclaw-session",

View File

@@ -152,7 +152,7 @@ export function resolveCliSessionReuse(params: {
return { invalidatedReason: "system-prompt" };
}
const storedMcpResumeHash = normalizeOptionalString(binding?.mcpResumeHash);
if (storedMcpResumeHash || currentMcpResumeHash) {
if (storedMcpResumeHash && currentMcpResumeHash) {
if (storedMcpResumeHash !== currentMcpResumeHash) {
return { invalidatedReason: "mcp" };
}