Skip to main content
A session connects a versioned agent configuration to an environment configuration for one independent task or conversation. Before starting a session, create an agent and an environment and retain their IDs. The agent controls how the agent behaves, while the environment controls the sandbox where it runs.

Create the session

Pass the agent ID and environment ID to sessions.create(). You can also add a title and string metadata to identify the session in your application.
The new session starts with a provisioning status while Funky prepares its sandbox.

Wait for the session

Wait until the session is ready before sending its first message.

Stream the response

Send a message, then follow the session’s live event stream. Assistant message events contain the response’s text content. Set after_seq to the sequence returned by send_message() or sendMessage() so the stream starts after the submitted user message.
The event stream replays persisted events after after_seq, follows new events over SSE, and reconnects from the last received sequence if the connection is interrupted. The session records the agent version and environment ID selected when it was created. Start a new session for each independent task or durable conversation.
See Model, Harness, and Network for configuration options.