What is Context?
Context is the conversation history and information that your agent remembers:- Conversation History - All messages in the current session
- Tool Results - Results from function calls
- User Preferences - Information about the user
- Session State - Current conversation state
Multi-Turn Conversations
Agents automatically maintain context across conversation turns:How Context Works
Session-Based Context
Each WebSocket connection creates a new session with its own context:- Session ID - Unique identifier for each conversation
- Message History - All messages in the session
- Tool Call History - All tool calls and results
- User Metadata - Optional user information
Context Management
The agent automatically manages context:- Stores messages - All user messages and agent responses
- Includes tool results - Tool execution results are added to context
- Maintains history - Full conversation history is available to the LLM
- Manages session - Each session has isolated context
Context in Tool Calls
Tool results are automatically included in context:Session Management
Creating Sessions
Sessions are created automatically when clients connect:Client Side
Best Practices
Context Length
- Keep conversations focused - Long conversations may exceed context limits
- Use tools effectively - Tools can help manage context by storing information
- Clear session boundaries - Start new sessions for new topics
Context Quality
- Clear user messages - Help the agent understand intent
- Relevant tool results - Tools should return useful information
- Consistent terminology - Use consistent terms throughout conversation
Next Steps
- Creating Agents → - Learn how to create agents
- Instructions → - Write effective instructions
- Sessions → - Learn about session management

