pkg/preset package provides ready-made agent constructors for the most common patterns. They set sensible defaults and reduce boilerplate — without removing any flexibility.
Chatbot
A conversational agent with memory and a 1-iteration loop (no tool calling).Chatbot:
WithMemory(inmemory.New())— in-memory store created automatically (override viaMemoryfield)WithMaxIterations(1)— single-turn response, no agentic loop
ToolAgent
An agent with tools, automatic retry, and a multi-iteration loop.ToolAgent:
WithMaxIterations(10)whenMaxIterationsis 0WithRetry(3)whenMaxRetriesis 0
When to use presets vs. raw NewAgent
| Scenario | Recommendation |
|---|---|
| Quick chatbot or demo | preset.Chatbot |
| Agent with tools | preset.ToolAgent |
| Fine-grained control (custom retry ordering, MCP, OTel) | chainforge.NewAgent directly |
| Multiple agents in a pipeline | Build each with NewAgent; presets are for standalone agents |
chainforge.NewAgent internally — there is no runtime overhead. Extra options passed as the variadic override any preset-supplied option.