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:
| Output | What it contains | Retrieval method |
|---|---|---|
working_memory | WorkingMemoryEntry dicts (semantic + episodic) | Hybrid RRF (embedding + token-recall) |
memory.procedural_rules | Style directives from ProceduralProfile | Full profile load (not query-based) |
diagnostics | Hit counts, store sizes, retrieval path | Written via _merge_dicts reducer |
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.
| Field | Source | Per turn? |
|---|---|---|
message | User input | Yes |
history / transcript | Checkpointer + operator.add reducer | Accumulated across turns |
working_memory | load_memory_node | Re-retrieved each turn |
memory.procedural_rules | load_memory_node | Re-loaded each turn |
crisis | crisis_gate_node | Fresh each turn |
routing.mode | Dispatcher | Fresh each turn |
progress | Checkpointer + _merge_dicts reducer | Merged across turns (exercise state persists) |
Session stage
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.