The Agent Class: Tracking Conversation History
~15 min read
Before writing any ReAct logic, you need a minimal Agent class that wraps a conversational LLM and keeps track of its full message history — the foundation every subsequent ReAct step builds on.
The Agent Class: Tracking Conversation History is a Pro topic
Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.
Key points
- •The Agent class is deliberately generic — it's a conversational memory wrapper, with zero ReAct-specific logic yet
- •self.messages holds the full conversation history, because LLM API calls are stateless without it
- •__call__ does three things per turn: record the user message, call invoke() for a reply, record the reply — all in one method
- •invoke() is the isolated piece that actually talks to the LLM API, making it easy to swap providers/models later
- •All the ReAct-specific behavior comes from what system prompt you pass in, not from this class itself