Building a Moat: Self Learning Agents

@ataiiam
ENGLISH2 days ago · Jul 07, 2026
169K
258
43
13
587

TL;DR

Atai Barkai explains how to build a business moat by creating self-learning agents that capture signals from both agent traces and ambient user activity using the AG-UI protocol.

Self-improvement is the new moat, allowing product companies to go beyond wrapping LLM APIs.

There are two places to harvest this learning: browser activity (what users actually do in applications) and agent traces (what your agent actually did).

If done correctly, your product can improve simply by being used.

Your product might have hundreds, thousands, or millions of agent-user interactions every day. That is a goldmine of data.

Today, however, most of that value goes uncaptured.

Your users “teach” the agent and that “lesson” just disappears.

Capturing data signals is a compounding asset.

But capturing is not enough -- the agent still has to use it without drowning in context. Models have a limited attention budget, and stuffing the context with everything is not the solution...

Atai Barkai - inline image

Article overview

We'll walk through self-improving agents you can build a business moat around, including:

  • Learning from agent-traces & in-browser activity
  • Where learnings can be applied: model weights, the harness, and context
  • The different kinds of learnings: procedural, semantic, episodic
  • Data privacy: keep your users data safe
  • Data ownership: build a business moat
  • Practical tips for easily implementing self-learning for any agent, using AG-UI

We’re releasing our Self-Learning solution in the coming weeks.

Sign up here for early access and design partnership.

Atai Barkai - inline image

Your agent should learn from 2 places

Agents should learn from agent-traces, and from ambient in-browser activity.

Most approaches to learning only use one or the other, but products that leverage both will significantly outperform those who don't.

1. Agent Traces

The agent runs and every step gets logged as a trace. What it was asked, which tools it called, what came back, where it failed.

Point another agent at those traces, and it finds the failure patterns and rewrites the prompts, tools, and instructions.

The missing half: Anything outside of the agent interaction, where most activity still takes place.

2. In-browser ambient user activity

Aka, watching the user.

Their clicks, edits, responses, and workflows.

Brex built their onboarding this way. They watched their analysts work and fed every human correction back as a training signal.

Each human fix creates a labeled data point that sharpens the next run.

The missing half: This method sees the human perfectly. But it knows nothing about what the agent tried or why it failed.

Atai Barkai - inline image

You should be capturing both signals

How? Or better yet, where?

There’s one place in almost every single product today that sees both simultaneously: the surface where the person and the agent work side by side.

Aka, the interface.

The how is via the Agent-User Interaction Protocol (AG-UI): an open standard that streams every event between your app, your users, and the agent. More on why that matters below.

Atai Barkai - inline image

Where the learning can be applied

There are three places, each with their own tradeoffs.

→ Model weights: Fine-tune the lesson into the model itself.

→ Harness: Everything around the model. The cycle it follows, the tools it's allowed to call, the checks that catch it before it acts.

→ In-context: Add the new information straight into the prompt. The agent reads it on every call.

I covered all 10 approaches across these three layers in the first article

https://x.com/svpino/status/2070210421995569537

The different kinds of learnings

There are three main types that will help your agents improve over time.

Atai Barkai - inline image

1. Procedural (workflows/how to do things)

Procedural memory is what many of us include in skills or agents.md files:

Learned workflows and rules for getting a task done.

For example:

A manager approving an over-limit refund for a loyal customer. The agent learns this and does the same next time.

Pro: The agent handles the same case the same way every time. Consistent and independent.

Con: If it learns the wrong workflow, it'll do the wrong thing confidently, every time.

2. Episodic (things that happened)

A record of specific past events and interactions.

For example:

"On January 5th, Joe Jonas's refund bounced because his card had expired."

Pro: A real past case beats an abstract rule. The agent sees how it played out and copies what worked.

Con: Most past cases are useless noise. Someone has to go through and keep only the ones worth remembering or the useful one gets buried.

3. Semantic (the facts)

Stable facts the agent should know.

For example:

"All credit card plans have some limit, but the limit varies by plan"

Pro: Reusable everywhere. A fact is a fact.

Con: Goes stale without warning. The day the limit changes, the agent is confidently wrong and acts on it anyway.

Atai Barkai - inline image

Self-learning in action via CopilotKit Intelligence and AG-UI

Semantic keeps what's true.

Episodic keeps the case that happened.

Procedural keeps the rule for handling it.

Atai Barkai - inline image

The flow journey from agent-user interaction to self-learning

Owning the loop yourself & building a moat

The learning data is the most important part of your product, and it will become increasingly valuable as the cost of creating software from scratch goes down.

Owning the learning data allows you to become more than a wrapper of an LLM API.

The agent's miss and the human's fix usually end up in two different places.

And nobody connects them.

The surface for doing so already exists inside your product: the interface.

Trace tools see only the agent.

Ambient tools, the kind that watch the browser, see only the human, and invade privacy to get it.

But CopilotKit sees both signals.

CopilotKit reads the events flowing through your app: every tool call, state change, approval, and edit, from both the agent and the person using it.

It does this through AG-UI (Agent-User Interaction Protocol) which carries every event between your app, your users, and the agent in real time.

Now the agent's attempt and the human's fix arrive in the same stream.

Atai Barkai - inline image

AG-UI works with any agent & any harness

AG-UI is an open standard that's framework-agnostic.

It's been adopted by AWS, Google, Microsoft, Oracle, LangChain, Mastra, Pydantic AI, CrewAI, LlamaIndex and more.

AG-UI sees the events and injects the learned context straight into the agent, whatever that agent's own harness looks like underneath.

That means the same learning applies to any agent you bring on, today or next year, automatically, with no custom integration work for each new one.

One of our customers runs a UI that talks to CopilotKit's agent + Google ADK + Microsoft Agent Framework, and all memories are shared across all three.

Memory detached from framework choice = portability

Atai Barkai - inline image

Everything runs on your infra so you own the learning

CopilotKit Intelligence self-hosts on your own Kubernetes cluster. Full data sovereignty, SOC 2 Type II, air-gapped deployment if you need it.

The data stays with you. So does everything the agent learns from it.

Everyone else's approach either keeps your learning in their cloud or like Meta's, takes surveillance to get it.

Atai Barkai - inline image

@CopilotKit Intelligence is live in production at Fortune 500s today, and open for early access. If you want your agent to get better the more people use it, reach out.

Learning Containers: deciding “who” gets the new learnings

As soon as you enable learning in your product, the question arises: how far does the learning extend? Sensitive facts from one user should not leak into another user's agent context.

CopilotKit's solution is Learning Containers: developer-friendly scopes that you can control, deciding how 'far' each lesson spreads.

CopilotKit allows you to easily define learning containers for different cohorts of users:

  • Per-user. Like specific preferences.
  • Per-team. Like approval procedures.
  • Per-app. Like company-wide rules.

Learning container are fully auditable. You can see exactly what was learned and which container it landed in.

Atai Barkai - inline image

There's a lot more to this.

Recently, we held an in-depth livestream going over everything I just mentioned.

Watch the full recording here.

Summary in a nutshell

Atai Barkai - inline image

Share this graphic with your network as a TL;DR

@CopilotKit Intelligence is already running this in production inside large enterprises, and it's open for early access.

If you want an agent that gets better the more your users use it, reach out and we'll get you in.

Atai Barkai - inline image

Follow @ataiiam for more.

Remix in YouMind

Turn one viral article into a full content workflow

Collect the source, decode the pattern, create assets, draft the story, and distribute from one AI workspace.

Explore YouMind
For creators

Turn your Markdown into a clean 𝕏 article

When you publish your own long-form writing, images, tables, and code blocks make 𝕏 formatting painful. YouMind turns a full Markdown draft into a clean, ready-to-post 𝕏 article.

Try Markdown to 𝕏

More patterns to decode

Recent viral articles

Explore more viral articles