MCPAgent keeps conversation history across runs by default. Disable memory for stateless requests, or clear history when a user starts a new task.
Keep conversation memory
WhenmemoryEnabled is true, the agent stores human, assistant, and tool messages after each run. This is the default.
Run without memory
WhenmemoryEnabled is false, each run starts from the current system prompt and tool list only.
Inspect history
getConversationHistory() returns a copy of the stored LangChain messages. Mutating the returned array does not mutate agent memory.
Clear history
clearConversationHistory() removes stored conversation messages. If memory is enabled and the agent has a system message, the system message is preserved.
Next steps
Structured Output
Generate type-safe responses with Zod schemas.
Streaming
Stream agent responses in real time.