Lesson 2.1
Multi-turn conversations
Agent completions are stateless: each request stands alone. To build a chatbot or research assistant that remembers earlier turns, thread the prior exchange back in through the history field:
payload = {
"agent_config": {
"agent_name": "Assistant",
"system_prompt": "You are a helpful research assistant.",
"model_name": "gpt-4.1",
"max_loops": 1,
},
"task": "Which of those is most relevant for solar?",
"history": [
{"role": "user", "content": "List three energy storage technologies."},
{"role": "assistant", "content": "1. Lithium-ion batteries ..."},
],
}Your application owns the memory: append each user message and agent reply to a list, and send that list as history on the next call. This gives you full control over how much context to keep and lets you trim or summarize old turns to manage token costs.