GitHub
Examples

Combined Workflow

The Grand Finale: An end-to-end example demonstrating the full 'Memory Cycle'.

End-to-End
Scenario: Emma decides to run a marathon

The Memory Cycle

Real applications don't use just one memory type. They combine them. In this workflow, we see how 5 different memory modules come together to answer a single question.

1

Ingestion (Priming)

We load a "Marathon Training Manual" into Semantic Memory.

2

Interaction (Episodic)

Emma chats about her goal. "I want to run a marathon next month." We store this in Episodic Memory.

3

Context (Short-term)

We flag "current_goal: marathon" in Short-term Memory to keep it in focus.

4

Reasoning (Combined Query)

We ask: "Is it realistic for Emma to run a marathon next month?"

Code Example

# 1. Semantic: Knowledge of Marathons
client.memory.facts.add_fact("Marathon training requires 16-20 weeks.", ...)
# 2. Episodic: Emma's History
# System knows she started running only 2 weeks ago (from previous episodes)
client.memory.episodes.create(..., event_data={"msg": "I want to do it next month!"})
# 3. Personalization: Her Preferences
# System knows she values "Safety"
# 4. The Unified Query
# Combines: Fact (Needs 16 weeks) + Episode (Started 2 weeks ago) + Preference (Safety)
response = client.queries.execute_unified(
query="Is it realistic for Emma to run a marathon next month?",
user_id="emma_2024",
include_sources=True
)
print(response.answer)
# Expected Output:
# "No, it is likely not realistic. Marathon training usually takes 16-20 weeks,
# and records show Emma started running only 2 weeks ago. Given her preference
# for 'Safety', rushing this could risk injury."

Key Takeaways

The power of the Functor SDK isn't in any single module, but in how they work together. The execute_unified query automatically synthesizes facts, history, and preferences to provide a truly intelligent answer.