aloof-scooter-47164
12/11/2025, 3:11 PMtall-airline-16756
12/11/2025, 3:11 PMtall-airline-16756
12/11/2025, 3:11 PM# add a tool
await agent.update_tools(agent.tools + [tool_a])
# remove a tool
await agent.update_tools([t for t in agent.tools if t != tool_a])
# replace all tools
await agent.update_tools([tool_a, tool_b])
• Node.js/TypeScript
// add a tool
await agent.updateTools({ ...agent.toolCtx, toolA })
// remove a tool
const { toolA, ...rest } = agent.toolCtx;
await agent.updateTools({ ...rest })
// replace all tools
await agent.updateTools({ toolA, toolB })
Notes:
• update_tools() / updateTools() replaces the entire tool set — read current tools from agent.tools (Python) or agent.toolCtx (Node) before updating if you want to preserve some tools.
• Tools registered via the agent class (e.g., with @function_tool) continue to work alongside tools set by update_tools().
Would you like a specific example for your language or a sample that preserves existing tools automatically?
Sources: Tool definition and use | LiveKit docsaloof-scooter-47164
12/11/2025, 3:12 PMtall-airline-16756
12/11/2025, 3:12 PMagent.update_tools() (or updateTools()) replaces the entire tool set, including tools loaded from MCP servers. If you want to keep MCP-provided tools, first read them from agent.tools (Python) or agent.toolCtx (Node) and include them when you call update_tools() so the MCP tools are preserved.
Sources: Tool definition and use | LiveKit docs | Agents (Python) | livekit/livekit_composite | DeepWikialoof-scooter-47164
12/11/2025, 3:15 PMtall-airline-16756
12/11/2025, 3:16 PM# assume `agent` and `tool_a` are already defined
# tool_a is a Tool instance you want to add
# read current tools (includes MCP-loaded tools)
current_tools = agent.tools
# create a new list that preserves existing tools and adds tool_a if not present
new_tools = current_tools + [t for t in [tool_a] if t not in current_tools]
# replace the agent's tools with the combined set
await agent.update_tools(new_tools)
Node.js / TypeScript (async)
// assume `agent` and `toolA` are already defined
// toolA is a tool object you want to add
// read current tool context (includes MCP-loaded tools)
const currentToolCtx = agent.toolCtx;
// add toolA while preserving existing tools
const newToolCtx = { ...currentToolCtx, toolA };
// replace the agent's tools with the combined set
await agent.updateTools(newToolCtx);
Notes
• update_tools() / updateTools() replaces the full tool set, so always merge current tools with new ones if you want to preserve MCP tools.
• If you need an example that removes a specific MCP tool or conditionally replaces tools, tell me which language and I’ll provide the snippet. Would you like that?aloof-scooter-47164
12/11/2025, 3:16 PMtall-airline-16756
12/11/2025, 3:16 PM# assume `agent` exists and MCP tools are already loaded in agent.tools
# tool identifiers: compare by `name` or another unique attribute your Tool uses
# A) Remove a specific MCP tool by name
mcp_tool_name = "mcp_tool_to_remove"
new_tools = [t for t in agent.tools if getattr(t, "name", None) != mcp_tool_name]
await agent.update_tools(new_tools)
# B) Conditionally replace a tool (replace if exists, otherwise add)
new_tool = tool_a # Tool instance to add/replace
def replace_or_add(tools, new_t, key_attr="name"):
names = {getattr(t, key_attr, None): t for t in tools}
names[getattr(new_t, key_attr, None)] = new_t
return list(names.values())
updated = replace_or_add(agent.tools, new_tool)
await agent.update_tools(updated)
Node.js / TypeScript (async)
// assume `agent` exists and MCP tools are loaded in agent.toolCtx
// tool keys are the property names in toolCtx
// A) Remove a specific MCP tool by key
const keyToRemove = "mcpToolToRemove";
const { [keyToRemove]: _, ...preserved } = agent.toolCtx;
await agent.updateTools({ ...preserved });
// B) Conditionally replace a tool (replace if exists, otherwise add)
const newToolKey = "toolA";
const newTool = toolA; // tool object
const newToolCtx = { ...agent.toolCtx, [newToolKey]: newTool };
await agent.updateTools(newToolCtx);
Notes
• Both approaches read the current tool set (which includes MCP tools), modify that set, then call update_tools() / updateTools() to replace all tools.
• Use a stable identifier (tool name in Python or object key in Node) to match MCP tools when removing or replacing.
• Tell me which language and exact identifier format your tools use if you want a tailored snippet.aloof-scooter-47164
12/11/2025, 3:17 PMtall-airline-16756
12/11/2025, 3:18 PMagent.update_tools() it replaces the entire agent tool set (including MCP-loaded tools) unless you explicitly merge them back.
Pros / Cons (brief)
• AgentSession
◦ Pros: simple centralized management; shared access across agents.
◦ Cons: less granular control per agent.
• Agent class
◦ Pros: fine-grained control; role-specific toolsets; better isolation/security.
◦ Cons: more setup if many agents need the same tools (possible redundant list calls).
Recommendation
• Default to AgentSession for common/shared tools; use Agent class for agent-specific or sensitive integrations. You can mix both—session tools plus agent-specific tools—to get the best of both worlds.
If you want, I can provide a short code example showing:
• registering an MCP server at session level, and
• registering a different MCP server on an agent,
in either Python or Node.js. Which language do you prefer?
Sources: Tool definition and use | LiveKit docs | Agents and handoffs | LiveKit docs | Agents (Python) | livekit/livekit_composite | DeepWikialoof-scooter-47164
12/11/2025, 3:20 PMtall-airline-16756
12/11/2025, 3:20 PMaloof-scooter-47164
12/11/2025, 3:21 PMtall-airline-16756
12/11/2025, 3:21 PMsession.tools first.
• Add a tool (preserve existing session + MCP tools)
# assume `session` (AgentSession) and `new_tool` (Tool instance) exist
current = session.tools
if new_tool not in current:
await session.update_tools(current + [new_tool])
• Remove a tool by name (preserve others)
to_remove_name = "mcp_tool_to_remove"
updated = [t for t in session.tools if getattr(t, "name", None) != to_remove_name]
await session.update_tools(updated)
• Replace all session tools (drops MCP-loaded tools unless re-added)
await session.update_tools([tool_a, tool_b])
Notes:
• session.update_tools() replaces the entire session tool set (including MCP-loaded tools). Always read session.tools and merge if you want to preserve existing tools.
• Updated tools become available immediately for subsequent LLM turns and apply across agents in the session.
Would you like a version that also preserves agent-level tools or a full example showing re-adding specific MCP tools by name?aloof-scooter-47164
12/11/2025, 3:23 PMupdate_tools for AgentSession class"tall-airline-16756
12/11/2025, 3:23 PMupdate_tools() method is available on AgentSession in the SDK versions that include dynamic tool updates. Verify your installed package version matches the release that added update_tools().
2) Verify your import/type
• Make sure the object you're inspecting is an actual AgentSession instance (not a different Session type or a plain dict). For example:
from my_sdk import AgentSession
print(type(session))
3) Accessing the method
• If your session is an AgentSession instance and your SDK version supports it, session.update_tools should exist and be awaitable:
# check at runtime
hasattr(session, "update_tools") # should be True
4) If the method is missing
• Either your SDK version predates dynamic session updates, or you are using an API surface that doesn't expose it. In that case you can:
◦ Update the SDK to the latest version that includes update_tools(), or
◦ Work around by updating agent-level tools (each agent has update_tools()), then ensure agents pick up the changes.
If you want, tell me:
• the SDK package name and version (pip show <package>), and
• how you instantiated the session (small code snippet),
and I’ll give the exact next steps or a precise code example.aloof-scooter-47164
12/11/2025, 3:27 PMtall-airline-16756
12/11/2025, 3:27 PMAgentSession.update_tools() was introduced after that release. To update session-level tools mid-session you need a version that includes that method.
Two options:
1) Upgrade the Agents SDK to a version that includes AgentSession.update_tools() (pick >= the release that added dynamic session updates or the latest). Then you can call:
await session.update_tools(session.tools + [new_tool])
2) If you cannot upgrade now, use the agent-level fallback: update each active agent’s tools with agent.update_tools() (read agent.tools first to preserve MCP tools), e.g.:
current = agent.tools
await agent.update_tools(current + [new_tool])
If you want, tell me which package manager you use (pip/poetry) and I’ll give the exact upgrade command and a short example showing session vs agent update flows.aloof-scooter-47164
12/11/2025, 3:28 PMtall-airline-16756
12/11/2025, 3:29 PMupdate_tools() method in the documented SDK. The documented runtime update API is on the agent/activity level (e.g., AgentActivity.update_tools() or agent.update_tools()), not on AgentSession. Use one of these instead to change tools at runtime, or update individual agents with agent.update_tools().
If you'd like, I can:
• show a short Python example using AgentActivity.update_tools() or agent.update_tools(), or
• help you inspect your installed SDK to confirm whether any undocumented session-level method exists. Which would you prefer?