Skip to content

fix(tools): add timeouts to HTTP requests in API client helpers#6301

Open
agharsallah wants to merge 1 commit into
google:mainfrom
agharsallah:fix/http-request-timeouts
Open

fix(tools): add timeouts to HTTP requests in API client helpers#6301
agharsallah wants to merge 1 commit into
google:mainfrom
agharsallah:fix/http-request-timeouts

Conversation

@agharsallah

Copy link
Copy Markdown

Link to Issue or Description of Change

2. Or, if no issue exists, describe the change:

Problem:

Every requests.get/requests.post call in the API Hub and Application
Integration tool clients omitted the timeout= argument. python-requests
defaults to no timeout, so a stalled or unresponsive endpoint hangs the tool
invocation — and therefore the agent — indefinitely. This was also an internal
inconsistency: load_web_page.py already sets a default request timeout
(_DEFAULT_TIMEOUT_SECONDS = 30).

Affected call sites:

  • src/google/adk/tools/apihub_tool/clients/apihub_client.py (4 requests.get)
  • src/google/adk/tools/application_integration_tool/clients/connections_client.py (1 requests.get)
  • src/google/adk/tools/application_integration_tool/clients/integration_client.py (1 requests.post)

Solution:

Add a module-level _REQUEST_TIMEOUT_SECONDS = 30 constant to each client
module (matching the value used in load_web_page.py) and pass timeout= to
every request call site. Keeping a named constant per module makes the value
discoverable and easy to tune, consistent with the existing pattern.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Extended the existing client tests to assert the mocked requests.* call
receives a timeout argument (timeout=ANY).

$ pytest tests/unittests/tools/apihub_tool/clients/test_apihub_client.py \
         tests/unittests/tools/application_integration_tool/clients/test_connections_client.py \
         tests/unittests/tools/application_integration_tool/clients/test_integration_client.py
94 passed, 5 warnings

Manual End-to-End (E2E) Tests:

Not applicable — this is a minimal, behavior-preserving change (adds a request
timeout only). Existing unit tests cover the request call sites.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

🤖 Generated with Claude Code

@google-cla

google-cla Bot commented Jul 5, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

The requests.get/post calls in the API Hub and Application Integration
tool clients omitted timeout=, so python-requests would wait forever on
a stalled endpoint, hanging the tool invocation (and the agent). This
also brought the clients in line with load_web_page.py, which already
sets a default request timeout.

Add a module-level _REQUEST_TIMEOUT_SECONDS constant (30s, matching
load_web_page.py) to each client module and pass timeout= to every
request call site. Extend the existing client tests to assert the
mocked request receives timeout.

Signed-off-by: agharsallah <17379925+agharsallah@users.noreply.github.com>
@agharsallah agharsallah force-pushed the fix/http-request-timeouts branch from 3fb0319 to 5f829c1 Compare July 5, 2026 18:07
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.

1 participant