Conversational ReAct Description - Multi-Turn AI Agent Framework
Conversational ReAct builds on the original ReAct paradigm by weaving in two critical capabilities: (1) persistent memory so that past turns inform future responses, and (2) context tracking that keeps the dialogue coherent over many back‐and‐forth exchanges.

Architecture Overview
At its core, Conversational ReAct interleaves three loops:
- Reasoning Loop: The agent decomposes the user’s query into sub‐goals (via chain‐of‐thought).
- Tool‐Use Loop: It calls external tools (search, calculator, database) to fetch facts or perform computations.
- Memory Loop: The outcome of each turn is stored in a context buffer or vector store, and retrieved on subsequent turns to recall prior user intents or facts.
It allows the AI to:
- Track user intent over multiple exchanges
- Use tools like search or calculators while keeping the dialogue coherent
- Recall past interactions for more personalized and accurate responses
This approach is especially useful in building chat-based assistants, customer service bots, or AI copilots that need to maintain context, ask clarifying questions, and execute external actions within a conversation loop.
Multi‐Turn Example
Suppose a user is planning a trip and asks:
User: “What’s the weather in Paris this weekend?”
- The agent reasons it needs weather data, so it calls a weather API.
- It replies, “Currently 18°C and partly cloudy.” Meanwhile it logs:“User is asking about Paris weekend weather.”
- Next turn, user says: “Great – can you recommend a good museum nearby?”
- Using the stored memory of “Paris weekend trip,” the agent searches for “top Paris museums open this weekend” and answers accordingly.
Keeping Context in TypeScript
Here’s a minimal pattern for appending each turn to a conversation history and retrieving the last n turns before calling your LLM:
// conversation.ts
export interface Turn {
role: "system" | "user" | "assistant";
content: string;
}
const MAX_TURNS = 6;
let history: Turn[] = [
{ role: "system", content: "You are a helpful assistant." }
];
export function appendTurn(turn: Turn) {
history.push(turn);
if (history.length > MAX_TURNS + 1) {
// drop oldest user+assistant pair
history.splice(1, 2);
}
}
export function getContext() {
return history;
}
// In your handler:
import OpenAI from "openai";
import { appendTurn, getContext } from "./conversation";
async function chat(userInput: string) {
appendTurn({ role: "user", content: userInput });
const response = await new OpenAI().chat.completions.create({
model: "gpt-4o-mini",
messages: getContext(),
});
const assistantMsg = response.choices[0].message;
appendTurn({ role: "assistant", content: assistantMsg.content });
return assistantMsg.content;
}
Benefits Use Cases
- Personalized Bots: Remembers past preferences and tailors recommendations.
- Customer Service: Maintains context across follow‐up questions (e.g., order status, issue resolution).
- AI Copilots: Combines real‐time reasoning with external tools (code execution, calendar APIs).

Best Practices
- Limit Memory Window: Only retain the last few turns to stay within token limits.
- Selective Retrieval: Use semantic search to fetch only the most relevant past turns.
- Tool–Response Separation: Always log tool inputs and outputs as separate “assistant” messages to preserve transparency.