Skip to content

fix(WebSearchTool): add configurable timeout parameter#2198

Open
fuleinist wants to merge 1 commit intohuggingface:mainfrom
fuleinist:fix/websearchtool-timeout-configurable
Open

fix(WebSearchTool): add configurable timeout parameter#2198
fuleinist wants to merge 1 commit intohuggingface:mainfrom
fuleinist:fix/websearchtool-timeout-configurable

Conversation

@fuleinist
Copy link
Copy Markdown

Problem

Both search_duckduckgo() and search_bing() in WebSearchTool call requests.get() without a timeout argument. This causes requests to hang indefinitely in slow/corporate proxy environments, and provides no way for users to adjust the wait time.

Solution

Adds an optional timeout parameter to WebSearchTool.__init__() with a default of 30 seconds. All requests.get calls inside the search methods now pass timeout=self.timeout.

This is a non-breaking change: the default behavior is unchanged.

Usage example

from smolagents import WebSearchTool

# Use default 30-second timeout
tool = WebSearchTool()

# Custom 60-second timeout for slow networks
tool = WebSearchTool(timeout=60)

Notes

Adds a timeout parameter to WebSearchTool.__init__() with a default of
30 seconds. Both search_duckduckgo() and search_bing() now pass this
timeout to requests.get(), making the tool more configurable for both
slow corporate proxy environments and latency-sensitive applications.

This is a non-breaking change: the default behavior is unchanged.
Copy link
Copy Markdown

@VANDRANKI VANDRANKI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition - having a configurable timeout is better than leaving it to the library default (which is often unlimited).

One gap: the timeout parameter is wired to search_duckduckgo and search_bing, but search_exa (added in #2139) hardcodes timeout=30 in its requests.post call and ignores self.timeout. Should pass timeout=self.timeout there too for consistency.

10ishq added a commit to 10ishq/smolagents that referenced this pull request Apr 23, 2026
Use getattr(self, 'timeout', 30) instead of hardcoded timeout=30
so search_exa respects self.timeout when the configurable timeout
parameter is added to WebSearchTool (see huggingface#2198).

Co-Authored-By: Tanishq Jaiswal <[email protected]>
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.

2 participants