Skip to main content
For a guided walkthrough, see SDK overview.

Turn input

Each Turn’s input is a list of one of these types. Resuming a Turn paused by mcp.auth_required needs no input - omit input or pass [].
User messages (UserMessage) cannot be mixed with tool approvals or client-side tool responses in the same input list. UserToolApprovalEvent and UserToolResponseEvent may be mixed together.

UserMessage

Start a new conversation or send the next user message. content is either a plain string or a list of content parts, letting you attach files alongside text.

UserMessageContentItem

A content part is one of: Text File

UserToolApprovalEvent

Sent to resume a turn paused by tool.approval_required. One item per pending tool call.

UserToolResponseEvent

Sent to resume a turn paused by tool.response_required. One item per pending tool call.

Reference

Use an agent uses TrueFoundryGateway (client.agents.sessions.*). create_turn_stream / createTurnStream returns a Stream of TurnStreamingEvent. Iterate the stream for event bodies; use Python .with_metadata() / TypeScript .withMetadata() to also read the SSE id (sequence number for resume). create_turn / createTurn returns the turn object immediately (no events). Turn input JSON shapes are the same in every language.

TrueFoundryGateway

Access methods via client.agents.sessions.*.

create

Create a conversation Session for a saved agent. The returned response wraps the session in .data.

list

List Sessions for a saved agent, newest-first by default. The pager auto-paginates when iterated.

get

Fetch an existing session by ID. The returned response wraps the session in .data.

cancel

Cancel the running turn for a session. Idempotent.

Session

The conversation context for a saved agent, returned by create and get in .data. Turns created within a session are chained automatically, so each turn sees the history of earlier ones. Key members:

create_turn

Start or continue a turn within a session. Returns the turn object immediately (no SSE). The turn may still be running — use get_turn or create_turn_stream when you need terminal state or events.

create_turn_stream

Start or continue a turn within a session. Responds with a Server-Sent Events stream (Stream[TurnStreamingEvent]). Iterating yields typed event bodies; .with_metadata() yields StreamEvent items with .id (SSE id) and .data (typed body) for resume. The first event is turn.created; the stream closes with turn.done.

list_turns

List turns in a session, newest-first. The pager auto-paginates when iterated.

get_turn

Fetch a single turn by ID. The returned response wraps the turn in .data.

Turn

A single request/response cycle within a session, returned by list_turns and get_turn in .data. Transitions: runningdone | cancelled | error.

subscribe_to_turn

Reconnect to a running turn’s live SSE stream. Pass after_sequence_number to resume after a known point. Use .with_metadata() to read the SSE id while reconnecting. Closes when the turn reaches a terminal state. Use list_turn_events for completed turns.

list_turn_events

Return a paginated snapshot of stored events for a completed turn. Pass order="asc" to replay forward. The pager auto-paginates when iterated.

list_events

Return a paginated snapshot of stored events across turns in a session.
To define or configure the agent itself, see Create an agent.