Skip to content

Python: fix declarative workflow DevUI sample and JoinExecutor Messag…#7206

Open
amit12cool wants to merge 5 commits into
microsoft:mainfrom
amit12cool:fix/python-declarative-workflow-devui-input
Open

Python: fix declarative workflow DevUI sample and JoinExecutor Messag…#7206
amit12cool wants to merge 5 commits into
microsoft:mainfrom
amit12cool:fix/python-declarative-workflow-devui-input

Conversation

@amit12cool

Copy link
Copy Markdown
Contributor

Motivation & Context

The workflow_declarative DevUI sample under python/samples/02-agents/devui/workflow_declarative/ was broken when run via the DevUI chat interface. Entering any age value always returned the "child" category. Four bugs caused this:

  1. workflow.yaml used =inputs.age — this only works when the workflow is invoked with a structured dict input (e.g. {"age": 25}). The DevUI sends user messages as chat text, which populates System.LastMessage.Text, not Inputs.age. As a result =inputs.age was always Blank (treated as 0 by PowerFx), causing 0 < 13 to always evaluate True → "child" for any input.

  2. workflow.yaml used turn.* namespaceturn is a .NET/Bot Framework convention. In the Python runtime, per-turn variables belong in the Local.* namespace.

  3. workflow.yaml used workflow.outputs.category (lowercase w) — the Python state engine is case-sensitive; the correct namespace is Workflow.Outputs.*.

  4. JoinExecutor did not handle a single Message trigger — when a Message (not list[Message]) was passed as the trigger, _ensure_state_initialized could not extract the user text into System.LastMessage.Text, compounding issue 1.

Description & Review Guide

  • What are the major changes?

    • workflow.yaml: replace =inputs.age with =Int(System.LastMessage.Text); replace turn.* with Local.*; fix workflow.outputs.categoryWorkflow.Outputs.category; remove the now-unused inputs: schema block
    • workflow.py: add logging.basicConfig so DevUI startup output is readable
    • _executors_control_flow.py (JoinExecutor): normalize a single Message trigger to list[Message] before passing to _ensure_state_initialized, so user text is correctly surfaced in System.LastMessage.Text
  • What is the impact of these changes?
    The DevUI sample now works correctly end-to-end. JoinExecutor also correctly handles single-message triggers in all workflows that use it.

  • What do you want reviewers to focus on?
    The JoinExecutor change in _executors_control_flow.py and whether any other executors have the same single-Message gap.

Related Issue

Fixes #

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 is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change.

Copilot AI review requested due to automatic review settings July 20, 2026 09:36
@giles17 giles17 added the python Usage: [Issues, PRs], Target: Python label Jul 20, 2026

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.

Pull request overview

Fixes the Python declarative-workflow DevUI sample so it correctly categorizes users based on age entered via the chat UI (using System.LastMessage.Text / Local.* / Workflow.Outputs.*), and updates the declarative workflow runtime so JoinExecutor properly initializes state when triggered with a single Message.

Changes:

  • Updated the DevUI sample workflow.yaml to read age from chat text, use Local.* variables, and correctly write outputs to Workflow.Outputs.*.
  • Improved DevUI sample startup logging readability by configuring logging.basicConfig(...).
  • Updated JoinExecutor to normalize a single Message trigger to list[Message] before state initialization.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
python/samples/02-agents/devui/workflow_declarative/workflow.yaml Fixes expression namespaces and input source so DevUI chat input drives correct branching and output state.
python/samples/02-agents/devui/workflow_declarative/workflow.py Adds simple logging configuration to make DevUI startup output easier to read.
python/packages/declarative/agent_framework_declarative/_workflows/_executors_control_flow.py Ensures JoinExecutor correctly initializes state for single-Message triggers (DevUI-style).

Comment thread python/samples/02-agents/devui/workflow_declarative/workflow.yaml
@moonbox3

Copy link
Copy Markdown
Contributor

Per the PR guidelines, please link an issue to this PR.

PRs that are not linked to an issue may be closed, no matter how valid the change is.

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.

4 participants