Skip to content

Python: Return empty list from Executor output_types when discovery is deferred - #9942

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
hardikkaurani:fix/python-executor-deferred-discovery-output-types
Nov 4, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
hardikkaurani:fix/python-executor-deferred-discovery-output-types

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Motivation & Context

In agent-framework (Python workflows), Executor.__init__ supports defer_discovery=True to defer handler inspection until later. While self._handler_specs is initialized during __init__, self._response_handler_specs was only set during handler discovery in RequestInfoMixin._discover_response_handlers.

As a result, prior to discovery, accessing executor.input_types safely returned an empty list [], but accessing executor.output_types or executor.workflow_output_types raised:

AttributeError: 'Deferred' object has no attribute '_response_handler_specs'

Description & Review Guide

  • What are the major changes?

    1. Initialized self._response_handler_specs: list[dict[str, Any]] = [] in Executor.__init__ alongside self._handler_specs.
    2. Defensively used getattr(self, "_response_handler_specs", []) in Executor.output_types and Executor.workflow_output_types.
    3. Added unit tests in packages/core/tests/workflow/test_request_info_mixin.py verifying that output_types and workflow_output_types return [] before discovery when defer_discovery=True, and populate correctly once discovery runs.
  • What is the impact of these changes?

    • Fixes unhandled AttributeError when inspecting deferred executors.
    • Consistent behavior across input_types, output_types, and workflow_output_types.
    • Zero breaking changes.

Related Issue

Fixes #9939

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change.

cc Eduard van Valkenburg (@eavanvalkenburg)

…d discovery on Executor

Initialize self._response_handler_specs in Executor.__init__ and safely fall back when reading response handler specs so that output_types and workflow_output_types return empty lists instead of raising AttributeError when handler discovery is deferred.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…eferred discovery

Add unit test coverage verifying that Executor.output_types and Executor.workflow_output_types safely return empty lists prior to handler discovery when defer_discovery=True, and properly populate once handlers are discovered.

Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 1, 2026
@eavanvalkenburg

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (2 commit(s)): b7b4656f7e5f, 120190020611
Model: gpt-5.6-sol

Overview

The PR initializes response-handler metadata during Executor construction and adds defensive fallbacks to type-introspection properties, so deferred executors report empty output types until discovery. Existing discovery appends into the preinitialized list, production deferred constructors complete both discovery phases, and the added tests cover empty-before and populated-after behavior. No Critical, High, or Medium defect was established.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Merged via the queue into microsoft:main with commit e2dc460 Nov 4, 2026
54 of 55 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 12019002 Deployed Nov 1, 2026 by hardikkaurani via team_check #8262
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Executor.output_types raises AttributeError when handler discovery is deferred

3 participants