Skip to content

fix: preserve concurrent tool result order#2321

Open
he-yufeng wants to merge 1 commit into
strands-agents:mainfrom
he-yufeng:fix/concurrent-tool-result-order
Open

fix: preserve concurrent tool result order#2321
he-yufeng wants to merge 1 commit into
strands-agents:mainfrom
he-yufeng:fix/concurrent-tool-result-order

Conversation

@he-yufeng
Copy link
Copy Markdown

Description

ConcurrentToolExecutor used to append results into the shared tool_results list as each async task completed. That made prompt-cache breakpoint order depend on tool runtime instead of the original toolUse order.

This keeps each task's results local while the concurrent queue runs, then merges them back in the original tool-use order after the queue drains. Event streaming still happens as tasks finish; only the final tool_results ordering changes.

Related Issues

Fixes #2112

Documentation PR

No documentation PR. This is a bug fix for existing executor behavior.

Type of Change

Bug fix

Testing

  • uv run --extra dev pytest tests/strands/tools/executors/test_concurrent.py -q

  • uv run --extra dev pytest tests/strands/tools/executors -q

  • uv run --extra dev ruff format --check src/strands/tools/executors/concurrent.py tests/strands/tools/executors/test_concurrent.py

  • uv run --extra dev ruff check src/strands/tools/executors/concurrent.py tests/strands/tools/executors/test_concurrent.py

  • git diff --check

  • I ran hatch run prepare

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, or no documentation change is needed
  • 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, or no dependent changes are needed

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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ConcurrentToolExecutor collects tool_results in completion order, breaking prompt-cache stability

1 participant