mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Add context_providers and description to workflow.as_agent() (#4651)
* Add context_providers and description to `workflow.as_agent()` * Add default workflow name and description * Positional * Move import --------- Co-authored-by: Tao Chen <taochen@microsoft.com> Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
fe4cd3cddc
commit
69697065ab
@@ -313,6 +313,37 @@ class TestWorkflowAgent:
|
||||
assert isinstance(agent_no_name, WorkflowAgent)
|
||||
assert agent_no_name.workflow is workflow
|
||||
|
||||
def test_workflow_as_agent_with_description_and_context_providers(self) -> None:
|
||||
"""Test that Workflow.as_agent() forwards description and context_providers."""
|
||||
executor = SimpleExecutor(id="executor1", response_text="Response")
|
||||
workflow = WorkflowBuilder(start_executor=executor).build()
|
||||
|
||||
history_provider = InMemoryHistoryProvider()
|
||||
agent = workflow.as_agent(
|
||||
name="MyAgent",
|
||||
description="A test agent",
|
||||
context_providers=[history_provider],
|
||||
)
|
||||
|
||||
assert isinstance(agent, WorkflowAgent)
|
||||
assert agent.name == "MyAgent"
|
||||
assert agent.description == "A test agent"
|
||||
assert history_provider in agent.context_providers
|
||||
|
||||
def test_workflow_as_agent_defaults_name_and_description_from_workflow(self) -> None:
|
||||
"""Test that as_agent() defaults name and description to the workflow's own values."""
|
||||
executor = SimpleExecutor(id="executor1", response_text="Response")
|
||||
workflow = WorkflowBuilder(
|
||||
start_executor=executor,
|
||||
name="my-workflow",
|
||||
description="Workflow description",
|
||||
).build()
|
||||
|
||||
agent = workflow.as_agent()
|
||||
|
||||
assert agent.name == "my-workflow"
|
||||
assert agent.description == "Workflow description"
|
||||
|
||||
def test_workflow_as_agent_cannot_handle_agent_inputs(self) -> None:
|
||||
"""Test that Workflow.as_agent() raises an error if the start executor cannot handle agent inputs."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user