Skip to content

fix: return non-leaf mapped outputs from SuperComponent.run_async - #12737

Merged
anakin87 merged 2 commits into
deepset-ai:mainfrom
alanhuangyoo:fix/supercomponent-async-include-outputs
Sep 14, 2026
Merged

anakin87 merged 2 commits into
deepset-ai:mainfrom
alanhuangyoo:fix/supercomponent-async-include-outputs

Conversation

@alanhuangyoo

Copy link
Copy Markdown
Contributor

Related Issues

  • No issue. Found while comparing SuperComponent.run and run_async.

Proposed Changes:

SuperComponent can map outputs from components that are not leaves of the wrapped pipeline, like retriever.documents that also feeds a prompt builder. run makes this work by passing include_outputs_from=self._get_include_outputs_from() to pipeline.run, so outputs consumed inside the pipeline are not pruned. run_async calls pipeline.run_async(data=...) without it, so those outputs get pruned and _map_explicit_outputs skips the missing key without a warning.

With a toy pipeline add -> double and output_mapping={"add.value": "intermediate", "double.value": "final"}:

run       -> {'intermediate': 2, 'final': 4}
run_async -> {'final': 4}

It also shows up through an Agent, because ComponentTool calls run_async when the component has one. A PipelineTool with outputs_to_state reading retriever.documents fills the state under Agent.run and leaves it empty under Agent.run_async.

The fix passes the same include_outputs_from in run_async.

How did you test it?

  • Added test_super_component_non_leaf_output_async, the async twin of test_super_component_non_leaf_output. It fails without the fix.
  • pytest -m "not integration" test/core/super_component test/tools test/core/pipeline test/components/agents: 1136 passed, 1 failed. The failure is test_show_in_notebook, which needs IPython (not installed here) and fails on main too.
  • ruff check, ruff format --check, and mypy on the two changed files pass.
  • The PipelineTool case (BM25 retriever -> PromptBuilder, mock chat generator) was checked with a separate script, not in the added test.

Checklist

This PR was fully generated with an AI assistant (Claude Code), including the fix, the test and this description. The checks above are the ones that were actually run.

🤖 Generated with Claude Code

run passes include_outputs_from for the components named in
output_mapping, so an output that is also consumed inside the wrapped
pipeline is not pruned. run_async did not, so such outputs were silently
missing from the async result, including for a PipelineTool run by
Agent.run_async.

Co-Authored-By: Claude Opus 5 <[email protected]>
@alanhuangyoo
alanhuangyoo requested a review from a team as a code owner September 13, 2026 21:57
@alanhuangyoo
alanhuangyoo requested review from anakin87 and removed request for a team September 13, 2026 21:57
@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

@alanhuangyoo is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the type:documentation Improvements on the docs label Sep 14, 2026
@anakin87
anakin87 enabled auto-merge (squash) September 14, 2026 07:44
@anakin87
anakin87 merged commit c0a3ed7 into deepset-ai:main Sep 14, 2026
22 of 23 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/generators
  utils.py
  haystack/components/preprocessors
  recursive_splitter.py
  text_cleaner.py
  haystack/core/super_component
  super_component.py
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants