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.
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
included_contexts
: Additional context informationmessage_metadata
: Metadata about messages in this state
Example
{
"engage_client_on_in_scope_topic": {
"type": "action",
"objective": "Engage the client on their current query or queries in order of severity, always personalizing responses to your understanding of the user, while handling any natural topic changes within the conversation",
"actions": [
"Address all of the user's queries. Provide upfront value quickly in your response before asking follow up questions...",
"Ask specific, detailed follow up questions to personalize my response.",
"Handle any topic changes within the natural flow of conversation...",
"..."
],
"intra_state_navigation_guidelines": [
"When client introduces a new topic, handle it within this state rather than triggering a state change",
"Track the current topic being discussed in the conversation context",
"If client changes topic, explicitly acknowledge the change and continue engagement on new topic",
"..."
],
"action_guidelines": [
"Personalize all responses to the client's user model and your understanding of the user...",
"Provide upfront value quickly in your response before asking follow up questions...",
"..."
],
"boundary_constraints": [
"Never trigger state changes for topic switches",
"Never force the client back to a previous topic unless they request it",
"..."
],
"exit_conditions": [
{
"description": "The client has finished discussing the current topic and there are potentially other topics to review...",
"next_state": "reflect_on_conversation_topics"
},
{
"description": "The client strongly and explicitly requests to immediately terminate the session",
"next_state": "end_session"
}
],
"message_metadata": [
"coaching_session",
"focused_engagement"
],
"included_contexts": ["task"]
}
}
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:
START(new user) -> [A] welcome_patient
START(returning user) -> [A] welcome_patient
[A] welcome_patient
(Client ready to proceed with check-in) -> [A] medication_adherence_check
[A] medication_adherence_check
(Medication information provided) -> [A] vasodilator_check
(Medication concerns identified) -> [A] assess_medication_impact
...
[A] check_chest_pain
(No concerning findings) -> [A] check_shortness_of_breath
(Concerning features present) -> [R] reflect_on_session_data
...
[R] reflect_on_session_data -> [D] determine_exercise_clearance
[D] determine_exercise_clearance
(All criteria met) -> [A] summarize_recommendations_approved
(Disqualifying findings) -> [A] summarize_recommendations_disqualified
...
[A] patient_questions
(No further questions) -> [A] end_session
[A] end_session -> END
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?