Skip to content

feat: add timeout and URL scheme validation to load_web_page #4886

Closed

Description

@cchinchilla-dev

Is your feature request related to a specific problem?

The load_web_page() function in src/google/adk/tools/load_web_page.py calls requests.get() without a timeout parameter. If the target server is unresponsive, the agent hangs indefinitely with no way to recover. Additionally, the function accepts any URL scheme (file://, ftp://, etc.) and does not handle Timeout or ConnectionError exceptions, causing uncontrolled errors to propagate.

Describe the Solution You'd Like

  1. Add timeout=10 to requests.get() to prevent indefinite hangs
  2. Validate that the URL scheme is http or https before making the request
  3. Handle requests.exceptions.Timeout and requests.exceptions.ConnectionError, returning descriptive error messages

Impact on your work

When building agents that use load_web_page as a tool, an unresponsive URL blocks the entire agent execution. This makes production deployments unreliable.

Willingness to contribute

Yes. I will submit a PR with the implementation and unit tests shortly.


Describe Alternatives You've Considered

Wrapping the tool call in a try/except at the agent level, but this pushes error handling to every consumer instead of solving it at the source.

Proposed API / Implementation

N/A - No API changes, only internal hardening. The function signature remains load_web_page(url: str) -> str.

Additional Context

The function already has SSRF protection via allow_redirects=False. These changes complement that existing hardening. The PR includes 11 unit tests covering all new behavior.

Activity

  1. added
    tools[Component] This issue is related to tools
    on Mar 18, 2026
  2. added theissue type on Mar 18, 2026
  3. added a commit that references this issue on Mar 18, 2026
    6fc296f
  4. sanketpatil06 commented on Mar 24, 2026

    @sanketpatil06

    @cchinchilla-dev, Thank you for submitting. It’s currently under review by our team, and I’ll keep you posted on any updates. We appreciate your input!

  5. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Mar 24, 2026
  6. cchinchilla-dev commented on Apr 30, 2026

    @cchinchilla-dev
    ContributorAuthor

    Hi @GWeale, after rebasing onto the latest upstream/main, the SSRF rewrite already covers URL-scheme validation and the unified failure path. The only remaining gap is the request timeout, which #4887 now addresses. See the PR for details. Thanks!

  7. added a commit that references this issue on Jun 11, 2026
    792775f
  8. added a commit that references this issue on Aug 11, 2026
    fad9a2c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs review[Status] The PR/issue is awaiting review from the maintainertools[Component] This issue is related to tools

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions