@function_tool async def transfer_call( self, ...
# ask-ai
d
@function_tool async def transfer_call( self, ctx: RunContext[HelperSessionInfo], should_transfer: bool = Field( description="Boolean. Always required. True if the user explicitly asked to be transferred. False if the user did not ask." ), ) -> None: can the llm read the description in a function tool?
t
Thanks for reaching out, Billy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely! An LLM can definitely read and use the description field in a function tool within the LiveKit Agents framework. This description—whether it comes from the function’s docstring or is explicitly provided through the
@function_tool
decorator—is shared with the LLM to help it understand exactly when and how to call the tool. For example, in Python:
Copy code
@function_tool()
async def get_weather(self, location: str) -> str:
    """
    Called when the user asks about the weather.

    Args:
        location: The location to get the weather for
    """
    return f"The weather in {location} is sunny today."
Here, the docstring is carefully parsed and sent to the LLM as the tool's description, including helpful details about the parameters. This way, the LLM can make smart decisions about invoking the function based on what the user wants. The framework makes sure this description is included in the tool schema sent to different LLM providers like OpenAI, Anthropic, Google Gemini, and AWS Bedrock. If no description is given, it might simply default to "No description provided." Please feel free to reach out if you’d like me to explain anything further or if there’s anything else I can help with! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py | avatars/hedra/dynamically_created_avatar/agent.py | agents/src/llm/tool_context.ts | Tool definition and use | LiveKit Docs
d
Copy code
class AlreadyBooked(AgentTask[bool]):
    def __init__(self, chat_ctx=None):
  
        super().__init__(
        instructions="""Let caller know they have an existing booking and them if they want to speak with someone""",
        chat_ctx=chat_ctx,
    )
    async def on_enter(self) -> None:
        logger.info(":eyes: Booking EXISTS!")
        await self.session.generate_reply(
            instructions=f"Ask if they want to speak with someone in regards to their painting project"
        )

    @function_tool
    async def transfer_call(self, ctx: RunContext[HelperSessionInfo], transfer_requested: bool = False, transfer_declined: bool = False) -> None:
        """Transfer caller
        
        Args: transfer_declined: bool set True if user declines transfer. 
        """
        logger.info("🏃‍♂️‍➡️ Running transfer_call function")
        participant_id = ctx.session.userdata.participant_identity
        job_ctx = get_job_context()
        room_name = job_ctx.room.name
        if transfer_requested:
            logging.info(":white_check_mark: xfer requested")
            await transfer_caller(participant_identity=participant_id,room_name=room_name)
            self.complete(True)
        if transfer_declined:
            logging.info(":x: xfer declined")
            self.complete(True)
if user declines it does not work no matter what i try
t
I'd love to help you get to the bottom of the issue with the
transfer_declined
parameter. Could you please share a bit more information? • Where did you come across the
transfer_declined
setting? Was it in documentation, a code example, or maybe an error message? • Are you noticing any specific errors or unexpected behavior when you're trying to do call transfers? • Which SIP provider are you working with? For example, Telnyx or Wavix? With these details, we'll be able to pinpoint the problem and find the best way to resolve it together. Sources: agent.py | Docs::Telephony