colossal-xylophone-68609
05/22/2026, 6:46 AMtall-airline-16756
05/22/2026, 6:47 AMtall-airline-16756
05/22/2026, 6:47 AMcontext.
You can get the current agent from the tool’s context.session.current_agent. Example in Python:
@function_tool()
async def my_tool(self, context: RunContext):
current_agent = context.session.current_agent
# use current_agent as needed
If you want an example for another language or need details on properties available on current_agent, tell me which language or what you want to read from the agent.
Sources: How to Build a Background Observer for Voice AI Guardrails | LiveKit | Function tool definition | LiveKit Documentation | Agents and handoffs | LiveKit Documentation, with interactive elementscolossal-xylophone-68609
05/22/2026, 6:53 AMtall-airline-16756
05/22/2026, 6:53 AMcolossal-xylophone-68609
05/22/2026, 6:54 AMtall-airline-16756
05/22/2026, 6:54 AMcontext.session.current_agent using Python's type/attribute introspection. For example:
@function_tool()
async def my_tool(self, context: RunContext):
agent = context.session.current_agent
# Simple class name
class_name = type(agent).__name__
# Fully qualified name (module + class)
fq_name = f"{agent.__class__.__module__}.{agent.__class__.__qualname__}"
# Example use
print("Class:", class_name)
print("Fully qualified:", fq_name)
Let me know if you want this returned to the caller, logged, or used for conditional logic and I can show that pattern.
, with interactive elementscolossal-xylophone-68609
05/22/2026, 6:55 AMtall-airline-16756
05/22/2026, 6:55 AMcontext.session.current_agent, gets its simple class name and fully qualified name, and returns them.
from livekit_agents import function_tool, RunContext # adjust imports to your SDK
@function_tool()
async def my_tool(self, context: RunContext):
agent = context.session.current_agent
# Simple class name
class_name = type(agent).__name__
# Fully qualified name (module + class)
fq_name = f"{agent.__class__.__module__}.{agent.__class__.__qualname__}"
# Example: use for logging and return to caller
print(f"Agent class: {class_name}")
print(f"Agent fully qualified name: {fq_name}")
return {
"class_name": class_name,
"fully_qualified_name": fq_name
}
Tell me if you want this example adjusted to log differently, use it in conditional logic, or include type checks.
, with interactive elements