Skip to content

Search docs

Find pages, headings, and concepts. Press ⌘K or Ctrl+K to toggle.

Sessions

A session is a single agent's conversation history — the unit that holds messages, tool calls, and status.

A session is one agent's conversation thread. It owns the messages, the tool calls and results, and the live runtime status. Every chat with an agent — through the canvas, an API call, or a peer message — happens inside a session.

Anatomy of a session

FieldPurpose
agentIdThe agent that runs in this session.
projectIdOptional project the session belongs to.
workspaceIdWorkspace scope when workspaces are enabled.
labelHuman-readable name shown in the UI.
statusactive, awaiting_peer, idle, completed, failed.
metadataJSON for runtime hints and UI state.
deletedAtSoft-delete tombstone.

Messages

Messages live in their own table and reference the session. Each message has:

  • A role (user, assistant, tool, system)
  • Either a fromUserId or a fromAgentId — never both
  • content plus structured parts, toolCalls, and toolResults
  • Optional parentMessageId for threading and deliveredToSessionId for cross-session peer messages
  • tokenUsage for billing

A DB check constraint enforces that exactly one sender (or neither, for system messages) is set.

Session vs project

SessionProject
ScopeOne agent, one conversationA whole unit of work
LifetimeUntil completed/deletedUntil archived
OwnsMessages, tool callsSessions, agents, files, memories, datasets
Identitychat_sessions.idprojects.id

A project contains many sessions. A session belongs to at most one project — you can also have ad-hoc sessions outside any project.

Peer messaging across sessions

When agent A calls message_agent to talk to agent B, the runtime delivers the message into B's session. The deliveredToSessionId field on the message records the cross-session hop so the canvas can render the link. Status flips to awaiting_peer when an agent is blocked on a reply — but most peer flows are fire-and-forget. See /docs/concepts/peer-messaging.

Lifetime

Sessions stay active while the agent is running, drop to idle between turns, and end as completed or failed. deletedAt is a soft delete — rows stay in the database so memories and references remain resolvable.