Skip to content

Python: Include InvokeAzureAgent input.arguments in agent text - #7907

Closed
Shivani . (Shivani767) wants to merge 1 commit into
microsoft:mainfrom
Shivani767:fix/7902-invoke-azure-agent-arguments
Closed

Shivani . (Shivani767) wants to merge 1 commit into
microsoft:mainfrom
Shivani767:fix/7902-invoke-azure-agent-arguments

Conversation

@Shivani767

@Shivani767 Shivani . (Shivani767) commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

InvokeAzureAgentExecutor._build_input_text() evaluated input.arguments into evaluated_args and then never used that dict. Actions that supply only input.arguments (as in the customer_support sample) therefore invoked the agent with an empty string.

Fixes #7902

Description & Review Guide

  • What are the major changes?

    • Format evaluated input.arguments as key: value lines (same shape as multi-value Workflow.Inputs fallback).
    • Include that text in the agent input, alone or combined with explicit messages / fallback input.
    • Add regression tests for arguments-only, arguments+messages, and expression-valued arguments.
  • What is the impact of these changes?

    • Argument-only InvokeAzureAgent actions now pass structured values to agent.run().
    • Existing messages-only and fallback-input behavior is unchanged when no arguments are present.
  • What do you want reviewers to focus on?

    • Whether folding arguments into text is the right Python parity approach vs. a Foundry structured_inputs channel (.NET uses the latter; Python run() has no equivalent parameter).

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.

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

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 #7902 by preserving evaluated InvokeAzureAgent arguments in agent input text.

Changes:

  • Formats arguments as key: value lines.
  • Combines arguments with explicit or fallback message text.
  • Adds regression coverage for argument-only, combined, and expression-based inputs.

Reviewed changes

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

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 the declarative Usage: [Issues, PRs], Target: declarative agents and workflows label Aug 31, 2026
@moonbox3

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (1 commit(s)): 88e4989182d7
Model: gpt-5.6-sol

Overview

The change correctly recovers previously discarded input.arguments, evaluates expressions before formatting, and preserves the existing messages-only behavior when the argument map is empty. The new tests cover arguments alone on a clean state, arguments with explicit messages, and expression-valued arguments. However, arguments-only actions still execute the implicit-input fallback chain, so chained workflows append a prior agent response or workflow input to the explicit argument block.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.

Affected areas: python/packages/declarative/agent_framework_declarative/_workflows/_executors_agents.py

messages_text = str(getattr(last, "text", "")) # type: ignore
elif evaluated_input:
messages_text = str(cast(Any, evaluated_input))
else:

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.

When an action supplies input.arguments but omits input.messages, this branch still reads the implicit fallback chain and line 741 appends it to the argument block. In a chained workflow, every completed agent sets System.LastMessage, so arguments-only actions such as the customer-support TicketingAgent receive both their structured fields and the prior agent's response; first-agent actions can similarly duplicate values from Workflow.Inputs. Please skip the implicit fallback when explicit arguments are present, while retaining it for actions with neither arguments nor messages.

@moonbox3

Copy link
Copy Markdown
Contributor

Please re-open when PR comments are resolved / responded to.

Shivani . (Shivani767) added a commit to Shivani767/agent-framework that referenced this pull request Sep 9, 2026
…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.
@Shivani767

Copy link
Copy Markdown
Contributor Author

Evan Mattson (@moonbox3) Review feedback addressed — requesting re-open please.

Change in latest commit (1fd2f7e): the implicit fallback chain (Local.input / System.LastMessage / Workflow.Inputs) is now skipped when explicit input.arguments are present (elif not evaluated_args:), while retained for actions with neither arguments nor messages. This prevents arguments-only actions like the customer-support TicketingAgent from getting the prior agent's response or Workflow.Inputs appended to their structured fields in chained workflows.

New regression test: test_agent_executor_build_input_text_arguments_only_skips_implicit_fallback poisons all three fallback sources and asserts the output is exactly "IssueDescription: Printer jammed". Existing tests (arguments-only, arguments+messages, expression-valued arguments, fallback-chain, last-message fallback) all pass: 4 passed, 5 skipped (powerfx).

@Shivani767

Copy link
Copy Markdown
Contributor Author

Please re-open when PR comments are resolved / responded to.

Evan Mattson (@moonbox3) Review feedback addressed — requesting re-open please.

Change in latest commit (1fd2f7e): the implicit fallback chain (Local.input / System.LastMessage / Workflow.Inputs) is now skipped when explicit input.arguments are present (elif not evaluated_args:), while retained for actions with neither arguments nor messages. This prevents arguments-only actions like the customer-support TicketingAgent from getting the prior agent's response or Workflow.Inputs appended to their structured fields in chained workflows.

New regression test: test_agent_executor_build_input_text_arguments_only_skips_implicit_fallback poisons all three fallback sources and asserts the output is exactly "IssueDescription: Printer jammed". Existing tests (arguments-only, arguments+messages, expression-valued arguments, fallback-chain, last-message fallback) all pass: 4 passed, 5 skipped (powerfx).

Shivani . (Shivani767) added a commit to Shivani767/agent-framework that referenced this pull request Sep 19, 2026
…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.
Shivani . (Shivani767) added a commit to Shivani767/agent-framework that referenced this pull request Sep 19, 2026
…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.
@Shivani767

Copy link
Copy Markdown
Contributor Author

Review feedback addressed — branch rebased onto current main; requesting re-open.

Rebase. The branch is now 9cadc071f on top of main (723256961, 2026-09-18) and replays cleanly, no conflicts:

  • 88e4989 — Python: Include InvokeAzureAgent input.arguments in agent text
  • 1fd2f7e — Python: skip implicit fallback when InvokeAzureAgent arguments are present

Feedback addressed (_executors_agents.py:715, automated review): when an action supplies input.arguments but omits input.messages, the implicit fallback chain (Local.input → System.LastMessage.Text → Workflow.Inputs) was still read and appended to the argument block. In a chained workflow every completed agent sets System.LastMessage, so an arguments-only action such as the customer-support TicketingAgent received both its structured fields and the previous agent's response; first-agent actions could likewise duplicate Workflow.Inputs.

The fallback is now gated on elif not evaluated_args: — skipped when explicit input.arguments are present, retained for actions with neither arguments nor messages.

Regression test added: 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 (rebased head): 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.

One practical note: the fork has no write access upstream, so I cannot re-open this PR through the API (422), and gh pr ready only works on an open PR — it is still a draft. Could you re-open it, or would you prefer a fresh non-draft PR? Happy to take whichever is least disruptive.

@Shivani767

Copy link
Copy Markdown
Contributor Author

Closed in favour of a fresh, non-draft PR: #8547 — #8547

Why a new PR rather than a re-open: the fix/7902-invoke-azure-agent-arguments branch had no write access upstream and this PR was a draft, so the re-open call was rejected (422), and there is no pr-limit-exempt path I can use. Rather than leave the work unreviewable, #8547 carries the same change, rebased onto current main (723256961, 2026-09-18) and non-draft.

What #8547 contains relative to this PR:

  • Same branch content — input.arguments folded into the agent text, plus the elif not evaluated_args: gate that skips the implicit fallback when explicit arguments are present (the automated review finding on this PR).
  • Rebased onto current main; no conflicts. main still discards input.arguments at _executors_agents.py:718, so .NET: Python: [Bug]: InvokeAzureAgent silently drops input.arguments, never sends them to the agent #7902 remains reproducible.
  • Verified: uv run pytest packages/declarative/tests/test_graph_coverage.py -q -k arguments → 2 passed, 1 skipped.

Evan Mattson (@moonbox3) — the feedback you asked to have resolved before re-opening is in #8547. Please review there, and close this PR out in favour of it.

pull Bot pushed a commit to sudoevans/agent-framework that referenced this pull request Sep 21, 2026
…soft#7902) (microsoft#8547)

* Python: Include InvokeAzureAgent input.arguments in agent text

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

* Python: skip implicit fallback when InvokeAzureAgent arguments are present

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.

This branch was previously deployed

1 inactive deployment
github-app-auth — 88e49891 Deployed Aug 27, 2026 by Shivani767 via limit_open_prs #992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

declarative Usage: [Issues, PRs], Target: declarative agents and workflows 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

4 participants