my agents are always reading the function out loud...
# ask-ai
c
my agents are always reading the function out loud instead of executing it. what might be the cause and how can I fix it?
t
Thanks for reaching out, Bryce. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
If your agents are reading function names aloud instead of executing them, it could be due to one of the following reasons: • Function Not Registered as a Tool: Ensure that the functions are properly decorated with
@function_tool()
and registered in the agent's context. • LLM Response Format: If the LLM generates the function name as plain text instead of a callable format, the agent will treat it as text to be spoken. • Tool Registration: Verify that the tool is correctly registered and recognized by the agent. To resolve this, check that: 1. All functions are defined with
@function_tool()
. 2. The LLM is configured to generate function calls in the correct format. 3. The tools are properly registered in the agent's context. Let me know if you need further assistance with any of these steps. Sources: tests/test_evals.py
c
how can I check 2 and 3?
t
Here’s a friendly guide to help you verify the LLM response format and tool registration: • Verify LLM Response Format: Take a look to see if the LLM response includes a
tool_calls
array with the tool’s
name
,
arguments
, and sometimes an
id
. Here’s an example to make it clearer:
Copy code
{
  "tool_calls": [
    {
      "function": {
        "name": "special_function",
        "arguments": "{\"arg1\": 1}",
        "id": "123456789"
      }
    }
  ]
}
Verify Tool Registration: Make sure your tools are registered with their schema definitions in JSON format. The schema should include the tool’s
name
,
description
, and
parameters
. Check out this example:
Copy code
{
  "type": "function",
  "function": {
    "name": "special_function",
    "description": "I'm special",
    "parameters": {
      "type": "object",
      "properties": {
        "arg1": {
          "type": "integer",
          "description": "The arg."
        }
      },
      "required": [
        "arg1"
      ]
    }
  }
}
Testing: Try running some test cases to confirm tool registration and response parsing are working smoothly. For example, send a request to execute a tool and check that the response includes the right tool call with the expected arguments. If you want, I’m here to help guide you through any part of this—just let me know!