Repository navigation
Conversation
Contributor
|
Thanks for the pull request. One thing worth sorting out before it is reviewed:
If you think it belongs here anyway, say so and a maintainer will take a look. |
Contributor
Author
|
Same as on #3853: the PR is linked to a confirmed issue — #3845, assigned to me — and intentionally uses |
… offload timeout ToolOffloadMiddleware applies one deployment-wide timeout (tool_offload_timeout_secs, agentscope-ai#3330) to every tool, and only is_state_injected / is_external_tool tools escape offloading. Tool authors who know better have no say: a tool whose delayed result would confuse the caller, or that knows it needs more or less wall-clock time than the default, cannot express that (agentscope-ai#3845, "Make execution policy and timeout configurable per tool"). Two ToolBase attributes, following the existing per-tool policy pattern: - is_offloadable=True (default): when False, the tool always runs synchronously, exactly like is_state_injected tools. - offload_timeout_secs=None (default): a number replaces the middleware-wide timeout for that tool's calls. Both default to the current behavior, so existing tools are unaffected.
konlue
force-pushed
the
feat/tool-offload-per-tool-policy
branch
from
November 9, 2026 15:33
8ee5dae to
02a920f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3845
AgentScope Version
main @
d8ebf89Description
Problem
ToolOffloadMiddlewareapplies one deployment-wide timeout (tool_offload_timeout_secs, #3330) to every tool, and onlyis_state_injected/is_external_tooltools escape offloading entirely. Tool authors who know better have no say:This is the "Make execution policy and timeout configurable per tool" item of #3845.
Changes
src/agentscope/tool/_base.py— two newToolBaseattributes, following the existing per-tool policy pattern (is_state_injected,is_external_tool):is_offloadable: bool = True— whenFalse, the middleware always runs the tool synchronously, exactly likeis_state_injectedtools.offload_timeout_secs: float | None = None— when set, replaces the middleware-wide timeout for this tool's calls;Nonekeeps the deployment default.src/agentscope/app/middleware/_tool_offload_middleware.py:not tool.is_offloadable);on_actingdocstrings document the two knobs.Both attributes default to the current behavior, so existing tools and deployments are unaffected;
tool_offload_timeout_secs=None(middleware disabled) continues to work as before. This complements #3853, which makes the offload placeholder itself machine-readable.How to test
pytest tests/tool_offload_middleware_test.py— 10 passed (7 existing + 3 new).test_tool_opting_out_of_offload_runs_synchronously:is_offloadable=Falsetool that outlives the timeout returns its real result and registers nothing in the background; fails on unpatched source (the tool gets a synthetic placeholder).test_per_tool_timeout_override_extends_the_wait:offload_timeout_secs=1.0survives a 0.05 s middleware-wide timeout; fails on unpatched source.test_per_tool_timeout_override_shortens_the_wait:offload_timeout_secs=0.01offloads a 0.5 s tool even under a 5 s middleware-wide timeout; fails on unpatched source.black --line-length=79andflake8clean on all three changed files.Checklist
/cc @lins — this and #3853 are the two slices of #3845 that can land without design decisions; the remaining items there (persistent result store, task management API) are untouched.