https://retellai.com/?utm_source=discord&utm_medium=seo logo
Custom Functions ignoring the JSON schema during t...
# ❓・bug-report
j
I have a bot that has a custom tool function with the following schema: { "type": "object", "required": [ "message" ], "properties": { "message": { "type": "string", "description": "You must include the company name of the user and their company role. You must format it like this: 'Company name: [INSERT_COMPANY_NAME], Company Role: [INSET_COMPANY_ROLE]" } } } The reason for doing it this way is because I can only send a 'message' to the API I'm connecting to, when running the bot in production (after publishing), the tool call always works as expected, for example: tool_call_id: 18206f52d5a4d92b { "message": "Demo request from Jack Example. Company name: Example Ltd, Company Role: Founder. Email: jack@example.com, Phone: 07123123123." } However, when running the tests around this bot, the bot consistently ignores this JSON schema and calls the tools with this payload: tool_call_id: 66311391b2c68319 { "message": "Demo request from Jack Example, Founder at Example Ltd. Interested in automating internal admin processes such as onboarding, project workflows, and recurring communications. Contact details: jack@example.com, +447123123123. Please arrange a personalised demo and follow up with Jack.", "Company name": "Example Ltd", "Company Role": "Founder" } I've ran the tests 10 times and had 10 production chats and every time, this happens The model is GPT 4.1, which is the same in my test cases Is anyone else having this issue? How do I solve this? I'd like to be able to test the structure within the test-cases to validate the right information is being sent
s
Hi @jackpickering_73300
Have you tried. To fix this, Adding explicit instructions in the schema description: “Only return a single message property, no other fields.”
Its prompting issue it can be solved providing write prompt before triggering function so llm can pass right info to function and function can perform that task
j
I find it strange that it'd be a prompting issue when it works every time on the production bot and fails every time on the test-cases, is there a difference in system prompts between the two that could cause this? Also, by 'schema description' do you mean the description in the tool call?
@shahretell - can you let me know on the above when you get some time please, I believe being able to accurately test tool call requests within test-cases is a really useful feature for reliability
s
Hi @jackpickering_73300 try defining the exact json in tool description so llm know exact body to send to that API
j
Hi @shahretell , I have done that already, but the question is, why does the test-case tool calls work differently to the production tool-calls? I am happy to do this for a quick fix, but I feel like its abstracting some internal knowledge that would be useful when writing our test-cases to work effectively