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

Request without tools definition. #494

Closed
JIAQIA opened this issue May 13, 2024 · 4 comments
Closed

Request without tools definition. #494

JIAQIA opened this issue May 13, 2024 · 4 comments
Assignees

Comments

@JIAQIA
Copy link

JIAQIA commented May 13, 2024

Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Requests which include tool_use or tool_result blocks must define tools.'}}

I believe this issue could be better addressed directly to the Anthropic Server Team, but I have not found a way to report this issue directly.

When interacting with the Anthropic API, my initial request includes the necessary tool definitions, which are processed correctly. However, for certain reasons, I need to remove the tool definitions after responding to the assistant's tool_use request appropriately. Subsequent messages sent to the Anthropic API without tool definitions then trigger the error mentioned above.

It is a common scenario to toggle between states where tools are either provided or not, as sometimes it is necessary to manually avoid unintended tool invocations. The simplest method is not to include tool definitions when they are not needed. However, the current design of the API seems to require that once tools have been invoked, all subsequent requests must include tool definitions. This requirement seems unreasonable. We hope that Anthropic will consider this use case and make necessary adjustments.

@JIAQIA
Copy link
Author

JIAQIA commented May 13, 2024

Anthropic Version: 0.25.8
SDK API: beta.tools.messages.create

@aaron-lerner
Copy link

Hi @JIAQIA, thanks for the question. Tool definitions are required in requests containing tool_uses and tool_requests because it aids the model in understanding what those tool_uses and tool_requests actually mean. To get the best responses from our models, it's important that they understand the entirety of the conversation included in the request.

@JIAQIA
Copy link
Author

JIAQIA commented May 31, 2024

Hi, @aaron-lerner ,Yes, I can guess the reason for this design. However, I have a scenario that you might want to consider evaluating. I have a tail -f tool. As we know, this command can continuously collect output and doesn't stop automatically. When I provide this tool to Claude, once it is invoked, I will continuously feed it output. The specific implementation isn't standardized yet, but my personal implementation uses yield to periodically send content to Claude. I replace the previous content with the latest yield output before making the request, making it appear as if the overall content is the latest output.

However, there's a prerequisite: during the entire monitoring output process, Claude cannot invoke the tail -f tool again. From my practice, if I still provide the tail -f tool upon returning content, Claude is very likely to invoke it again.

This would be a big problem for me, similar to an infinite invocation loop.

@aaron-lerner
Copy link

I would suggest instructing Claude in the system prompt to not use any tools.

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