DEV Community

Aamer Mihaysi
Aamer Mihaysi

Posted on

The State Problem: Why Most Agents Cant Remember What They Just Did

Agents are supposed to be stateful. They should remember what they have done, track progress, and act accordingly. Most agents are not.

The problem is not memory. The problem is state management.

What state means for agents:

State is not just conversation history. State is everything the agent needs to know to make decisions:

  • What tasks have been completed?
  • What tasks are pending?
  • What resources are available?
  • What constraints have changed?
  • What decisions were made and why?

Most frameworks give agents a message log and call it state. That is like giving a developer a git log and calling it documentation.

Why state management is hard:

  1. Implicit vs explicit state. Agents accumulate state implicitly through conversation. But to use state effectively, it needs to be explicit. The agent needs to know what it knows.

  2. State drift. As tasks get longer, state gets stale. The agent thinks it is in one state, but the world has moved on.

  3. State serialization. Agents run in sessions. Sessions end. State needs to persist across sessions, but most frameworks do not handle this.

  4. State conflicts. Multiple agents working on the same task need shared state. But shared state is hard when agents are isolated processes.

What good state management looks like:

  • Explicit state objects, not just conversation history
  • State checkpoints that can be saved and restored
  • State diffs that show what changed
  • State validation that catches inconsistencies
  • State cleanup that removes stale data

The pattern that works:

Instead of passing the entire conversation, pass a state object:

{
  completed: [task1, task2],
  pending: [task3],
  blocked: [{task4, reason: "waiting for API"}],
  context: {relevant_data},
  decisions: [{choice, rationale}]
}
Enter fullscreen mode Exit fullscreen mode

The agent reads state, acts, updates state. The state is the contract between turns.

Why this matters:

Without proper state management, agents cannot do multi-step tasks reliably. They lose track. They repeat work. They make contradictory decisions.

State is the difference between an agent that acts and an agent that coordinates.

If your agent cannot answer "What have I done so far?" without replaying the entire conversation, you do not have state management. You have a log.

Top comments (0)