Merge pull request #90 from AutoMaker-Org/fix-agent-runner

feat: implement SDK session ID handling for conversation continuity
This commit is contained in:
Web Dev Cody
2025-12-14 17:49:40 -05:00
committed by GitHub
5 changed files with 40 additions and 71 deletions

View File

@@ -160,7 +160,7 @@ describe("claude-provider.ts", () => {
});
});
it("should handle conversation history", async () => {
it("should handle conversation history with sdkSessionId using resume option", async () => {
vi.mocked(sdk.query).mockReturnValue(
(async function* () {
yield { type: "text", text: "test" };
@@ -176,13 +176,18 @@ describe("claude-provider.ts", () => {
prompt: "Current message",
cwd: "/test",
conversationHistory,
sdkSessionId: "test-session-id",
});
await collectAsyncGenerator(generator);
// Should pass an async generator as prompt
const callArgs = vi.mocked(sdk.query).mock.calls[0][0];
expect(typeof callArgs.prompt).not.toBe("string");
// Should use resume option when sdkSessionId is provided with history
expect(sdk.query).toHaveBeenCalledWith({
prompt: "Current message",
options: expect.objectContaining({
resume: "test-session-id",
}),
});
});
it("should handle array prompt (with images)", async () => {

View File

@@ -103,8 +103,9 @@ describe("agent-service.ts", () => {
});
expect(result.success).toBe(true);
// Should only read file once
expect(fs.readFile).toHaveBeenCalledTimes(1);
// First call reads session file and metadata file (2 calls)
// Second call should reuse in-memory session (no additional calls)
expect(fs.readFile).toHaveBeenCalledTimes(2);
});
});