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.

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.

Action State

Action states create engagement fields where the agent directly interacts with clients. They require careful design with balanced constraints to create optimal movement paths.

Required Parameters

  • type: Must be "action"

  • objective: Clear statement of the state's goal

  • actions: Ordered list of client-facing interaction steps

  • intra_state_navigation_guidelines: Rules for action sequencing and exit condition selection

  • action_guidelines: Behavioral rules for the agent

  • boundary_constraints: Limitations on agent behavior

  • exit_conditions: List of conditions that trigger state transitions

Optional Parameters

  • included_contexts: Additional context information

  • message_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:

  1. Prevents Loops: Avoids repetitive cycles of states that don't make progress toward goals

  2. Prevents Bad Traversals: Eliminates paths that don't properly consider the more global problem space view

  3. 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

  1. Action State Guarantee: Agents always start and end on action states

  2. Arbitrary Steps: Agents can take an arbitrary number of internal steps before responding

  3. Quantum Composition: Each state can be composed of smaller quantas of actions (like tool calls)

  4. Internal Processing: Between action states, agents traverse internal states for reasoning, memory operations, and decision-making

  5. Hidden Complexity: Users only see the action state responses, not the internal journey

  6. 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 response

  • action → decision → reflection → action - Thoughtful evaluation

  • action → 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:

  1. 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

  2. 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

  3. 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:

  1. [A] get_therapeutic_agreement_get_focus - Acknowledges concern about therapy progress

  2. [C] recall - Retrieves past session goals, breakthroughs, and patterns

  3. [R] reflect_on_therapeutic_agreement - Analyzes the gap between expectations and experience

  4. [D] assess_focus_significance - Evaluates if this reflects deeper therapeutic resistance

  5. [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.

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

  1. 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.

  2. 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"

  3. 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

  4. 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?