mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
feat: implement SDK session ID handling for conversation continuity
- Added support for resuming conversations using the Claude SDK session ID. - Updated the ClaudeProvider to conditionally resume sessions based on the presence of a session ID and conversation history. - Enhanced the AgentService to capture and store the SDK session ID from incoming messages, ensuring continuity in conversations.
This commit is contained in:
@@ -33,6 +33,7 @@ interface Session {
|
||||
abortController: AbortController | null;
|
||||
workingDirectory: string;
|
||||
model?: string;
|
||||
sdkSessionId?: string; // Claude SDK session ID for conversation continuity
|
||||
}
|
||||
|
||||
interface SessionMetadata {
|
||||
@@ -200,6 +201,7 @@ export class AgentService {
|
||||
abortController: session.abortController!,
|
||||
conversationHistory:
|
||||
conversationHistory.length > 0 ? conversationHistory : undefined,
|
||||
sdkSessionId: session.sdkSessionId, // Pass SDK session ID for resuming
|
||||
};
|
||||
|
||||
// Build prompt content with images
|
||||
@@ -221,6 +223,14 @@ export class AgentService {
|
||||
const toolUses: Array<{ name: string; input: unknown }> = [];
|
||||
|
||||
for await (const msg of stream) {
|
||||
// Capture SDK session ID from any message
|
||||
if (msg.session_id && !session.sdkSessionId) {
|
||||
session.sdkSessionId = msg.session_id;
|
||||
console.log(
|
||||
`[AgentService] Captured SDK session ID: ${msg.session_id}`
|
||||
);
|
||||
}
|
||||
|
||||
if (msg.type === "assistant") {
|
||||
if (msg.message?.content) {
|
||||
for (const block of msg.message.content) {
|
||||
|
||||
Reference in New Issue
Block a user