Skip to content

fix(file_read): return error message when search finds no results#505

Open
wangwangbobo wants to merge 4 commits into
strands-agents:mainfrom
wangwangbobo:fix/file-search-empty-results
Open

fix(file_read): return error message when search finds no results#505
wangwangbobo wants to merge 4 commits into
strands-agents:mainfrom
wangwangbobo:fix/file-search-empty-results

Conversation

@wangwangbobo

Copy link
Copy Markdown
Contributor

Summary

When search_file returns empty results, the tool was returning an empty content list {"content": []} with status: "success". This causes a Bedrock API error because tool_use IDs must have corresponding tool_result blocks.

Fix

Added a check after search_file() — if results are empty, append a clear error message instead of extending with empty results.

if not results:
    response_content.append({"text": "No search results found for the given pattern."})
else:
    response_content.extend([{"text": r["context"]} for r in results])

Related Issue

Fixes #303

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

Successfully merging this pull request may close these issues.

[BUG] file_read search mode returns empty list if results is empty

1 participant