Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions livekit-agents/livekit/agents/voice/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def __init__(
turn_handling: NotGivenOr[TurnHandlingOptions] = NOT_GIVEN,
llm: NotGivenOr[llm.LLM | llm.RealtimeModel | LLMModels | str | None] = NOT_GIVEN,
tts: NotGivenOr[tts.TTS | TTSModels | str | None] = NOT_GIVEN,
mcp_servers: NotGivenOr[list[mcp.MCPServer] | None] = NOT_GIVEN,
min_consecutive_speech_delay: NotGivenOr[float] = NOT_GIVEN,
use_tts_aligned_transcript: NotGivenOr[bool] = NOT_GIVEN,
# deprecated
turn_detection: NotGivenOr[TurnDetectionMode | None] = NOT_GIVEN,
min_endpointing_delay: NotGivenOr[float] = NOT_GIVEN,
max_endpointing_delay: NotGivenOr[float] = NOT_GIVEN,
allow_interruptions: NotGivenOr[bool] = NOT_GIVEN,
mcp_servers: NotGivenOr[list[mcp.MCPServer] | None] = NOT_GIVEN,
) -> None:
tools = tools or []
if type(self) is Agent:
Expand Down Expand Up @@ -109,6 +109,11 @@ def __init__(
mcp_servers = None # treat empty list as None (but keep NOT_GIVEN)

self._mcp_servers = mcp_servers
if self._mcp_servers:
logger.warning(
"passing MCP servers to AgentSession or Agent is deprecated "
"and will be removed in a future version. Use `MCPToolset` instead."
)
self._activity: AgentActivity | None = None

@property
Expand Down Expand Up @@ -699,13 +704,13 @@ def __init__(
turn_handling: NotGivenOr[TurnHandlingOptions] = NOT_GIVEN,
llm: NotGivenOr[llm.LLM | llm.RealtimeModel | None] = NOT_GIVEN,
tts: NotGivenOr[tts.TTS | None] = NOT_GIVEN,
mcp_servers: NotGivenOr[list[mcp.MCPServer] | None] = NOT_GIVEN,
preserve_function_call_history: bool = False,
# deprecated
turn_detection: NotGivenOr[TurnDetectionMode | None] = NOT_GIVEN,
allow_interruptions: NotGivenOr[bool] = NOT_GIVEN,
min_endpointing_delay: NotGivenOr[float] = NOT_GIVEN,
max_endpointing_delay: NotGivenOr[float] = NOT_GIVEN,
mcp_servers: NotGivenOr[list[mcp.MCPServer] | None] = NOT_GIVEN,
) -> None:
tools = tools or []
turn_handling = (
Expand Down
4 changes: 0 additions & 4 deletions livekit-agents/livekit/agents/voice/agent_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,6 @@ async def _start_session(self, *, reuse_resources: _ReusableResources | None = N
if self.mcp_servers:
from ..llm.mcp import MCPToolset

logger.warning(
"passing MCP servers to AgentSession or Agent is deprecated "
"and will be removed in a future version. Use `MCPToolset` instead."
)
self._mcp_tools = [
MCPToolset(id=utils.shortuuid("mcp_toolset_"), mcp_server=server)
for server in self.mcp_servers
Expand Down
7 changes: 6 additions & 1 deletion livekit-agents/livekit/agents/voice/agent_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ def __init__(
turn_handling: NotGivenOr[TurnHandlingOptions] = NOT_GIVEN,
# Tool settings
tools: NotGivenOr[list[llm.Tool | llm.Toolset]] = NOT_GIVEN,
mcp_servers: NotGivenOr[list[mcp.MCPServer]] = NOT_GIVEN,
max_tool_steps: int = 3,
# TTS settings
use_tts_aligned_transcript: NotGivenOr[bool] = NOT_GIVEN,
Expand Down Expand Up @@ -252,6 +251,7 @@ def __init__(
allow_interruptions: NotGivenOr[bool] = NOT_GIVEN,
resume_false_interruption: NotGivenOr[bool] = NOT_GIVEN,
agent_false_interruption_timeout: NotGivenOr[float | None] = NOT_GIVEN,
mcp_servers: NotGivenOr[list[mcp.MCPServer]] = NOT_GIVEN,
) -> None:
"""`AgentSession` is the LiveKit Agents runtime that glues together
media streams, speech/LLM components, and tool orchestration into a
Expand Down Expand Up @@ -398,6 +398,11 @@ def __init__(
self._turn_detection = raw_turn_detection
self._interruption_detection = interruption.get("mode", NOT_GIVEN)
self._mcp_servers = mcp_servers or None
if self._mcp_servers:
logger.warning(
"passing MCP servers to AgentSession or Agent is deprecated "
"and will be removed in a future version. Use `MCPToolset` instead."
)
self._tools = tools if is_given(tools) else []

# unrecoverable error counts, reset after agent speaking
Expand Down
Loading