Skip to content

fix: Fix parallel tool calling when tools interact with State#11690

Open
sjrl wants to merge 3 commits into
v3from
fix-parallel-tool-calling
Open

fix: Fix parallel tool calling when tools interact with State#11690
sjrl wants to merge 3 commits into
v3from
fix-parallel-tool-calling

Conversation

@sjrl

@sjrl sjrl commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Fixed a bug in Agent (and the underlying tool invocation) where parallel tool calls in a single step did not respect read/write dependencies on State. Tool arguments were prepared once, up front, from the initial state, so a tool reading a State key via inputs_from_state never observed a write made by another tool in the same step via outputs_to_state. For example, two calls to a retrieval tool that both reads and writes the documents key would each see the original documents instead of the second call seeing the first call's results.

Tool calls within a step are now scheduled into batches based on their inputs_from_state and outputs_to_state mappings. Calls that only read, or that touch disjoint keys, still run in parallel; a call that reads a key another call writes is run in a later batch, after that write has been merged into State, with its arguments re-prepared so it sees the updated value. Tools that receive the live State object are treated as reading and writing every key and run on their own. The order the LLM requested the calls in no longer affects correctness.

How did you test it?

New tests and added regression tests exemplifying the previous incorrect behavior.

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@sjrl sjrl requested a review from a team as a code owner June 19, 2026 11:14
@sjrl sjrl requested review from julian-risch and removed request for a team June 19, 2026 11:14
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Jun 19, 2026 11:14am

Request Review

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/agents
  tool_calling.py 31, 598, 604
Project Total  

This report was generated by python-coverage-comment-action

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

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant