Feature/memory pr (#889)
* feat: multi-turn context and conversation arc memory PR 2E - Section 2.9, 2.10: - Add multiTurnContext.ts with turn tracking and state preservation - Add conversationArc.ts with goal/decision/milestone tracking - Wire into query.ts after tool execution - Feature-flags: MULTI_TURN_CONTEXT, CONVERSATION_ARC - Add comprehensive tests (22 passing) * feat(memory): resolve review blockers and integrate native Knowledge Graph into Conversation Arcs - Fix: Extract text from production block arrays in phase detector\n- Fix: Ensure proper turn segmentation in query loop\n- Fix: Respect options in multi-turn context tracker\n- Feat: Add native Knowledge Graph (Entities/Relations) to ConversationArc architecture\n- Test: Comprehensive test suite for all fixes and new graph features * test(perf): add automated performance benchmarks for Knowledge Graph extraction and summary --------- Co-authored-by: LifeJiggy <Bloomtonjovish@gmail.com>
This commit is contained in:
28
src/query.ts
28
src/query.ts
@@ -252,6 +252,12 @@ async function* queryLoop(
|
||||
| ToolUseSummaryMessage,
|
||||
Terminal
|
||||
> {
|
||||
// Start a new turn for multi-turn context tracking
|
||||
if (feature('MULTI_TURN_CONTEXT')) {
|
||||
const { startNewTurn } = await import('./utils/multiTurnContext.js')
|
||||
startNewTurn()
|
||||
}
|
||||
|
||||
// Immutable params — never reassigned during the query loop.
|
||||
const {
|
||||
systemPrompt,
|
||||
@@ -1516,6 +1522,28 @@ async function* queryLoop(
|
||||
}
|
||||
queryCheckpoint('query_tool_execution_end')
|
||||
|
||||
// Track multi-turn context after tool execution
|
||||
if (feature('MULTI_TURN_CONTEXT')) {
|
||||
const { addMessageToTurn, addToolCallToTurn } = await import(
|
||||
'./utils/multiTurnContext.js'
|
||||
)
|
||||
addMessageToTurn(assistantMessage)
|
||||
for (const toolUse of toolUseBlocks) {
|
||||
addToolCallToTurn({
|
||||
id: toolUse.id,
|
||||
name: toolUse.name,
|
||||
input: toolUse.input as Record<string, unknown>,
|
||||
timestamp: Date.now(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Update conversation arc phase
|
||||
if (feature('CONVERSATION_ARC')) {
|
||||
const { updateArcPhase } = await import('./utils/conversationArc.js')
|
||||
updateArcPhase([assistantMessage])
|
||||
}
|
||||
|
||||
// Generate tool use summary after tool batch completes — passed to next recursive call
|
||||
let nextPendingToolUseSummary:
|
||||
| Promise<ToolUseSummaryMessage | null>
|
||||
|
||||
Reference in New Issue
Block a user