Skip to content

Python: Add context_providers and description to workflow.as_agent()#4651

Open
cecheta wants to merge 4 commits intomicrosoft:mainfrom
cecheta:workflow
Open

Python: Add context_providers and description to workflow.as_agent()#4651
cecheta wants to merge 4 commits intomicrosoft:mainfrom
cecheta:workflow

Conversation

@cecheta
Copy link
Member

@cecheta cecheta commented Mar 12, 2026

Motivation and Context

Closes #4650 #4652

Description

Allow passing more options to workflow.as_agent(), including context providers and description.
Agent name and description now default to the workflow's.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings March 12, 2026 16:32
@github-actions github-actions bot changed the title Add context_providers and description to workflow.as_agent() Python: Add context_providers and description to workflow.as_agent() Mar 12, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Mar 12, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _workflow.py2671992%91, 272–274, 276–277, 295, 299, 433, 621, 642, 698, 710, 716, 721, 741–743, 756
TOTAL24000264288% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5233 20 💤 0 ❌ 0 🔥 1m 25s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Expands the Python Workflow.as_agent() convenience API to support more WorkflowAgent/BaseAgent configuration so callers don’t need to instantiate WorkflowAgent directly (addresses #4650).

Changes:

  • Extend Workflow.as_agent() to accept description, context_providers, and passthrough **kwargs to WorkflowAgent/BaseAgent.
  • Add a unit test ensuring description and context_providers are forwarded correctly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/packages/core/agent_framework/_workflows/_workflow.py Extends Workflow.as_agent() signature and forwards new options into WorkflowAgent.
python/packages/core/tests/workflow/test_workflow_agent.py Adds coverage for forwarding description and context_providers through Workflow.as_agent().

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 13 to 18
from typing import Any, Literal, overload

from .._sessions import BaseContextProvider
from .._types import ResponseStream
from ..observability import OtelAttr, capture_exception, create_workflow_span
from ._agent import WorkflowAgent
Copy link
Contributor

Choose a reason for hiding this comment

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

@cecheta LGTM. Could you please address this little comment from Copilot. simply add the following to right above logger = logging.getLogger(__name__):

if TYPE_CHECKING:
    from ._agent import WorkflowAgent

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@markwallace-microsoft
Copy link
Member

@cecheta, friendly reminder — this issue is waiting on your response. Please share any updates when you get a chance. (This is an automated message.)

@cecheta
Copy link
Member Author

cecheta commented Mar 20, 2026

Pull request is awaiting review

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Feature]: Provide context_provider and description when calling Workflow.as_agent()

4 participants