Summary
In this chapter, we equipped agents with two useful skill sets to make them more intelligent: memory and knowledge.
We started by implementing short-term memory, manually tracking message history, and using the Sessions
class to support multi-turn conversations. We addressed the challenge of growing context windows by introducing the sliding message window and message summarization techniques.
Next, we explored long-term memory. We made agent memory persistent across sessions using SQLiteSession
with a file-backed database, and introduced structured memory recall through tool-calling. This approach enabled agents to store only the most relevant facts, reducing memory bloat while increasing recall precision.
We then looked at two distinct types of model knowledge:
- Training knowledge, which is the static information “baked into” the model during its initial training.
- Retrieved knowledge, which is the dynamic, context-specific data fetched...