Prompt
I'm building an agent that needs to use tools and memory, what stack should I use?
Latest observation
If you’re building an agent that needs tools + memory, I’d choose a stack based on how much control you want versus how fast you want to ship.
My default recommendation
Python + FastAPI + Postgres + pgvector + Redis + an orchestration library like LangGraph
Why this works well:
- Python has the best ecosystem for agent/tooling work
- FastAPI is clean for exposing agent APIs
- Postgres handles durable state, users, runs, tool logs, and metadata
- pgvector gives you memory / retrieval without adding another major system
- Redis is great for short-term cache, queues, session state, and rate limits
- LangGraph is good when your agent needs multi-step workflows, tool calling, branching, retries, and persistent state
If you want the simplest possible stack
Use:
- OpenAI/Anthropic API
- Python
- FastAPI
- Postgres
- pgvector
This is enough for:
- tool calling
- persistent memory
- user/session state
- retrieval over previous conversations or documents
If your agent is still small, this is probably the best starting point.
Suggested architecture
1. Model layer
Use a model that supports:
- tool/function calling
- structured outputs
- long context
Examples:
- OpenAI GPT-4.1 / GPT-4o
- Anthropic Claude
- Gemini, if your environment fits it
2. Agent orchestration
Choose one:
- LangGraph if you want explicit control over state machines, branching, retries, loops
- OpenAI Responses API / built-in tool calling if your logic is simpler
- CrewAI / AutoGen only if you specifically want multi-agent patterns
For most production systems, I’d favor LangGraph over “magic” agent frameworks.
3. Memory
Split memory into 3 types:
Short-term memory
- Conversation state in the current thread
- Store in Redis or Postgres
- Keep only the recent messages in the prompt
Long-term memory
- Facts/preferences/history
- Store in Postgres + vector index
- Retrieve with embeddings
Working memory
- Current task context, tool outputs, intermediate reasoning artifacts
- Store in your orchestration state, not necessarily in the prompt
Storage choices
Postgres
Use for:
- users
- conversations
- messages
- tool invocations
- agent runs
- memory items
- audit logs
pgvector
Use for:
- semantic retrieval of memories
- document chunks
- past conversations
- user preferences
Redis
Use for:
- ephemeral session state
- job queues
- caching
- locks
- rate limiting
Tooling layer
Build tools as normal Python functions or service endpoints:
- search
- database lookup
- calendar
- browser
- document retrieval
- internal business actions
Best practice:
- define tools with strict schemas
- validate inputs
- make them idempotent where possible
- log every tool call
Observability you should include from day 1
You’ll want:
- prompt/version tracking
- tool call logs
- traces for every run
- latency metrics
- failure tracking
- cost tracking
Good options:
- OpenTelemetry
- LangSmith
- Arize Phoenix
- Helicone
- custom logging in Postgres + dashboards
Recommended production stack
If I were shipping this today, I’d do:
- Frontend: Next.js
- API: FastAPI
- Agent orchestration: LangGraph
- LLM: OpenAI or Anthropic
- Database: Postgres
- Vector storage: pgvector
- Cache / queue: Redis + Celery or RQ
- Auth: Clerk, Auth0, or your own JWT setup
- Observability: OpenTelemetry + LangSmith/Phoenix
- Deployment: Docker + Kubernetes or ECS/Fargate, depending on scale
If you’re an early-stage founder
Don’t overcomplicate it. Start with:
- one model
- one API service
- one Postgres DB
- one vector index
- one orchestrator
You can always add:
- Redis
- queues
- multi-agent workflows
- separate memory services later
Rule of thumb
- Need reliability and control? Use LangGraph + Postgres
- Need to ship fast? Use a simple tool-calling loop + Postgres
- Need lots of retrieval/memory? Add pgvector
- Need async/background work? Add Redis + queue
- Need complex workflows? Add stateful orchestration, not more “autonomy”
If you want, I can also give you:
- a minimal starter architecture,
- a full production-grade architecture, or
- a specific stack recommendation based on your use case (support agent, coding agent, research agent, sales agent, etc.).