Skip to content

hitl_tool: _poll_for_decision ignores interval parameter and always sleeps for POLL_INTERVAL_S #191

Open

Description

@RobinaMirbahar

Describe the bug
hitl_tool accepts a poll_interval: float = POLL_INTERVAL_S argument and forwards it as interval to _poll_for_decision(api_base, request_id, poll_interval, timeout) in src/google/adk_community/tools/hitl/gateway.py. However, inside _poll_for_decision, the sleep call on each poll cycle ignores the interval parameter and hardcodes the module-level POLL_INTERVAL_S constant:

await asyncio.sleep(POLL_INTERVAL_S + random.uniform(0, POLL_JITTER_S))

As a result, passing a custom poll_interval to @hitl_tool(agent_name="...", poll_interval=0.25) (or calling _poll_for_decision(..., interval=0.25)) has no effect and always sleeps for POLL_INTERVAL_S (2.0s) plus jitter.

To Reproduce

  1. Decorate a tool with a custom poll_interval, e.g., @hitl_tool(agent_name="credit_agent", poll_interval=0.25).
  2. Have GET /approvals/{id} return {"status": "pending"} on the first poll before transitioning to {"status": "approved"}.
  3. Observe that _poll_for_decision sleeps for POLL_INTERVAL_S + random.uniform(0, POLL_JITTER_S) instead of interval + random.uniform(0, POLL_JITTER_S).

Expected behavior
_poll_for_decision should use its interval parameter (await asyncio.sleep(interval + random.uniform(0, POLL_JITTER_S))), while still defaulting to POLL_INTERVAL_S when poll_interval is not explicitly passed to hitl_tool.

Proposed fix
Update _poll_for_decision in src/google/adk_community/tools/hitl/gateway.py to sleep for interval + random.uniform(0, POLL_JITTER_S) and add unit tests in tests/unittests/tools/test_hitl_gateway.py covering custom poll_interval sleep behavior across pending polls and timeout handling.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions