agent changing data before sending in tool
# support
h
any idea why the agent would successfully retrieve a phone number in a call then change a couple digits in the function tool? trying to send a phone number works most of the time but sometimes it sends the wrong number, and I can confirm it read the correct number from the logs changes last 4 digits call id db067eb0-e114-4ae7-aa7e-33130d12da11 https://cdn.discordapp.com/attachments/1349829151741181972/1349829151921541241/image.png?ex=67d485dc&is=67d3345c&hm=2ee6774328f54fc5f7fa4ace23668fd69d4c9314d19fdd56826735b3d9922009&
v
Hi there! I've looked into this issue where the agent is changing phone number digits when sending them to function tools. Based on the documentation, there are a few known issues with phone number handling in Vapi that might explain what you're seeing: 1. **Phone Number Formatting Issues**: There's a known issue where the API might append a US country code (+1) to phone numbers or alter their format during processing. This could potentially affect other digits as well. 2. **Transformation Rules**: Vapi applies specific transformation rules to phone numbers before invoking function tools. According to the documentation, phone numbers undergo manipulation through a process like:
Copy code
javascript
   formatted_number: number.number?.replace(/(\+1)(\d{3})(\d{3})(\d{4})/, '$1-$2-$3-$4')
If there's a bug in this transformation logic, it could potentially alter digits. 3. **Tool Call Execution Issues**: Users have reported irregular tool call execution where functions sometimes behave unexpectedly. For your specific case where the last 4 digits are being changed, this could be related to a bug in the phone number parsing or formatting logic. The system might be incorrectly processing or transforming the number before sending it to the function. I'd recommend checking if there are any patterns to when this occurs - is it happening with specific phone number formats or under certain conditions? Sources: - [Discord Thread about Phone Number Formatting](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343612796717371393) - [Discord Thread about Tool Call Issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342336047589359618) - [Discord Thread about Phone Number Transformation](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1328923059905630238)
h
Copy code
{
  "type": "object",
  "properties": {
    "phone_number": {
      "description": "the phone number attached to the clients account"
      "type": "string"
    }
  },
  "required": []
}
changed to
Copy code
{
  "type": "object",
  "properties": {
    "phone_number": {
      "description": "the phone number attached to the clients account must be a U.S. number in E.164 format",
      "type": "string"
    }
  },
  "required": [
    "phone_number"
  ]
}
worked first attempt but it seems to be random
worked fine for a bit then started sending number without the +1 formatting
v
Hello Ham, Please lower the temperature on your LLM to around .6 and this should solve your issue.
h
I will do that thank you, I also told it to just send the 10 digits the contact gives no formating, working so far
v
Great to hear Ham! Happy building