Managing State Across Interactions › Handling State Conflicts

Michael BrenndoerferJuly 11, 20251 min read
AI Agent HandbookAll chapters
Part 7 of 15Agent State and Architecture - Putting It All Together
Chapter 20Managing State Across Interactions › Handling State Conflicts
Reading section 6 of 13 · Handling State Conflicts · 1 minSection 6 of 13 · 1 min

Book contents

Section 6 of 13 · 1 min read

Managing State Across Interactions › Handling State ConflictsOne section · Sections in this chapter6 / 13 ↓

Sometimes different tiers of state can conflict. What if the user's persistent preference says they like morning flights, but in this session they've been booking evening flights?

The general rule: more recent state takes precedence, but acknowledge the conflict:

In[10]:
Code
def resolve_preference_conflict(self, persistent_pref: str, session_behavior: str) -> str:
    """Handle when session behavior conflicts with persistent preferences"""
    return f"""I notice you usually prefer {persistent_pref}, but today you've been 
choosing {session_behavior}. Should I update your preference, or is today an exception?"""

This gives the user control and makes the agent's reasoning transparent.