Feature/memory pr (#894)

* 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(cli): add /knowledge command to manage native memory

- Add /knowledge enable <yes|no> to toggle Knowledge Graph learning\n- Add /knowledge clear to reset memory\n- Add persistent knowledgeGraphEnabled setting to global config\n- Integrated user setting into the query execution loop

* feat(cli): add /knowledge command (stable local-jsx version)

- Resolve conflicts between .ts and .tsx files\n- Align with LocalJSXCommandCall signature\n- Fix onDone and args errors

* test(cli): fix knowledge command tests by properly isolating global config

* fix(cli): make knowledge command defensive against undefined args and leaky tests

* fix(cli): correct data source for entity count and fix test isolation

* fix(cli): reinforce knowledge test by explicitly defining property on test config

* fix(cli): explicitly define property in test config to avoid undefined in CI

* fix(cli): make knowledge tests resistant to global config mocks in CI

* chore(memory): surgical improvements from architectural audit

- Fix: Implement entity deduplication in Knowledge Graph\n- Fix: Ensure fact extraction from user messages in query loop\n- Fix: Refine regexes for better quality learning (less noise)

---------

Co-authored-by: LifeJiggy <Bloomtonjovish@gmail.com>
This commit is contained in:
3kin0x
2026-04-25 01:19:41 +02:00
committed by GitHub
parent ff2a380723
commit 44f9cac70d
10 changed files with 247 additions and 84 deletions

View File

@@ -253,7 +253,10 @@ async function* queryLoop(
Terminal
> {
// Start a new turn for multi-turn context tracking
if (feature('MULTI_TURN_CONTEXT')) {
if (
feature('MULTI_TURN_CONTEXT') &&
getGlobalConfig().knowledgeGraphEnabled
) {
const { startNewTurn } = await import('./utils/multiTurnContext.js')
startNewTurn()
}
@@ -374,6 +377,16 @@ async function* queryLoop(
let messagesForQuery = [...getMessagesAfterCompactBoundary(messages)]
// Extract facts and update phase from the latest message (user input or tool result)
if (
feature('CONVERSATION_ARC') &&
getGlobalConfig().knowledgeGraphEnabled &&
messagesForQuery.length > 0
) {
const { updateArcPhase } = await import('./utils/conversationArc.js')
updateArcPhase([messagesForQuery[messagesForQuery.length - 1]])
}
let tracking = autoCompactTracking
// Enforce per-message budget on aggregate tool result size. Runs BEFORE
@@ -1523,7 +1536,10 @@ async function* queryLoop(
queryCheckpoint('query_tool_execution_end')
// Track multi-turn context after tool execution
if (feature('MULTI_TURN_CONTEXT')) {
if (
feature('MULTI_TURN_CONTEXT') &&
getGlobalConfig().knowledgeGraphEnabled
) {
const { addMessageToTurn, addToolCallToTurn } = await import(
'./utils/multiTurnContext.js'
)
@@ -1539,7 +1555,10 @@ async function* queryLoop(
}
// Update conversation arc phase
if (feature('CONVERSATION_ARC')) {
if (
feature('CONVERSATION_ARC') &&
getGlobalConfig().knowledgeGraphEnabled
) {
const { updateArcPhase } = await import('./utils/conversationArc.js')
updateArcPhase([assistantMessage])
}