Back to articles
Agents in 60 lines of python : Part 6

Agents in 60 lines of python : Part 6

via Dev.to PythonArun Purushothaman

Memory Across Runs Lesson 6 of 9 — A Tour of Agents The entire AI agent stack in 60 lines of Python. State tracks everything — turns, tool calls, results. But close the session and it's gone. Start a new conversation and ask the agent your name. Blank. It has no idea. ChatGPT remembers your name across chats. Here's how that works — and it's simpler than you think. The problem Your agent has a state dict. It records everything that happens during a run. But state lives in memory. When the process ends, the dict disappears. Next time you run the agent, it starts fresh — no history, no context, no memory of previous conversations. This is the difference between a chatbot and an assistant. An assistant remembers. The fix: a tool called remember Give the agent a tool called remember . It doesn't do anything clever — it saves a key-value pair to a dictionary. That dictionary gets written to disk (or a database) and loaded back into the system prompt on every new run. The agent calls remembe

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
2 views

Related Articles