claude-mem
claude-mem copied to clipboard
fix: correct V2 SDK API to use receive() instead of stream()
The V2 Agent SDK implementation was calling sdkSession.stream() instead of the documented sdkSession.receive() method, causing a mismatch with the official API specification.
Changes
-
SDKAgent.ts (lines 129, 176): Changed
stream()→receive()for AsyncGenerator message iteration - Comments: Updated to reflect correct V2 "receive" terminology
API Alignment
The Session interface per official V2 docs:
interface Session {
send(message: string): Promise<void>;
receive(): AsyncGenerator<SDKMessage>; // Not stream()
close(): void;
}
Before:
await sdkSession.send(initPrompt);
for await (const message of sdkSession.stream()) { // ❌ Incorrect
await this.handleSDKMessage(message, session, worker);
}
After:
await sdkSession.send(initPrompt);
for await (const message of sdkSession.receive()) { // ✅ Correct
await this.handleSDKMessage(message, session, worker);
}
All other V2 API usage (unstable_v2_createSession, unstable_v2_resumeSession, unstable_v2_prompt, await using cleanup) was already correct.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.