Python: Add CreateConversationExecutor, fix input routing, remove unused handler layer - #4159
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the Python declarative (graph-based) workflow execution path by adding missing executors (notably CreateConversation), improving input/state routing for PowerFx expressions, and removing an unused legacy “action handler” execution layer.
Changes:
- Add
CreateConversationExecutor, improve dynamic agent name expression evaluation, and adjust branch-exit/terminator handling to prevent incorrect edge wiring. - Thread runner iteration limits via
WorkflowFactory/DeclarativeWorkflowBuilder, supporting a YAMLmaxTurnsfield; update DeepResearch sample accordingly. - Remove the unused legacy handler layer and associated tests; update samples/tests to use the executor-based system.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| workflow-samples/DeepResearch.yaml | Adds maxTurns: 500 and sets autoSend: false to improve looping convergence and suppress raw JSON output. |
| python/samples/03-workflows/declarative/human_in_loop/main.py | Updates streaming output handling to align with executor-based output payloads. |
| python/samples/03-workflows/declarative/deep_research/main.py | Adjusts streaming print formatting (adds newlines between output events). |
| python/samples/02-agents/context_providers/redis/redis_conversation.py | Removes an unused import. |
| python/samples/01-get-started/06_host_your_agent.py | Adds whitespace (formatting-only). |
| python/packages/declarative/tests/test_workflow_samples_integration.py | Switches coverage check from handlers to ALL_ACTION_EXECUTORS. |
| python/packages/declarative/tests/test_workflow_handlers.py | Removes tests for the deleted handler layer. |
| python/packages/declarative/tests/test_workflow_factory.py | Removes tests tied to the deleted handler-layer ActionContext. |
| python/packages/declarative/tests/test_graph_coverage.py | Adds tests for expression-based agent name resolution, terminator branch exit handling, and CreateConversationExecutor. |
| python/packages/declarative/tests/test_external_input.py | Removes tests for the deleted handler-based HITL implementation. |
| python/packages/declarative/tests/test_additional_handlers.py | Removes tests for the deleted handler layer (conversation/variables/etc.). |
| python/packages/declarative/agent_framework_declarative/_workflows/_human_input.py | Removes the handler-based HITL implementation module. |
| python/packages/declarative/agent_framework_declarative/_workflows/_handlers.py | Removes the handler registry/types module. |
| python/packages/declarative/agent_framework_declarative/_workflows/_factory.py | Adds max_iterations plumbing into graph builder creation. |
| python/packages/declarative/agent_framework_declarative/_workflows/_executors_control_flow.py | Ensures JoinExecutor initializes state before passing through. |
| python/packages/declarative/agent_framework_declarative/_workflows/_executors_basic.py | Adds CreateConversationExecutor and registers it in BASIC_ACTION_EXECUTORS. |
| python/packages/declarative/agent_framework_declarative/_workflows/_executors_agents.py | Supports = PowerFx expressions for agent name fields across schema variants. |
| python/packages/declarative/agent_framework_declarative/_workflows/_declarative_builder.py | Adds more terminators, threads max_iterations into WorkflowBuilder, and improves _get_branch_exit terminator handling. |
| python/packages/declarative/agent_framework_declarative/_workflows/_declarative_base.py | Populates System.LastMessage.Text from string (and non-dict) workflow inputs. |
| python/packages/declarative/agent_framework_declarative/_workflows/_actions_error.py | Removes handler-based error actions module. |
| python/packages/declarative/agent_framework_declarative/_workflows/_actions_control_flow.py | Removes handler-based control-flow actions module. |
| python/packages/declarative/agent_framework_declarative/_workflows/_actions_basic.py | Removes handler-based basic actions module. |
| python/packages/declarative/agent_framework_declarative/_workflows/_actions_agents.py | Removes handler-based agent invocation actions module. |
| python/packages/declarative/agent_framework_declarative/_workflows/init.py | Updates exports to reflect the executor-only workflow implementation. |
|
Hi Evan Mattson (@moonbox3), could you also check System.ConversationId? |
Fixed in 19c71d2. |
Motivation and Context
conversationId: =System.ConversationIdrouted messages toSystem.conversations.default.messagesinstead of a properly scoped conversation. Nowinitialize()generates a UUID and seeds a matchingSystem.conversationsentry, matching the .NET behavior.Supersedes #4065
This branch builds on sample-fixes-8 (#4065) and keeps all of its executor fixes. It supersedes #4065 because that PR worked around missing executors by using a simplified local workflow.yaml; this PR fixes the root causes instead.
Description
Contribution Checklist