fix(test): fix sync continuation test mock leaking across sessions

The messages() mock in 'session_id with background=false' test did not
filter by session ID, causing resolveParentContext's SDK calls for
parent-session to increment messagesCallCount. This inflated
anchorMessageCount to 4 (matching total messages), so the poll loop
could never detect new messages and always hit MAX_POLL_TIME_MS.

Fix: filter messages() mock by path.id so only target session
(ses_continue_test) increments the counter. Restore MAX_POLL_TIME_MS
from 8000 back to 2000.
This commit is contained in:
YeonGyu-Kim 2026-02-15 19:48:59 +09:00
parent 96a67e2d4e
commit aad0c3644b

View File

@ -45,7 +45,7 @@ describe("sisyphus-task", () => {
STABILITY_POLLS_REQUIRED: 1, STABILITY_POLLS_REQUIRED: 1,
WAIT_FOR_SESSION_INTERVAL_MS: 10, WAIT_FOR_SESSION_INTERVAL_MS: 10,
WAIT_FOR_SESSION_TIMEOUT_MS: 1000, WAIT_FOR_SESSION_TIMEOUT_MS: 1000,
MAX_POLL_TIME_MS: 8000, MAX_POLL_TIME_MS: 2000,
SESSION_CONTINUATION_STABILITY_MS: 50, SESSION_CONTINUATION_STABILITY_MS: 50,
}) })
cacheSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(["anthropic", "google", "openai"]) cacheSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(["anthropic", "google", "openai"])
@ -1267,52 +1267,58 @@ describe("sisyphus-task", () => {
launch: async () => mockTask, launch: async () => mockTask,
} }
let messagesCallCount = 0 let messagesCallCount = 0
const mockClient = { const mockClient = {
session: { session: {
prompt: async () => ({ data: {} }), prompt: async () => ({ data: {} }),
promptAsync: async () => ({ data: {} }), promptAsync: async () => ({ data: {} }),
messages: async () => { messages: async (args?: { path?: { id?: string } }) => {
messagesCallCount++ const sessionID = args?.path?.id
const now = Date.now() // Only track calls for the target session (ses_continue_test),
// not for parent-session calls from resolveParentContext
if (sessionID !== "ses_continue_test") {
return { data: [] }
}
messagesCallCount++
const now = Date.now()
const beforeContinuation = [ const beforeContinuation = [
{ {
info: { id: "msg_001", role: "user", time: { created: now } }, info: { id: "msg_001", role: "user", time: { created: now } },
parts: [{ type: "text", text: "Previous context" }], parts: [{ type: "text", text: "Previous context" }],
}, },
{ {
info: { id: "msg_002", role: "assistant", time: { created: now + 1 }, finish: "end_turn" }, info: { id: "msg_002", role: "assistant", time: { created: now + 1 }, finish: "end_turn" },
parts: [{ type: "text", text: "Previous result" }], parts: [{ type: "text", text: "Previous result" }],
}, },
] ]
if (messagesCallCount === 1) { if (messagesCallCount === 1) {
return { data: beforeContinuation } return { data: beforeContinuation }
} }
return { return {
data: [ data: [
...beforeContinuation, ...beforeContinuation,
{ {
info: { id: "msg_003", role: "user", time: { created: now + 2 } }, info: { id: "msg_003", role: "user", time: { created: now + 2 } },
parts: [{ type: "text", text: "Continue the task" }], parts: [{ type: "text", text: "Continue the task" }],
}, },
{ {
info: { id: "msg_004", role: "assistant", time: { created: now + 3 }, finish: "end_turn" }, info: { id: "msg_004", role: "assistant", time: { created: now + 3 }, finish: "end_turn" },
parts: [{ type: "text", text: "This is the continued task result" }], parts: [{ type: "text", text: "This is the continued task result" }],
}, },
], ],
} }
}, },
status: async () => ({ data: { "ses_continue_test": { type: "idle" } } }), status: async () => ({ data: { "ses_continue_test": { type: "idle" } } }),
},
config: { get: async () => ({ data: { model: SYSTEM_DEFAULT_MODEL } }) },
app: {
agents: async () => ({ data: [] }),
}, },
config: { get: async () => ({ data: { model: SYSTEM_DEFAULT_MODEL } }) }, }
app: {
agents: async () => ({ data: [] }),
},
}
const tool = createDelegateTask({ const tool = createDelegateTask({
manager: mockManager, manager: mockManager,