Skip to main content
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

When memoryEnabled is true, the agent stores human, assistant, and tool messages after each run. This is the default.

Run without memory

When memoryEnabled is false, each run starts from the current system prompt and tool list only.
Use stateless agents for request/response APIs, background jobs, and tests where earlier runs must not affect later behavior.

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.
Use this after a user switches projects, changes accounts, or asks to start over.

Next steps

Structured Output

Generate type-safe responses with Zod schemas.

Streaming

Stream agent responses in real time.