Skip to main content

Context Management

Every turn, the agent retrieves long-term memory, loads the conversation via checkpointer + reducers, and assembles the context that the response node will see.


Per-turn retrieval

load_memory_node runs on the therapeutic branch and populates:

OutputWhat it containsRetrieval method
working_memoryWorkingMemoryEntry dicts (semantic + episodic)Hybrid RRF (embedding + token-recall)
memory.procedural_rulesStyle directives from ProceduralProfileFull profile load (not query-based)
diagnosticsHit counts, store sizes, retrieval pathWritten via _merge_dicts reducer
First-turn catch-up

On the first turn of a new session (transcript length = 1), the most recent episodic arc is automatically injected as a catch-up entry — the "last time we talked..." experience — regardless of query match.


What the response node sees

Click a step to see what it does.

FieldSourcePer turn?
messageUser inputYes
history / transcriptCheckpointer + operator.add reducerAccumulated across turns
working_memoryload_memory_nodeRe-retrieved each turn
memory.procedural_rulesload_memory_nodeRe-loaded each turn
crisiscrisis_gate_nodeFresh each turn
routing.modeDispatcherFresh each turn
progressCheckpointer + _merge_dicts reducerMerged across turns (exercise state persists)

Session stage

Not yet dynamic

The session stage is set to "opening" at the start of every turn. Dynamic stage inference (opening → deepening → working → closing) is a planned enhancement — the state field and knowledge file (knowledge/session_stages.md) exist but the inference logic is not yet wired into the graph.


Prompt injection by mode

Not every mode sees the same context. Click a cell to see which context fields are injected into each mode's prompt.

Response guidance
Stage guidance
Session context
Recent history
Current message
supportive_conversation
pattern_reflection
guided_exercise
psychoeducation
realignment
crisis_response
crisis_classifier
safety_check
orientation
out_of_scope