Richard Golian

1995-born. Charles University alum. Head of Performance at Mixit. 10+ years in marketing and data.

Castellano Français Slovenčina

Manage subscription Choose a plan

RSS
Newsletter
New articles to your inbox
Richard Golian

Article

AI Agent Memory: Training an Agent That Learns Between Sessions

What is an AI agent, and how AI memory lets one learn over time
Richard Golian
Richard Golian · 1 846 reads
Hi, I am Richard. On this blog, I share thoughts, personal stories, findings and what I am working on. I hope this article brings you some value.

What is an AI agent? In my own practice, an AI agent is a program that does not just answer questions, it acts. It retrieves data on a schedule, analyses what it finds, proposes the next step, and checks its own output against a standard before sending anything. That is what separates an agent from a chatbot. The harder question, and the subject of this article, is AI agent memory: whether the agent can carry what it learned in one session into the next, or whether it starts again from zero every time.

The goal I set myself

I wanted to build an agent that does not just assist. One that acts.

The idea was straightforward: configure automations to retrieve data, let the agent analyse what it finds, have it propose next steps, send those proposals somewhere for review, and through that feedback loop, gradually improve. At a certain point, once its proposed steps consistently matched what I considered good decisions, it would stop waiting for approval and start executing on its own.

Not a chatbot. Not a co-pilot. An autonomous system that earns its authority through demonstrated accuracy.

That was the goal. I wrote about parts of it in my previous article on local AI models. This is the next chapter.

WHAT I BUILT, AND WHAT IT COULD NOT DO

The first version was simple by design. But the interesting part was not what it did. The interesting part was what it could not do.

The agent runs on a schedule. It retrieves data, analyses it, and sends a report to Slack. To make sure the output was consistent, I created a schema, an approved format the agent checks itself against before sending anything. If something does not match, it corrects itself. It loops until the output passes. If something prevents it from completing the process, such as a failed LLM call, it does not send a degraded output. It sends an alert to Slack instead.

I also added positive examples. Approved outputs from previous runs that the agent can reference when producing the next one.

This felt like a solid system. And for a while, I thought it was.

THE THING THAT KEPT BOTHERING ME

Every session starts from zero.

The schema is there. The examples are there. But the agent does not know what it struggled with yesterday. It does not know which rule it keeps violating. It does not know what it has already figured out.

And that changes everything.

The self-correction loop works within a single session. Between sessions, nothing accumulates. So the inconsistency I was seeing was not a configuration problem. It was not a prompting problem.

The problem was not technical. It was structural.

SELF-CORRECTION VS SELF-IMPROVEMENT

This is where I realised something important.

Self-correction means the agent catches its own errors before sending output. It happens inside one run, against a fixed schema. The session ends, and whatever the agent learned disappears.

Self-improvement means the agent builds something across runs. Each session leaves a trace that the next session can use. Errors become rules. Rules become context. Context shapes the next output before generation even starts.

The first is a quality filter. The second is something closer to learning.

And this distinction is not just about AI agents. It is the difference between systems that repeat and systems that evolve. Between people who fix mistakes and people who stop making the same ones. Most organisations have self-correction. Very few have genuine self-improvement. The mechanism looks similar from the outside. The architecture underneath is completely different.

What I had was a good quality filter. What I was missing was the accumulation layer underneath it.

HOW TO GIVE AN AI AGENT MEMORY

This is a fair question, and one I had to work through myself.

Claude Code has a file called CLAUDE.md. It loads automatically at the start of every session. When you tell the agent to remember something for future runs, it can write it there. And next time, it will be there. That is real persistence. It is not an illusion.

So when Claude Code confirms it will remember something, it is not lying.

The problem is what "there" actually means in practice.

Continue

Join the Library

Full access to my findings, personal stories, and what I learn from the people I meet.

Join the Library · €29.99 per year What should I study in the age of AI?… I Left My Job for Several Months to Read… How I Fell in Love With Her, at First… How do you stop depending on social media? Can… How to Start With AI in a Company: Automating… Fable 5 vs Opus: I Ran the Same Audit…
Read only this one · €2,99

Get the full article by email and feel free to reply if you want to discuss it further.

Visa Mastercard Apple Pay Google Pay

Summary

I wanted to build an autonomous AI agent that improves over time, not just one that corrects itself within a single session. The distinction is between self-correction and self-improvement. Claude Code's built-in memory has limits for agents that run daily. A structured memory layer changes what is possible.

Common questions on this article's topic

What is an AI agent?
In this article, an AI agent is a program that does not only answer questions but acts: it retrieves data on a schedule, analyses it, proposes a next step, and checks its own output against an approved schema before sending anything. That is what separates an agent from a chatbot or a co-pilot. The agent described here runs on a schedule, reports to Slack, and is designed to earn autonomy through demonstrated accuracy rather than receive it by default.
Can AI have memory?
Yes, but with limits. Claude Code, for example, loads a file called CLAUDE.md at the start of every session, which gives an agent real persistent memory across runs. The persistence is genuine, not an illusion. The limitation identified in the article is that CLAUDE.md is static and unstructured: it does not organise itself or remove outdated entries, so for an agent running daily it eventually becomes noise. Giving an AI agent useful memory means adding a structured layer that records what happened, what the verdict was, and what the next session should know.
Can AI agents learn over time?
Only if experience is stored deliberately. By default every session starts from zero, because current models have no built-in mechanism for accumulating experience between runs. The article distinguishes self-correction, which catches errors inside one session, from self-improvement, where errors become rules, rules become context, and context shapes future output before generation starts. An AI agent learns over time when that accumulation layer is maintained consistently.
What is the difference between AI self-correction and self-improvement?
Self-correction means the agent catches errors within a single session, checking output against a schema and looping until it passes. When the session ends, everything learned is lost. Self-improvement means the agent builds knowledge across sessions: errors become rules, rules become context, and context shapes future output before generation even starts. In the article, this distinction is identified as the critical gap in current AI agent architectures, and the key to building systems that genuinely evolve.
What is CLAUDE.md and what are its limitations for AI agents?
CLAUDE.md is a file that Claude Code loads automatically at the start of every session, providing persistent memory across runs. When the agent is told to remember something, it writes to this file. The persistence is real, not an illusion. However, in the article, the limitation is identified: CLAUDE.md is a static, unstructured file. It does not organise itself, distinguish relevant from outdated entries, or manage its own growth. For an agent running daily over weeks, the file becomes noise rather than signal.
Why does every AI agent session start from zero?
Because current AI models have no built-in mechanism for accumulating experience between sessions. The context window is populated fresh each time. In the article, this is identified as the structural, not technical, problem: the agent does not know what it struggled with yesterday, which rules it keeps violating, or what it has already figured out. The self-correction loop works within a session. Between sessions, nothing persists unless explicitly stored.
What is a structured memory layer for AI agents?
A structured memory layer sits alongside static memory files and organises accumulated experience into categories the agent can reference selectively. Instead of loading everything into the context window every time, the agent retrieves only what is relevant to the current task. In the article, this is the solution being built: a system where errors become rules, rules become context, and the agent's behaviour improves measurably across sessions rather than resetting each time.
Can you run autonomous AI agents locally?
Yes, but with significant limitations. In the article and its predecessor on local AI models, the setup used a Mac Mini with Ollama and n8n. Basic pipelines worked: data retrieval, simple analysis, Slack alerts. But the context window limitations of local models made complex analysis impossible. For autonomous agents that need to process real-world data volumes and maintain quality over time, cloud models with larger context windows proved necessary.
What does it take to build an AI agent that earns autonomy?
In the article, the principle is that autonomy must be earned through demonstrated accuracy, not granted by default. The architecture starts with human review of every proposed action. As the agent's proposals consistently match good decisions, it gradually gains permission to act independently. This requires not just good single-session performance but genuine improvement over time, which is why the structured memory layer is essential. Without cross-session learning, the agent cannot build the track record needed to justify autonomous action.
Richard Golian

If you have any thoughts, questions, or feedback, feel free to drop me a message at mail@richardgolian.com.

NEWSLETTER
What I write about, what I am working on, what I learned.
Sent the first Sunday of the month. Unsubscribe anytime.

Related articles

What Determines a Stock Price?

In April, in the first part of this series, I wrote about an AI prediction system I had started building on my own machine. At the time the software was a few hours old and the prediction record was empty. The record since then has shown one thing: the system does not yet understand the market it is being asked to forecast. It can pull macro context, book value, earnings. But it cannot put those together into something that helps it understand the price.

23 May 2026·1 153 reads
Can AI Predict the Stock Market? Building a Calibrated System

I am building an AI system to predict the S&P 500. It runs on my own machine, uses free public data (yfinance, FRED, the Shiller dataset), and grades every forecast against reality. This series documents the build itself: the decisions, the methodology, the mistakes. What I will eventually share from the running system is a separate question, and an honest one.

26 April 2026·2 654 reads
AI sales forecast: 9 traps so far

Yesterday I could not tear myself away from the computer. When I lifted my head, it was half past eight in the evening. I had been sitting alone upstairs for about three hours.

25 April 2026·1 704 reads

More articles

What should I study in the age of AI? What should I major in? Does a degree still make sense?

The development of artificial intelligence changes how we look at which paths in life make sense. Which studies and which profession to choose.

4 October 2026·139 reads
I Left My Job for Several Months to Read Philosophy

It was Thursday, 31 March 2022, when I handed over the last of my responsibilities to my colleagues, closed my laptop and went to the library. I left my job for several months and immersed myself in philosophy. And I am immensely grateful for it. Today I am, like most people, on a merry-go-round, and it is hard for me to stop and think about the fundamental questions of my own life.

28 September 2026·456 reads
How I Fell in Love With Her, at First Sight

It was September 2023. My life, my work, everything was completely different from now. It was simpler. I owned almost nothing. I needed to film an advert, I went up to a floor inside the company where the product I needed for that advert was, and there I noticed her for the first time. She laughs at me when I describe it like this, but at that moment the universe told me, that is her.

20 September 2026·660 reads
How to stop depending on social media, and what the IndieWeb is

How and why I am gradually leaving social media and the big platforms. When I read that Meta is testing a new way to charge for organic posts that link outside its platform, it confirms how right I was to become steadily less dependent on the big platforms and on social media. It does not mean I have left them completely. It means that whether or not I stay in touch with my readers depends on them less and less, and today almost not at all.

9 September 2026·718 reads
How to Start With AI in a Company

One of my family members described a firm that has its data in several different tools, and its employees still join it by hand, in spreadsheets. That is the ordinary state of firms. When somebody tells such people not to do it by hand and to use AI, they will not understand. Most firms do not even have the basic connectors between the tools they use. These firms need help with AI transformation.

12 August 2026·854 reads
Fable 5 vs Opus: the cheaper model won

The same task, two models. Fable 5 against Opus 4.8. On paper Fable is the better model, with a larger context and stronger specs. And still it lost. Opus handled the task with a single round of checking for 721,000 tokens, while Fable needed nine rounds and burnt through 2.78 million tokens. The difference was not in the model, but in how I set the task. And I know it, because I measured it.

22 July 2026·1 146 reads
I Ran Object Detection on My Laptop, and Saw Everything Is Possible

A few weeks ago I installed a small local AI model on my laptop that watches a live camera feed. I turned the webcam on in the dark, and in near total darkness it recognised me and the objects in the room. That such things exist, I have known for a long time. What opened my eyes was the accessibility. I installed it in one prompt, free, and it runs entirely on my machine, sending data nowhere.

15 July 2026·798 reads
My blog is full of bots and AI agents

I once wrote about building my own privacy-friendly analytics tool. It had bot detection from the first version, yet it was not enough. Direct visits took a strangely high share of my traffic. When someone claims that 20% of their visits are bots and 80% are humans, I used to think the same. Today I would say the opposite ratio is closer to the truth. This is how I got there.

6 July 2026·2 430 reads
Dependent on AI: Are We Still Masters, or Slaves?

I have Heidegger and my notebook beside me. I am asking where all of this is heading, where artificial intelligence is taking us.

21 June 2026·1 433 reads
Which Work Will AI Not Replace?

Seventy per cent. That is where the first AI output begins, even when you give it the full company context and the best examples from the past. We are talking about the kind of output that cannot be defined programmatically. It is more complex. Often it is creative work. On one repeated type of output I reached eighty per cent within a week. Every further percentage point is harder than the one before.

10 June 2026·1 054 reads
All in on AI agents, or an analogue life.

Four days in Catalonia. No computer, no AI, almost no social media. I bought this notebook so that I could write down what I would think about, and what I would come across and learn on the trip.

10.5.2026·1 749 reads
NEWSLETTER
What I write about, what I am working on, what I learned.
Sent the first Sunday of the month. Unsubscribe anytime.