GitHub
Examples

Personalization

Infer, store, and utilize user preferences to adapt agent behavior.

Intelligence Module
Scenario: Learning Emma's communication style

When to Use

Use this module to make your agent "feel" like it knows the user. It explicitly manages preferences distinct from general facts. Perfect for:

  • Communication style (Formal vs Casual)
  • User interests and hobbies
  • Settings and defaults (Dark mode, Metric system)

Key Operations

add_preference()

Explicitly set a user preference

infer_preferences()

Auto-discover prefs from chat history

Code Example

We can add preferences manually or let the system infer them from a conversation transcript.

# 1. Explicitly add a preference
client.memory.personalization.add_preference(
user_id="emma_2024",
preference_key="communication_style",
preference_value="Warm, supportive, and concise",
source="onboarding_form"
)
# 2. Infer from interaction
# The system reads the chat and realizes she likes running
client.memory.personalization.infer_preferences(
user_id="emma_2024",
interaction_history=[
{"role": "user", "content": "I really love my morning runs, they clear my head."}
]
)
# Result: Adds preference "interest: running" with high confidence

Key Takeaways

  • Explicit vs Implicit: supports both "User told me" and "I guessed it".
  • Conflict Resolution: Use reconcile() (not shown) to handle conflicting preferences (e.g., User liked running, now hates it).
  • Personalization context is automatically injected into get_context() calls for relevant users.