Turn input
Each Turn’sinput 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 bytool.approval_required. One item per pending tool call.
UserToolResponseEvent
Sent to resume a turn paused bytool.response_required. One item per pending tool call.
Reference
Prefer the high-levelAgentSessionClient for application code — same prepare_turn / prepareTurn → execute model as Use an agent. Use the low-level TrueFoundryGateway client when you need raw Fern types or direct SSE control.
High-level streaming yields { sequence_number, event } (Python) / { sequenceNumber, event } (TypeScript). Low-level create_turn / createTurn yields raw TurnStreamingEvent values.
Turn input JSON shapes are the same in every language.
- Python
- TypeScript
High-level (AgentSessionClient)
is_event_delta, merge_event_delta, and event types from truefoundry_gateway_sdk.agents. Import UserMessage and content-part types from truefoundry_gateway_sdk.types.create_session
AgentSession for a saved agent.list_sessions
AgentSession objects for a saved agent, newest-first by default. The pager auto-paginates when iterated.get_session
AgentSession
The conversation context for a saved agent. Turns created within a session are chained automatically. Key members:prepare_turn
PreparedTurn with no id yet. The turn is created server-side on the first execute() call:execute(stream=True)— POST create_turn and stream SSE asTurnStreamData(sequence_number,event).execute(stream=False, poll_interval_ms=...)— POST create_turn, then poll until the turn reaches a terminal state. Default / minimum poll interval is 3000 ms.
execute() starts the turn, call stream(), refresh(), wait_for_completion(), list_events(), or cancel() on the same object. Calling those methods before execute() raises.PreparedTurn
Output ofprepare_turn(). Not yet started — no HTTP until execute(). Identity fields are None until started.Turn
A started turn returned bylist_turns(), get_turn(), or after PreparedTurn.execute(). Same methods as PreparedTurn except there is no execute() — the turn already exists server-side.Low-level (TrueFoundryGateway)
client.agents.sessions.*.create
.data.list
get
.data.cancel
Session
The conversation context for a saved agent, returned bycreate 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
turn.created; the stream closes with turn.done.list_turns
get_turn
.data.Turn
A single request/response cycle within a session, returned bylist_turns and get_turn in .data. Transitions: running → done | cancelled | error.subscribe_to_turn
after_sequence_number to resume after a known point. Closes when the turn reaches a terminal state. Use list_turn_events for completed turns.list_turn_events
order="asc" to replay forward. The pager auto-paginates when iterated.