Skip to content

.NET: Python: [Bug]: Declarative workflow IsBlank defaults ignore inputs the caller omitted #9729

Description

Description

In declarative workflows, a PowerFx default for an input the caller did not pass never takes effect. The simple_workflow sample sets

value: =If(IsBlank(inputs.name), "World", inputs.name)

but workflow.run({}) prints Hello, ! instead of Hello, World!.

The cause: when the inputs record has no name field, PowerFx fails to compile inputs.name (and Workflow.Inputs.name) with Name isn't valid. 'name' isn't recognized. DeclarativeWorkflowState.eval() treats that as an undefined variable and returns None for the whole expression, so the IsBlank default is never evaluated. The input only counts as blank when it is present with a blank value:

workflow.run(...) output
{} Hello, !
{"other": 1} Hello, !
{"name": None} Hello, World!
{"name": ""} Hello, World!
{"name": "Alice"} Hello, Alice!

invoke_function_tool/main.py works around this with the comment "both location and unit must be provided". The existing test test_if_with_isblank avoids the case by initializing with {"name": ""}.

Separately, the simple_workflow sample discards the result of its second ("Alice") run, so it prints nothing for that run.

Reproduction

With the .NET runtime available for PowerFx, run python/samples/03-workflows/declarative/simple_workflow/main.py, or:

state = DeclarativeWorkflowState(state_store)
state.initialize({"other": 1})
state.eval('=If(IsBlank(inputs.name), "World", inputs.name)')  # None, expected "World"

Expected behavior

An input the workflow references but the caller omitted behaves as blank, the same as passing it as None, so IsBlank-based defaults apply.

Proposed fix

In DeclarativeWorkflowState.eval(), find inputs.<name> / Workflow.Inputs.<name> references in the formula. Bind any the caller did not supply to blank in the PowerFx symbols for that evaluation only, without writing them to workflow state. Other undefined names keep today's None behavior. I have a PR ready, with a regression test that fails on main.

Package Versions

agent-framework-declarative from main at 1168c00, powerfx with .NET 10.0.12 runtime.

Python Version

3.13

AI Assistance

Claude Code helped find this by running the declarative samples locally, trace it to DeclarativeWorkflowState.eval(), and draft this report. I verified the behavior locally.

Activity

  1. added
    .NETUsage: [Issues, PRs], Target: .Net
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 26, 2026
  2. changed the title [-]Python: [Bug]: Declarative workflow IsBlank defaults ignore inputs the caller omitted[/-] [+].NET: Python: [Bug]: Declarative workflow IsBlank defaults ignore inputs the caller omitted[/+] on Oct 26, 2026
  3. added
    needs-maintainer-triageUsage: [Issues], Target: all issues that the automated triage flow failed to process
    on Oct 26, 2026
  4. eavanvalkenburg commented on Nov 2, 2026

    @eavanvalkenburg
    Member

    Thanks for the reproduction. The team will consider owning omitted-input handling that lets declarative workflows apply useful blank/default expressions. This changes the currently documented legacy undefined-reference fallback, so the exact input-binding and compatibility contract must be agreed first. This is consideration, not an implementation or timing commitment. We will use existing #9730 and the namespace/lexical-scope review as planning input rather than start competing work.

  5. eavanvalkenburg commented on Nov 2, 2026

    @eavanvalkenburg
    Member

    /plan Plan the accepted core ownership of omitted-input blank/default binding, using existing #9730 and the current maintainer scope/alias findings. Reconcile this with eval documented legacy None-on-undefined-reference behavior: decide declared optional inputs versus referenced-but-undeclared inputs, missing/null/empty distinctions and compatibility for unrelated undefined names. Prefer supported engine/schema binding information over maintaining an approximate PowerFx parser. Preserve true global aliases versus With-local bindings/member names, independently resolved inputs and Workflow.Inputs records, quoted identifiers/comments/interpolated code, and no workflow-state mutation. Cover the two existing review regressions through native PowerFx and the public YAML path, plus missing/null/empty/provided values and unchanged namespace behavior. Do not blanket-rebind both aliases from one record. Keep the simple sample second-run output omission separate from the expression-policy change. Scope is the Python declarative wrapper; the .NET runtime dependency alone does not establish a .NET SDK bug. This is not minor-ready: retain both triage labels, stay unassigned and settle semantics before implementation approval.

  6. eavanvalkenburg commented on Nov 11, 2026

    @eavanvalkenburg
    Member

    /plan Plan the accepted core ownership of omitted-input blank/default binding, using existing #9730 and the current maintainer scope/alias findings. Reconcile this with eval documented legacy None-on-undefined-reference behavior: decide declared optional inputs versus referenced-but-undeclared inputs, missing/null/empty distinctions and compatibility for unrelated undefined names. Prefer supported engine/schema binding information over maintaining an approximate PowerFx parser. Preserve true global aliases versus With-local bindings/member names, independently resolved inputs and Workflow.Inputs records, quoted identifiers/comments/interpolated code, and no workflow-state mutation. Cover the two existing review regressions through native PowerFx and the public YAML path, plus missing/null/empty/provided values and unchanged namespace behavior. Do not blanket-rebind both aliases from one record. Keep the simple sample second-run output omission separate from the expression-policy change. Scope is the Python declarative wrapper; the .NET runtime dependency alone does not establish a .NET SDK bug. This is not minor-ready: retain both triage labels, stay unassigned and settle semantics before implementation approval.

  7. github-actions commented on Nov 11, 2026

    @github-actions
    Contributor

    Summary

    When a caller omits an input, =If(IsBlank(inputs.name), "World", inputs.name) returns None instead of "World". PowerFx cannot compile inputs.name when the inputs record has no name field. DeclarativeWorkflowState.eval() then maps the "isn't recognized" error to None for the whole expression (_declarative_base.py L546–640). The docstring documents that fallback as legacy behavior. You asked me to plan core ownership of this and to reconcile it with that fallback.

    I only read the current main code. I ran nothing and did not look at the #9730 implementation. I treat that PR as an open, competing proposal, not as evidence of the right design.

    Recommendation

    A code change is warranted, scoped to the Python declarative wrapper. It is not minor-ready: keep both triage labels, leave it unassigned, and settle the semantics below before implementation approval.

    • Why a change is warranted: the shipped simple_workflow sample relies on this default, and invoke_function_tool carries a workaround comment. Passing None or "" already works, so only omitted keys are broken. That inconsistency is a real defect for users.
    • Python only: eval() and _to_powerfx_symbols() are Python code (L849–895). The .NET runtime is only the engine, so this is not shown to be a .NET SDK bug. The .NET label can stay as triage context, but no .NET work is implied.
    • Workaround today: callers pass {"name": None} explicitly. That is easy to forget and is not discoverable.

    Decisions to settle first

    1. Declared versus undeclared inputs (main design choice).

      • The factory already builds a schema from the YAML inputs: (_factory.py L478), but DeclarativeWorkflowState never sees it.
      • Proposed default: bind declared inputs that are missing as blank. This is exact and needs no formula parsing.
      • Open question: should workflows with no inputs: declaration, such as simple_workflow today, also get blank binding for referenced names? If yes, that needs reference discovery, which is the part you want to avoid maintaining.
      • A middle path: use PowerFx's own compile diagnostics (the unrecognized-name error and its spans), and only for inputs.* and Workflow.Inputs.*. This is less code than a custom parser but still approximate. It needs a maintainer decision on whether the engine exposes enough supported information.
      • Lean: declared inputs first, then a narrowly scoped engine-diagnostic fallback for undeclared references only if maintainers accept it.
    2. Missing, null and empty stay distinct. Missing and null both become blank. "" stays an empty string. IsBlank("") is true in PowerFx, so the existing results are unchanged. Provided values are never overwritten.

    3. Compatibility for unrelated undefined names. Local.typo, Env.X and custom namespaces keep today's None result (the Env omission is intentional, L866–872). Only omitted inputs change. Update the eval() docstring so the legacy fallback is described as "other undefined names".

    4. Aliases and scope.

      • inputs and Workflow.Inputs are two separate symbols that currently point at the same data.
      • Resolve each reference on its own. Do not rebind both aliases from one record.
      • A reference inside With, As or ForAll, or a record member that happens to be named inputs, must not be treated as the global input.
      • Quoted identifiers, comments and interpolated code must not create false matches.
      • Custom inputs namespaces must stay independent.
    5. No state mutation. Blank bindings exist only in the per-evaluation symbols. Nothing is written to workflow state or checkpoints.

    Proposed plan (not implemented; pending approval)

    1. Agree the semantics above on this issue, especially item 1.

    2. Pass the declared input names from the factory into the state, so _to_powerfx_symbols() can add blank entries for the missing ones in an evaluation-only copy of the inputs and Workflow.Inputs records. This is the agreed core ownership.

    3. Only if approved, add the narrow engine-diagnostic retry for undeclared inputs.* references. If the retry fails to compile, return None as today.

    4. Update the eval() docstring and any declarative docs that mention undefined-name behavior.

    5. Tests:

      • Use native PowerFx (state.eval) and the public YAML path (WorkflowFactory with run({})).
      • Cover the two review regressions: local-scope shadowing and alias independence.
      • Cover the matrix: missing, None, "" and provided values, for both aliases.
      • Check unchanged behavior for Local.*, custom namespaces, quoted identifiers and comments.
      • Assert that state and checkpoints are unchanged after evaluation.
    6. Separate follow-up: the simple_workflow sample discarding its second-run ("Alice") output. It is a one-line sample fix and independent of the expression policy, so it should not be bundled into the same decision.

    Done when: run({}) and run({"other": 1}) give Hello, World!, the other matrix rows are unchanged, and no existing declarative test changes.

    No changes have been made. Next step: maintainers confirm item 1 (declared-only versus declared plus engine-diagnostic fallback).

    Generated by Issue Planning for #9729 · copilot · auto · ~24 AIC · ⌖ ~1 AIC · ⊞ 4.8K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETUsage: [Issues, PRs], Target: .Netneeds-maintainer-triageUsage: [Issues], Target: all issues that the automated triage flow failed to processpythonUsage: [Issues, PRs], Target: PythontriageUsage: [Issues], Target: All issues that still need to be triaged

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions