Open p-i- opened 1 week ago
Might be as simple as:
diff --git a/src/computer_use_demo/tools/collection.py b/src/computer_use_demo/tools/collection.py
index c4e8c95..ef17ed5 100644
--- a/src/computer_use_demo/tools/collection.py
+++ b/src/computer_use_demo/tools/collection.py
@@ -32,3 +32,9 @@ class ToolCollection:
return await tool(**tool_input)
except ToolError as e:
return ToolFailure(error=e.message)
+ except TypeError as e:
+ # Handle missing required arguments
+ return ToolFailure(error=f"Invalid tool arguments: {str(e)}")
+ except Exception as e:
+ # Catch all other exceptions and wrap them
+ return ToolFailure(error=f"Tool execution failed: {str(e)}")
Ya Hah! 🐛🔨That was a crash before.
Caused by this now resolved incident. I'll keep this one open until we address the unhandled exception in the demo. @p-i- would you be willing to open a PR?
@x5a Please wire it in yourself, simpler!
Caused by this now resolved incident. I'll keep this one open until we address the unhandled exception in the demo. @p-i- would you be willing to open a PR?
I believe that I am experiencing this issue. The below happened just an hour or two ago. I see this text in the link you provided:
"Between 21:00 UTC on October 28 through 04:15 UTC on October 30, API calls invoking tool use intermittently failed to include all parameters, including required parameters. This issue primarily affected requests to claude-3-5-sonnet-20241022 and claude-3-haiku-20240307, and has now been resolved."
According to https://www.utctime.net/ , the announcement indicates that this was supposed to have been resolved about 25 1/2 hours ago.
Here is the error, from here to the end of the comment. Thank you for your assistance.
File "/home/computeruse/computer_use_demo/loop.py", line 132, in sampling_loop raw_response = client.beta.messages.with_raw_response.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_legacy_response.py", line 377, in wrapped return cast(LegacyAPIResponse[R], func(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_utils/_utils.py", line 274, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/resources/beta/messages/messages.py", line 896, in create return self._post( ^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1277, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 954, in request return self._request( ^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1058, in _request raise self._make_status_error_from_response(err.response) from None
anthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.78: Did not find 1 tool_result
block(s) at the beginning of this message. Messages following tool_use
blocks must begin with a matching number of tool_result
blocks.'}
Caused by this now resolved incident. I'll keep this one open until we address the unhandled exception in the demo. @p-i- would you be willing to open a PR?
I believe that I am experiencing this issue. The below happened just an hour or two ago. I see this text in the link you provided:
"Between 21:00 UTC on October 28 through 04:15 UTC on October 30, API calls invoking tool use intermittently failed to include all parameters, including required parameters. This issue primarily affected requests to claude-3-5-sonnet-20241022 and claude-3-haiku-20240307, and has now been resolved."
According to https://www.utctime.net/ , the announcement indicates that this was supposed to have been resolved about 25 1/2 hours ago.
Here is the error, from here to the end of the comment. Thank you for your assistance.
File "/home/computeruse/computer_use_demo/loop.py", line 132, in sampling_loop raw_response = client.beta.messages.with_raw_response.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_legacy_response.py", line 377, in wrapped return cast(LegacyAPIResponse[R], func(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_utils/_utils.py", line 274, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/resources/beta/messages/messages.py", line 896, in create return self._post( ^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1277, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 954, in request return self._request( ^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1058, in _request raise self._make_status_error_from_response(err.response) from None
anthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.78: Did not find 1
tool_result
block(s) at the beginning of this message. Messages followingtool_use
blocks must begin with a matching number oftool_result
blocks.'}
@libertyteeth the error you're seeing is not symptomatic of the outage on Tuesday and instead indicates that your client (the demo) is sending a malformed request to the API. My best guess that you are encountering a known issue that results in the human turn request after a client side tool failure failing. If you have more information about the tool error that occurred before the API error, feel free to open a new issue.
I am seeing problem with all tool use again this morning:
BadRequestError
Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': "messages.1.content.1.tooluse.name: String should match pattern '^[a-zA-Z0-9-]{1,64}$'"}}
Is this again something that happens on the anthropic API side or a local problem of mine?
Consider the following crash dump:
The agent loop has used a tool incorrectly, and this has crashed the process.
This means the conversation is now lost. I encounter this kind of crash several times a day.
This kind of error should be trapped, so that the next agent cycle has an opportunity to invoke the tool correctly.
I'm connecting this issue with https://github.com/anthropics/anthropic-quickstarts/issues/121 as that represents another error that should be trapped thus allowing the agent loop to continue.