Context Management
Manage conversation context during voice interactions
Overview
Context updates allow you to dynamically add information to the conversation’s context during voice interactions. This helps provide the AI agent with additional context about the user, conversation state, or UI state.
Automatic Context Updates
During voice conversations, several types of items are automatically added to the context:
- User speech: Everything the user says is automatically transcribed and added as message items
- Agent responses: All agent responses are added to maintain conversation flow
- Function calls: When agents call tools, the function call details are automatically added
- Function outputs: Tool results are automatically added by the SDK when tools complete
Manual Context Updates
You can manually add items to the conversation context using the conversation.item.create
event:
Event Notifications
The server sends events for all context operations:
Retrieving Context Items
You can retrieve a specific item from the conversation context by its ID:
Deleting Context Items
You can remove items from the conversation context:
Item Structure
Context items follow this structure:
Field | Type | Description |
---|---|---|
type | string | Item type: “message”, “function_call”, “function_call_output” |
role | string | Message role: “user”, “assistant”, “system” |
content | array | Message content with type and text |
status | string (optional) | Item status: “in_progress”, “completed” |
Context Item Types
Message Items
Standard conversation messages from users, assistants, or system
Function Call Items
Tool invocations with parameters (automatically managed)
Function Output Items
Results from tool executions (automatically managed)
The context helps the AI agent maintain awareness of the conversation history and make more informed responses based on the full context of the interaction.