[Feature] ToolCompose with parallel dispatch, builtin tools, legacy adapter#3736
Open
vmoens wants to merge 1 commit intogh/vmoens/267/basefrom
Open
[Feature] ToolCompose with parallel dispatch, builtin tools, legacy adapter#3736vmoens wants to merge 1 commit intogh/vmoens/267/basefrom
vmoens wants to merge 1 commit intogh/vmoens/267/basefrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3736
Note: Links to docs will display an error until the docs builds have been completed. ❌ 4 New FailuresAs of commit c36ab72 with merge base d386287 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
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.
Stack from ghstack (oldest at bottom):
Lands the headline orchestrator: ToolCompose(Compose) parses each
assistant message once, dispatches matched tools concurrently via
asyncio.gather, and injects structured results into History. ChatEnv is
unchanged; ToolCompose drops into any TransformedEnv.
Public API additions in torchrl.envs.llm.agentic:
insert. Owns the parser, honors pass_state_to_tools (mirrors the legacy
ExecuteToolsInOrder knob), supports per-tool RateLimiter, and surfaces
three keys per step: ("agentic","any_tool_calls"),
("agentic","any_error"), ("agentic","stop_requested").
FileReadTool, StopTool. StopTool raises StopSignal which the dispatcher
translates into the stop_requested flag.
ToolTransformBase-shape object (PythonInterpreter, BrowserTransform,
MCPToolTransform, SimpleToolTransform) into a Tool. Existing user code
drops into ToolCompose without rewriting.
Stable call_id is enforced end-to-end: parsers assign deterministic ids,
ToolCompose populates ToolContext.call_id, and parsers' render_result
echoes the same id back into the tool message injected into History.
Nested-loop safety: when ToolCompose._step is called from inside a
running event loop (e.g. Jupyter), dispatch is offloaded to a worker
thread that owns its own loop. asyncio.run is used otherwise.
Tests extend test/llm/test_llm_transforms.py with TestToolCompose,
TestPythonTool, TestShellTool, TestLegacyAdapter (19 tests):
parallel-dispatch wall-time check (3 x 500ms < 0.9s), StopTool
termination, schema validation rejection, raise-on-non-Tool insert,
duplicate-name rejection, pass_state_to_tools on/off, rate-limit
serialization, failure isolation, stable call_id round-trip, nested-loop
safety, legacy adapter end-to-end. All existing legacy
ExecuteToolsInOrder/XMLBlockParser/JSONCallParser tests still pass.
benchmarks/test_llm.py gains an "agentic-dispatch" group with parallel
n=3 / n=8 and a single-call baseline so reviewers can see parallel
dispatch flattens the wall-time curve.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com