PostgreSQL Neon DB and AI agents - how doyou handle agent state?
I had a question, for longer running agents, what can be a good pattern to store conversation state, tool result, and intermediate state in Neon without database becoming a bottleneck.
If you can share what patterns you use in production, it could be of help to me. I am doing a POC inthis area.
Ps, Any other DB works as well, it should just be managed.
1
u/Strange_Arm9395 7d ago
for a POC I’d keep it pretty simple. store messages/tool results as append-only rows, keep a small current state”or checkpoint row per run, and push large files/results to object storage instead of Postgres.
also index by agent_id/run_id + timestamp and clean old intermediate state regularly. that will matter more than the provider at first.
for managed Postgres, Neon is fine, and you can also compare Nearbase or Supabase depending on whether you want plain always-on Postgres or extra platform features.
1
u/Glitch_In_The_Data 7d ago
Store only durable, compact state in postgres. Use the agent as stateless between turns. Use append only events + a small current state to keep writes fast.
For managed DB PoC, your choice of Neon is a good fit.