generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 217
Open
Labels
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
1.13.0
Tools Package Version
0.2.12
Tools used
- File Read
Python Version
3.12.4
Operating System
macOS 15.7
Installation Method
pip
Steps to Reproduce
from strands_tools.file_read import file_read
file_read({
"toolUseId": "tooluse_8Xt6CI1ESNG9OkZa6F0Gvg",
"name": "file_read",
"input": {
"path": "/path/to/file",
"mode": "search",
"search_pattern": "<pattern that does not exist in file>",
"context_lines": 8
}
}
)
Expected Behavior
The tool call should result in an error indicating no results were found
{
"toolUseId": "<tooluse_ok5yc_fORPeK2jZhlq7z4Q>",
"status": "error",
"content": [{"text": "No search results found!"}]
}
Actual Behavior
Response:
{
"role": "user",
"content": [
{
"toolResult": {
"toolUseId": "tooluse_8Xt6CI1ESNG9OkZa6F0Gvg",
"status": "success",
"content": []
}
}
]
}
When an agent is operating, this leads to a bedrock exception:
litellm.BadRequestError: BedrockException - {\"message\":\"The model returned the following errors: messages.7: `tool_use` ids were found without `tool_result` blocks immediately after: tooluse_8Xt6CI1ESNG9OkZa6F0Gvg. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"}
Additional Context
No response
Possible Solution
If results is empty throw an exception instead of returning an empty content block
elif mode == "search":
results = search_file(
console,
file_path,
tool_input.get("search_pattern", ""),
tool_input.get("context_lines", file_read_context_lines_default),
)
if not results:
raise Exception("No search results found!")
response_content.extend([{"text": r["context"]} for r in results])
Related Issues
No response
niccalle