Open GuilhermeKO opened 3 months ago
Thanks for raising! Could you share a link to an example trace where this occurs?
Sure thing! Here is the link: https://smith.langchain.com/public/3537d35c-9ff2-445f-92bf-94586c0874b3/r
@GuilhermeKO if you look at the tool names, you'll see there's an invalid space in your tool name there:
"tool_calls": [
{
"name": "authenticate_user ",
"args": {
"cpf_or_cnpj": "12345678900",
"password": "Senha12345"
},
"id": "toolu_01D1GYt1s5UhtKd2dNQydjY5"
}
],
Notice the "authenticate_user "
I'm not entirely sure why the model is adding the space, since the schema provided seems to be correct. Will check on our side if anything is fishy
{"name":"authenticate_user","description":"This tool authenticates the current user, so tools that use the solar API will be able to fetch the user data. You must use this tool if the user is actually not authenticated or if some other tool failed with auth issues.","input_schema":{"type":"object","properties":{"cpf_or_cnpj":{"type":"string","description":"User cpf or cnpj value."},"password":{"type":"string","description":"User password"}},"required":["cpf_or_cnpj","password"]}}
Issue you'd like to raise.
The following error occurs when creating consecutive AI messages with tool calls followed by Tool Messages:
400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.3.content.0.tooluse.name: String should match pattern '^[a-zA-Z0-9-]{1,64}$'"}}
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.3.content.0.tooluse.name: String should match pattern '^[a-zA-Z0-9-]{1,64}$'"}} at APIError.generate (file:///node_modules/@anthropic-ai/sdk/error.mjs:36:20) at Anthropic.makeStatusError (file:///node_modules/@anthropic-ai/sdk/core.mjs:256:25) at Anthropic.makeRequest (file:///node_modules/@anthropic-ai/sdk/core.mjs:299:30) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async RetryOperation._fn (/node_modules/p-retry/index.js:50:12
Steps to Reproduce:
Provider: ChatAnthropic Model: claude-3-5-sonnet-20240620
tool name: getOrderData tool id : toolu_018kq2eUEPncj2jBeEodys4Q
tool name: getOrderData tool id: toolu_018kq2eUEPncj2jBeEodys4Q
Note: Works fine until this point.
Now create another AI message with tool call: tool name: authenticate_user tool id : toolu_01D1GYt1s5UhtKd2dNQydjY5
And another Tool message with response: tool name: authenticate_user tool id : toolu_01D1GYt1s5UhtKd2dNQydjY5
Running this generates the error above mentioned. I have tried changing the tools names as the error suggests and tried changing the order of tools but nothing changed. Both tools work when there is no consecutive tool.
Screenshot with initial AI and Tool Message:
Screenshot with The consecutive Ai and Tool Messages:
Screenshot with Error:
Suggestion:
No response