Skip to content

Conversation

pgrayy
Copy link
Member

@pgrayy pgrayy commented Aug 11, 2025

Description

  • Allow users to decide whether tools should run concurrently or sequentially.
    • Currently, we execute all tools concurrently.
    • Sequential execution can however be useful (e.g., user wants agent to first use browser tool to navigate to a website and then snapshot tool to take a picture).

For more details, please see comments in file diff.

Usage

Sequential

from strands import Agent
from strands.tools.executors import SequentialToolExecutor

agent = Agent(tool_executor=SequentialToolExecutor(), tools=[screenshot_tool, email_tool])
agent("Please take a screenshot and then email the screenshot to my friend")

Assuming the model returns screenshot_tool and email_tool use requests, the SequentialToolExecutor will execute both sequentially in the order given.

Concurrent

from strands import Agent
from strands.tools.executors import ConcurrentToolExecutor

agent = Agent(tool_executor=ConcurrentToolExecutor(), tools=[weather_tool, time_tool])
agent("What is the weather and time in New York?")

Assuming the model returns weather_tool and time_tool use requests, the ConcurrentToolExecutor will execute both concurrently. Note, this is the default executor and so Agent(tools=[weather_tool, time_tool]) will result in the same behavior.

Related Issues

#614

Documentation PR

Will follow up

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare: Wrote new unit and integration tests

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Follow Up

Will document the following items in an issue tracker after PR approval:

  1. Add tool executors page to our docs.
  2. Simplify/reorganize the before and after tool execution logic.
    • Currently, the base Executor class implements _stream and _stream_with_trace methods to wrap the tool execution with additional logic that includes tracing, hooks, exception handling, etc. It is a bit cumbersome and would maybe make more sense to be placed in the AgentTool implementations.
  3. Finalize the execute method interface.
    • We should be able to remove tool_results. execute could instead work as a generator that yields results upon completion that the caller (inside event_loop.py) collects. For this to work however, we require strongly typed events.
    • See if we can remove invocation_state as this parameter is on a deprecation path.
  4. Expose Executor as a public interface after clean up.
  5. Accept custom thread pools for sync tool execution.

@pgrayy pgrayy marked this pull request as ready for review August 11, 2025 22:24
@pgrayy pgrayy marked this pull request as draft August 19, 2025 18:53
@pgrayy pgrayy marked this pull request as ready for review August 20, 2025 14:58
@pgrayy pgrayy requested a review from zastrowm August 22, 2025 21:55
@pgrayy pgrayy merged commit c18ef93 into strands-agents:main Aug 25, 2025
12 checks passed
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.

3 participants