diff --git a/packages/orchestration-service/src/chat/index.js b/packages/orchestration-service/src/chat/index.js index e01d339..82986e9 100644 --- a/packages/orchestration-service/src/chat/index.js +++ b/packages/orchestration-service/src/chat/index.js @@ -90,6 +90,7 @@ async function chat(externalId, userMessage, options = {}) { // 2. Fetch recent episodes for context const recentEpisodes = await memory.getRecentEpisodes(session.id, RECENT_EPISODE_LIMIT ); + const isFirstMessage = recentEpisodes.length === 0; const recentIds = new Set(recentEpisodes.map(e => e.id)); // 3. Semantic Search @@ -125,11 +126,12 @@ async function chat(externalId, userMessage, options = {}) { } async function chatStream(externalId, userMessage, onChunk, options = {}) { - console.log('[orchestration] chatStream called:', { externalId, userMessage: userMessage.slice(0, 50) }); + console.log('[orchestration] chatStream called:', { externalId, userMessage: userMessage.slice(0, 50) }); let session = await memory.getSessionByExternalId(externalId); if (!session) session = await memory.createSession(externalId); const recentEpisodes = await memory.getRecentEpisodes(session.id, RECENT_EPISODE_LIMIT); + const isFirstMessage = recentEpisodes.length === 0; const recentIds = new Set(recentEpisodes.map(e => e.id)); const semanticEpisodes = await getSemanticEpisodes(userMessage, session.id, recentIds); @@ -176,7 +178,6 @@ async function chatStream(externalId, userMessage, onChunk, options = {}) { } } catch (err) { console.error('[orchestration] Failed to parse inference SSE event:', raw, err.message); - throw err; // add this temporarily } } }