Threads

Threads store the message history of your agent. They are essential when building chat-like experiences, because they let agents maintain continuity across multiple turns in a conversation.


How Threads Work

  • A thread is a container for messages.
  • Each message in a thread has a role (user, agent, or tool) and content.
  • Agents can use the thread to keep context during chat sessions.

When you start a new chat, you create a thread. Each new message is added to it, so the agent always has access to the previous conversation.


Why Use Threads?

  • Continuity: Keep track of chat history across multiple messages.
  • Organization: Store conversations separately for each user or project.
  • Reusability: Share a thread with different agents if needed.

Examples

  • Customer Support: Store a user's support conversation in a thread.
  • Team Chatbot: Maintain the flow of questions and answers in a workspace.
  • Project Discussion: Log ongoing discussions about a specific project.

Things to Know

  • Threads are designed for chat-style use cases.
  • They store history, unlike runs, which are stateless.
  • Each thread belongs to a project and can be tied to an agent or user.

👉 Think of Threads as conversation logs that let your agent “remember” what was said earlier in a chat.