Skip to content

Chat contract

The types a chat agent receives for one turn and what it may return, shared by the chat page and evals. Guide: Chat with your agent.

The chat agent contract, shared by the chat page (agent_adapter.viewer) and evals.

ChatReply = str | AsyncIterator[str | ToolCallDelta] module-attribute

Attachment dataclass

A file the user attached; path is a local copy the server stored.

read_bytes()

The file's bytes.

Raises:

Type Description
OSError

the stored file cannot be read.

read_text(encoding='utf-8')

The file's text.

Raises:

Type Description
OSError

the stored file cannot be read.

UnicodeDecodeError

the file is not text in encoding.

ChatAgent

Bases: Protocol

agent(message, session): async or sync; returns text or an async iterator of chunks.

ChatMessage dataclass

The user's message of one turn.

ChatSession dataclass

One conversation as the agent sees it during a turn; state is live and mutable.

context()

A context in this turn's run: pass it as ctx= so tool calls show in the chat.