Skip to content

Python: Include InvokeAzureAgent input.arguments in agent text (#7902) - #8547

Merged
Evan Mattson (moonbox3) merged 2 commits into
microsoft:mainfrom
Shivani767:fix/7902-invoke-azure-agent-arguments-v2
Sep 21, 2026
Merged

Evan Mattson (moonbox3) merged 2 commits into
microsoft:mainfrom
Shivani767:fix/7902-invoke-azure-agent-arguments-v2

Conversation

@Shivani767

Copy link
Copy Markdown
Contributor

Motivation & Context

InvokeAzureAgent accepts an input.arguments map, but the Python declarative executor never sent it to the agent. _build_input_text evaluated the arguments and then discarded them, so an arguments-only action invoked the agent with an empty string — input.arguments was silently dropped (#7902).

This is the successor to #7907, which was closed by Evan Mattson (@moonbox3) with "Please re-open when PR comments are resolved / responded to." Both pieces of feedback (the automated review finding and the addressed fallback behaviour below) are now in, so this PR carries the same change as a fresh, non-draft PR. This supersedes #7907 — please close #7907 in favour of this one.

Description & Review Guide

  • What are the major changes?

    • _build_input_text now folds evaluated input.arguments into the text passed to agent.run(), formatted as key: value lines (the same shape the multi-value Workflow.Inputs fallback already used). Python's agent run() has no separate structured-input channel, so arguments must be folded into this text rather than discarded.
    • The implicit fallback chain (Local.input / Local.userInput → System.LastMessage.Text → Workflow.Inputs) is now gated on elif not evaluated_args: — it is skipped when explicit input.arguments are present, and retained for actions with neither arguments nor messages.
  • What is the impact of these changes?

    • Argument-only actions no longer invoke the agent with an empty string (.NET: Python: [Bug]: InvokeAzureAgent silently drops input.arguments, never sends them to the agent #7902).
    • In chained workflows, an arguments-only action such as the customer-support TicketingAgent no longer receives the previous agent's response appended to its structured fields. Every completed agent sets System.LastMessage, so before this change both the structured fields and the prior agent's text reached the agent; first-agent actions could similarly duplicate Workflow.Inputs.
    • Actions with neither arguments nor messages keep the previous fallback behaviour.
  • What do you want reviewers to focus on?

    • The key: value folding format as the substitute for a structured-input channel — it is a text convention, not a typed one.
    • Whether skipping the implicit fallback whenever input.arguments is non-empty is the right default (it is what the automated review asked for).

Related Issue

Fixes #7902

Supersedes #7907 (closed — "re-open when PR comments are resolved"). No other open PR addresses #7902.

Review follow-up from #7907

Addressed in 4915e69c5: when an action supplies input.arguments but omits input.messages, the fallback chain was still read and appended to the argument block. Now skipped via elif not evaluated_args:.

New regression test: test_agent_executor_build_input_text_arguments_only_skips_implicit_fallback poisons all three fallback sources and asserts none of them reach the argument block.

Validation

Branch rebased onto current main (723256961, 2026-09-18); no conflicts.

uv run pytest packages/declarative/tests/test_graph_coverage.py -q -k arguments
2 passed, 1 skipped

main still discards input.arguments at _executors_agents.py:718, so #7902 remains reproducible on current main.

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. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

/cc Evan Mattson (@moonbox3) — the #7907 feedback is addressed; re-opening was not available from this account (no write access upstream, and the PR is a draft), so this fresh PR carries the same change.

Fold evaluated input.arguments into the text passed to agent.run() so
argument-only InvokeAzureAgent actions no longer silently invoke with
an empty string.
…esent

Addresses review on microsoft#7907: arguments-only actions no longer append
System.LastMessage / Workflow.Inputs fallback text to their structured
fields in chained workflows. Adds a regression test with poisoned
fallback state.

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.

Copilot review overview

🟢 Approval recommended

The focused implementation addresses the reported data loss while preserving and testing existing fallback behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes Python declarative InvokeAzureAgent actions silently dropping input.arguments.

Changes:

  • Formats evaluated arguments as key: value input text.
  • Prevents implicit fallback text from contaminating arguments-only invocations.
  • Adds regression coverage for arguments, messages, expressions, and fallback behavior.
File Description
python/​packages/​declarative/​agent_framework_declarative/​_workflows/​_executors_agents.py Includes evaluated arguments in agent input text.
python/​packages/​declarative/​tests/​test_graph_coverage.py Adds regression tests for argument handling.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@moonbox3
Evan Mattson (moonbox3) added this pull request to the merge queue Sep 21, 2026
Merged via the queue into microsoft:main with commit 53e9813 Sep 21, 2026
48 of 49 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 4915e69c Deployed Sep 19, 2026 by Shivani767 via limit_open_prs #1422
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.

.NET: Python: [Bug]: InvokeAzureAgent silently drops input.arguments, never sends them to the agent

3 participants