Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: Error when using two consecutive tools on playground ChatAnthropic claude-3-5-sonnet-20240620 #899

Open
GuilhermeKO opened this issue Jul 30, 2024 · 3 comments

Comments

@GuilhermeKO
Copy link

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.tool_use.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.tool_use.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

  1. Create a AI message with tool call:

tool name: getOrderData
tool id : toolu_018kq2eUEPncj2jBeEodys4Q

{
  "days": 30,
  "unfinisehd_orders": "false"
}

  1. Then the Tool message with the response:

tool name: getOrderData
tool id: toolu_018kq2eUEPncj2jBeEodys4Q

[
  {
    "orderCode": "123456789",
    "orderDate": "11/07/2024",
    "status": "Canceled",
    "deliveryDate": "12/07/2024",
    "origin": "Test1",
    "orderPrice": 20.01
  }
]

Note: Works fine until this point.

  1. Now create another AI message with tool call:
    tool name: authenticate_user
    tool id : toolu_01D1GYt1s5UhtKd2dNQydjY5
{
  "user_info": "1234567890",
  "password": "password"
}
  1. And another Tool message with response:
    tool name: authenticate_user
    tool id : toolu_01D1GYt1s5UhtKd2dNQydjY5
"Authenticated"

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:
image

Screenshot with The consecutive Ai and Tool Messages:
image

Screenshot with Error:
image

Suggestion:

No response

@hinthornw
Copy link
Collaborator

Thanks for raising! Could you share a link to an example trace where this occurs?

@GuilhermeKO
Copy link
Author

@hinthornw
Copy link
Collaborator

hinthornw commented Aug 1, 2024

@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"]}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants