State-Based Architecture
A context graph is a structured topological field of interconnected states that guides agent behavior and decision-making. Context graphs implement a hierarchical state machine (HSM) architecture, where states are organized in a structured hierarchy that enables efficient organization of complex problem spaces.
State Types
Each state type serves a specific purpose in managing conversation flow and agent behavior.
Context Graphs orchestrate agent behavior through a structured hierarchy of states:
Decision States: Choose optimal actions based on real-time data and objectives, drawing on the integrated Memory-Knowledge-Reasoning (M-K-R) system.
Action States: Execute defined tasks with clear rules and constraints, powered by the current M-K-R context.
Reflection States: Allow introspection and strategic reasoning. These are critical junctures in the M-K-R cycle, where the agent might re-evaluate its understanding (Knowledge), recontextualize Memory, and refine its Reasoning pathways before proceeding.
Recall States: Allow explicit integration with user memory to increase personalization. These states directly tap into the Memory component of M-K-R, bringing historical context to bear on current Knowledge application and Reasoning.
Annotation States: Clarify and segment complex interactions.
Side-Effect States: Touch points for external system interaction, enabling Actions.
State Reference
Decision
Choose optimal actions based on real-time inputs
Routing between workflows, escalation decisions
Action
Deliver user-facing responses within guardrails
Conversational turns, report delivery
Reflection
Re-assess plan or safety posture
Post-incident review, plan recalibration
Recall
Pull memory into active context
Longitudinal review, personalization pulls
Annotation
Tag context for downstream processing
Segment transcripts, mark compliance events
Side-Effect (Action Gateway)
Stage and trigger external systems or tools without user-facing output
Schedule follow-ups, call APIs, write structured logs
Designing a State
Side-Effect states exist to produce effects outside the conversation loop. They hand off control to Actions and other tooling, ensuring that every external operation is versioned and auditable without overloading Action states with non-dialog responsibilities.
Each state definition should answer five questions before it ships to production:
Objective – What outcome must be true before the state can exit?
Guidance – Which ordered actions or prompts keep the model on the intended path?
Boundaries – Which behaviors are forbidden, especially for safety or compliance?
Exit criteria – What explicit signals trigger each transition, and which state should follow?
Tooling & memory configuration – Which tool calls are exposed in this state and should active memory retrieval be skipped?
In the API schema this maps to action_tool_call_specs, exit_condition_tool_call_specs, and the skip_active_memory_retrieval flag for each state.
Action State Implementation Example
Each state type has its unique set of structured parameters and implementation best practices. For example, see below for a more detailed summary of the Action State.
Required Parameters
type: Must be "action"objective: Clear statement of the state's goalactions: Ordered list of client-facing interaction stepsintra_state_navigation_guidelines: Rules for action sequencing and exit condition selectionaction_guidelines: Behavioral rules for the agentboundary_constraints: Limitations on agent behaviorexit_conditions: List of conditions that trigger state transitions
Optional Parameters
action_tool_call_specs: Optional tool calls the agent may use while executing actionsexit_condition_tool_call_specs: Tool calls available when evaluating exit conditionsskip_active_memory_retrieval: Set totruewhen the state should not trigger active memory retrieval on entry
Example
Reasoning States and Abstract Topology
Reasoning states (which include Decision and Reflection states) play a critical role in the traversal of context graphs, acting as key nodes in the integrated Memory-Knowledge-Reasoning (M-K-R) process. They impact traversal by providing a local and global view of the problem space via an abstract topology. This abstract topological view:
Prevents Loops: Avoids repetitive cycles of states that don't make progress toward goals
Prevents Bad Traversals: Eliminates paths that don't properly consider the more global problem space view
Optimizes Transitions: Prevents both premature and late transitions to adjacent problem spaces even without perfect exit conditions
The abstract topology effectively provides a "map" of the entire problem space, allowing the agent to make informed decisions about where to go next based on both immediate context and the overall structure of the problem. This is similar to how a human expert would consider the current details of a situation and their broader understanding of the entire domain when making decisions.
Here's a simplified example of an abstract topology for a medical check-in flow:
This abstract topology provides a concise map of the problem space, showing key states and transitions. With this global view, the agent can make informed decisions about state traversal, ensuring that the conversation follows a coherent and purposeful path while avoiding problematic patterns like loops or premature transitions.
Multi-State Traversal: The Hidden Journey Between Action States
A fundamental aspect of context graphs is that agents can traverse multiple states internally before responding to users. The core guarantee: agents always start and end on action states, but the journey between them can involve sophisticated internal processing that remains invisible to users.
Core Traversal Principles
Action State Guarantee: Agents always start and end on action states
Arbitrary Steps: Agents can take an arbitrary number of internal steps before responding
Quantum Composition: Each state can be composed of smaller quantas of actions (like tool calls)
Internal Processing: Between action states, agents traverse internal states for reasoning, memory operations, and decision-making
Hidden Complexity: Users only see the action state responses, not the internal journey
Response Guarantee: The only guarantee is that the agent responds in an action state
Quantum Patterns
Each interaction is composed of quantas of patterns - fundamental units of state transitions:
Basic Quantas:
action → action- Direct responseaction → decision → reflection → action- Thoughtful evaluationaction → action → action- Multi-step direct engagement
Complex Quantas:
Traversal Patterns
Each interaction follows patterns like:
[A] action → [A] action- Direct transition[A] action → [D] decision → [R] reflection → [A] action- Thoughtful evaluation[A] action → [R] reflection → [D] decision → [A] action- Analysis before routing[A] action → [C] recall → [D] decision → [A] action- Memory-informed decision
These patterns represent "quanta" of agent behavior - fundamental units of processing that compose into complex interactions.
Three Levels of Navigation Intelligence
Agents navigate using three complementary information levels that provide both global and local perspectives:
Conceptual Level (Description)
The "why" - service philosophy and methodology
Sparse, conceptual global view of the entire service
Provides understanding of overall purpose and approach
Rich, detailed description of how the service should work
Structural Level (Abstract Topology)
The "what" - map of possible state transitions
Zoomed-out global view showing all states and connections
Enables seeing multiple steps ahead in the problem space
Allows strategic path planning across the entire graph
Local Level (State Guidelines)
The "how" - specific execution instructions
Dense, high-resolution local view of current state
Detailed objectives, actions, and boundaries
Precise exit conditions that determine next transitions
This multi-resolution approach is powerful because it gives agents both the "forest and the trees" - they can see the big picture through sparse conceptual and structural views while having dense, detailed guidance for local execution. This enables intelligent navigation that balances global strategy with local precision.
Example: Hidden Therapeutic Processing
User: "I feel like I'm not making progress in therapy"
Internal traversal:
[A] get_therapeutic_agreement_get_focus- Acknowledges concern about therapy progress[C] recall- Retrieves past session goals, breakthroughs, and patterns[R] reflect_on_therapeutic_agreement- Analyzes the gap between expectations and experience[D] assess_focus_significance- Evaluates if this reflects deeper therapeutic resistance[A] get_therapeutic_agreement_get_meaningfulness- Explores what progress means to them
User experience: The therapist responds with deep understanding of their therapeutic journey, acknowledging past work while exploring their current feelings, all without revealing the complex internal analysis.
Navigation Strategies
For Non-Intuitive Transitions: When jumps might surprise users
Highly detailed exit conditions
Explicit descriptions of when/why transitions occur
Clear documentation of edge cases
For Intuitive Navigation: When flow should feel natural
Rich conceptual descriptions
Lighter transition guidelines
Agent discretion based on context
Implementation Considerations
Context Density Calibration (Entropy Control in Practice):
High-density (Low Entropy): "Verify all required regulatory compliance elements while maintaining strict protocol adherence"
Medium-density (Medium Entropy): "Engage the client on their current query while handling natural topic changes within conversation flow"
Low-density (High Entropy): "Create space for open exploration of possibilities without excessive structure"
This density calibration demonstrates strategic entropy management—applying tight constraints when precision matters (compliance), balanced guidance for operational workflows, and minimal constraints for creative exploration.
Action Sequencing:
Define action sequences that create natural progressive movement
Balance between prescriptive steps and open exploration
Example from healthcare implementation: "Address user queries → Ask personalized follow-up questions → Handle topic changes → Track conversation context"
Navigation Guidelines Implementation:
Define intra-state movement behaviors
Example: "When client introduces a new topic, handle it within this state rather than triggering a state change"
Implementation shows how agent navigates within a single region of the field
Exit Condition Design:
Create clear, detectable boundaries for state transitions
Support both simple state transitions and cross-graph navigation
Include safety exits for unexpected situations
Last updated
Was this helpful?

