Skip to content

feat: add configurable HTTP timeout for tool execution#166

Open
RomSes2 wants to merge 1 commit intomainfrom
fix/configurable-http-timeout
Open

feat: add configurable HTTP timeout for tool execution#166
RomSes2 wants to merge 1 commit intomainfrom
fix/configurable-http-timeout

Conversation

@RomSes2
Copy link
Copy Markdown

@RomSes2 RomSes2 commented Apr 6, 2026

Summary

  • httpx.request() in StackOneTool.execute() was called without a timeout parameter, defaulting to httpx's 5s. Slow providers (e.g. Workday, which regularly takes 10-15s) cause ReadTimeout errors.
  • Adds a timeout field to ExecuteConfig (default 30s) and passes it to httpx.request()
  • Adds timeout to ExecuteToolsConfig so users can configure it at the toolset level

Usage

toolset = StackOneToolSet(
    execute={"account_ids": ["..."], "timeout": 60},
)

Test plan

  • All existing tests pass (40/40 in test_models.py)
  • Verified manually against Workday connector — calls that previously timed out at 5s now succeed at 15s with timeout=60
  • Default of 30s is backwards-compatible (previously was httpx's 5s default, so this is strictly more generous)

🤖 Generated with Claude Code


Summary by cubic

Adds a configurable HTTP timeout for tool execution to reduce ReadTimeouts with slow providers. Default is 30s and applied to all tool HTTP requests, overridable per toolset.

  • New Features
    • Added timeout to ExecuteConfig (default 30s) and pass it to httpx.request(...).
    • Exposed timeout in ExecuteToolsConfig so it can be set on init, e.g. StackOneToolSet(execute={"account_ids": ["..."], "timeout": 60}).

Written for commit a329c46. Summary will update on new commits.

httpx.request() was called without a timeout, defaulting to 5s.
Slow providers (e.g. Workday) regularly exceed this, causing
ReadTimeout errors.

- Add `timeout` field to `ExecuteConfig` (default 30s)
- Pass it through to `httpx.request()`
- Add `timeout` to `ExecuteToolsConfig` so users can set it at init:
  `StackOneToolSet(execute={"account_ids": [...], "timeout": 60})`
- Thread timeout from toolset config through `_StackOneRpcTool`

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 6, 2026 22:45
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Auto-approved: Adds configurable HTTP timeout with a safe default of 30s, improving reliability for slow external providers without impacting core logic.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes tool execution HTTP requests more resilient by adding a configurable timeout (defaulting to 30s) and wiring it through the toolset and tool execution path to avoid ReadTimeout on slower providers.

Changes:

  • Added timeout to ExecuteConfig (default 30.0) and passed it to httpx.request() during tool execution.
  • Added timeout to ExecuteToolsConfig and propagated it into RPC tool construction (_StackOneRpcTool).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
stackone_ai/toolset.py Adds execute.timeout config and passes it into _StackOneRpcTool via ExecuteConfig(timeout=...).
stackone_ai/models.py Extends ExecuteConfig with timeout and forwards it into httpx.request(...) during StackOneTool.execute().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 59 to +74
class ExecuteToolsConfig(TypedDict, total=False):
"""Execution configuration for the StackOneToolSet constructor.

Controls default account scoping for tool execution.

When set to ``None`` (default), no account scoping is applied.
When provided, ``account_ids`` flow through to ``openai(mode="search_and_execute")``
and ``fetch_tools()`` as defaults.
"""

account_ids: list[str]
"""Account IDs to scope tool discovery and execution."""

timeout: float
"""HTTP request timeout in seconds for tool execution. Defaults to 30."""

Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The ExecuteToolsConfig docstring still describes only account scoping, but this config now also controls HTTP execution timeout. Update the class docstring/constructor docs to mention the new timeout option so users discover it and understand what it affects (e.g., tool execution requests).

Copilot uses AI. Check for mistakes.
Comment on lines 248 to 255
request_kwargs["data"] = body_params

if query_params:
request_kwargs["params"] = query_params

response = httpx.request(**request_kwargs)
response = httpx.request(**request_kwargs, timeout=self._execute_config.timeout)
response_status = response.status_code
response.raise_for_status()
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

New behavior passes timeout=self._execute_config.timeout into httpx.request(), but the test suite doesn’t currently assert that the timeout is forwarded (or that the default 30s is applied). Add/adjust a unit test to verify httpx.request is called with the expected timeout value, and that overriding ExecuteConfig(timeout=...) changes the value passed through.

Copilot uses AI. Check for mistakes.
Comment on lines 1189 to 1204
parameters = ToolParameters(
type=str(schema.get("type") or "object"),
properties=self._normalize_schema_properties(schema),
)
timeout = (
self._execute_config.get("timeout", 30.0) if self._execute_config else 30.0
)
return _StackOneRpcTool(
name=tool_def.name,
description=tool_def.description or "",
parameters=parameters,
api_key=self.api_key,
base_url=self.base_url,
account_id=account_id,
timeout=timeout,
)
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The new toolset-level execute.timeout is used when constructing _StackOneRpcTool, but there’s no test ensuring that a configured timeout actually propagates into each tool’s ExecuteConfig (and therefore into HTTP execution). Add a toolset test that creates StackOneToolSet(execute={"timeout": ...}), fetches a tool (mocking MCP catalog if needed), and asserts the resulting tool executes with that timeout.

Copilot uses AI. Check for mistakes.
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