
- Enables contextual reasoning across multiple nodes and turns.
- Tracks the system’s evolution over time, useful for audits and debugging.
- Supports iterative and adaptive behavior (e.g., agents refining their plan or tools over multiple passes).
- The graph state is a dictionary/object shared between nodes.
- Each node may add new fields or update existing ones.
- Over time the state becomes a record of inputs, intermediate decisions, tool invocations, and final output.

- Follow-up questions only make sense when prior messages are preserved.
- Tools (search, calculators, external APIs) produce outputs that should be appended to the state so later nodes can reason with them.
- Execution traces (steps_taken) help debugging, audit, and reproducibility.


- Cap chat history length (e.g., keep the last N turns).
- Expire or summarize older tool logs.
- Prune or compress
steps_takenentries for long-running flows. - Persist only what helps behavior or auditing; drop or archive the rest.

Decide what to persist based on the agent’s goals. Keep only the state that improves behavior or is required for auditing; summarize or drop the rest to maintain performance.
- State (computer science): https://en.wikipedia.org/wiki/State_(computer_science)
- For practical designs, search for “conversational memory patterns”, “agent tool logging”, and “execution tracing best practices” to find implementation examples and community patterns.