Run your first agent
Sessions enable multi-turn conversations where Claude remembers previous messages. Use sessions for chat interfaces, complex tasks requiring multiple steps, or any scenario where context matters.Creating a Session
Session Options
For the complete API, see the Session SDK Reference.
Sending Messages
Basic Send
Streaming
Session States
Sessions progress through these states:
Check the current state:
Event Handlers
Listen to session events:Session Persistence
Sessions are automatically persisted. You can resume them later:Get Session ID
Resume Session
Closing Sessions
Always close sessions when done to free resources:Session Results
After each message, you get aSessionResult: