This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

memory system no longer flodos

+27 -5
+6
src/runner/index.ts
··· 19 19 toolInFlight: false, 20 20 memoryRecallCooldowns: {}, 21 21 memoryRecallTurn: 0, 22 + memoryRecallPending: false, 22 23 deferredEvents: [], 23 24 } 24 25 ··· 189 190 }) 190 191 logMessage(convId, "user", incomingMessage) 191 192 emitUserEvent(event) 193 + // A new incoming event starts a new turn — recall once for it. 194 + state.memoryRecallPending = true 192 195 console.log("[runner] injected event from", event.source) 193 196 } 194 197 ··· 212 215 state.contextSize = 0 213 216 state.memoryRecallCooldowns = {} 214 217 state.memoryRecallTurn = 0 218 + // The wake event is the first turn — recall once for it. 219 + state.memoryRecallPending = true 215 220 216 221 const saved = await loadSession() 217 222 if (saved) { ··· 260 265 state.toolInFlight = false 261 266 state.memoryRecallCooldowns = {} 262 267 state.memoryRecallTurn = 0 268 + state.memoryRecallPending = false 263 269 flushDeferredEvents() 264 270 state.deferredEvents = [] 265 271 eventResolvers = []
+10 -5
src/runner/loop-completion.ts
··· 663 663 baseConversation = sanitizeMessages(baseConversation) 664 664 } 665 665 666 - const requestContext = await buildCompletionMessages( 667 - baseConversation, 668 - state.memoryRecallCooldowns, 669 - state.memoryRecallTurn, 670 - ) 666 + // Only run memory recall on the first step of a new turn. Re-running it on 667 + // every agentic iteration floods context with the same recalled chunks for 668 + // the same (unchanged) user message. 669 + const requestContext = state.memoryRecallPending 670 + ? await buildCompletionMessages( 671 + baseConversation, 672 + state.memoryRecallCooldowns, 673 + state.memoryRecallTurn, 674 + ) 675 + : { messages: baseConversation, recalledChunkIds: [] as number[] } 671 676 const requestMessages = requestContext.messages 672 677 673 678 if (USE_FALLBACK) {
+1
src/runner/loop.test.ts
··· 13 13 toolInFlight: false, 14 14 memoryRecallCooldowns: {}, 15 15 memoryRecallTurn: 0, 16 + memoryRecallPending: false, 16 17 } 17 18 } 18 19
+3
src/runner/loop.ts
··· 57 57 async function processAssistantTurn(convId: number, state: LoopState, hooks: LoopHooks): Promise<CycleOutcome> { 58 58 state.memoryRecallTurn += 1 59 59 const response = await fetchCompletion(state) 60 + // Recall (if any) has been applied for this turn; don't re-recall on the 61 + // follow-up iterations that work through the same incoming event. 62 + state.memoryRecallPending = false 60 63 applyUsage(state, response.usage, { 61 64 elapsedMs: response.elapsedMs, 62 65 tokensPerSecond: response.tokensPerSecond,
+6
src/runner/types.ts
··· 11 11 toolInFlight: boolean 12 12 memoryRecallCooldowns: Record<number, number> 13 13 memoryRecallTurn: number 14 + /** 15 + * True only on the first assistant step after a new incoming event. Memory 16 + * recall runs once per turn rather than on every agentic iteration so it 17 + * doesn't flood context while the assistant works through a single turn. 18 + */ 19 + memoryRecallPending: boolean 14 20 } 15 21 16 22 /** Lifecycle hooks injected by the runner orchestrator into the loop. */
+1
src/types.ts
··· 24 24 contextSize: number 25 25 memoryRecallCooldowns: Record<number, number> 26 26 memoryRecallTurn: number 27 + memoryRecallPending: boolean 27 28 }