Skip to content

Python: Fix workflow not pausing when agent calls declaration-only tool#3757

Open
moonbox3 wants to merge 2 commits intomicrosoft:mainfrom
moonbox3:3425-fix-latest
Open

Python: Fix workflow not pausing when agent calls declaration-only tool#3757
moonbox3 wants to merge 2 commits intomicrosoft:mainfrom
moonbox3:3425-fix-latest

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Feb 9, 2026

Motivation and Context

  • Fixes Python: [Bug]: Workflow doesn't pause when agent calls declaration_only tool, causing OpenAI 400 error #3425: when an agent calls a declaration_only tool (for example, a client-side AG-UI tool with func=None), the workflow now pauses and emits a request_info event instead of continuing and hitting an OpenAI 400 error
  • Three changes:
    • _try_execute_function_calls: mark declaration-only FunctionCallContent items with user_input_request=True so AgentExecutor detects them
    • _handle_function_call_results: don't re-add function_call items already present in the response message
    • handle_user_input_response: use role="tool" when feeding function results back to the agent so the LLM sees proper tool responses

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@moonbox3 moonbox3 self-assigned this Feb 9, 2026
Copilot AI review requested due to automatic review settings February 9, 2026 06:40
@moonbox3 moonbox3 added the python label Feb 9, 2026
@moonbox3 moonbox3 added the workflows Related to Workflows in agent-framework label Feb 9, 2026
@github-actions github-actions bot changed the title Fix workflow not pausing when agent calls declaration-only tool Python: Fix workflow not pausing when agent calls declaration-only tool Feb 9, 2026
@moonbox3 moonbox3 moved this to In Review in Agent Framework Feb 9, 2026
@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Feb 9, 2026
@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _tools.py7978589%232, 278, 329, 331, 359, 529, 564–565, 667, 669, 689, 707, 721, 733, 738, 740, 747, 780, 851–853, 894, 916–944, 979, 987, 1228, 1433, 1490, 1494, 1573–1577, 1595, 1597–1598, 1710, 1714, 1764, 1766, 1782, 1784, 1848, 1875, 1932, 2000, 2179–2180, 2207, 2215, 2228, 2238–2239, 2274, 2330, 2362
packages/core/agent_framework/_workflows
   _agent_executor.py1672286%98, 146, 164–165, 219–220, 222–223, 255–257, 265–267, 277–279, 281, 285, 289, 293–294
TOTAL16555205787% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3923 225 💤 0 ❌ 0 🔥 1m 10s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a workflow pause/resume gap for declaration-only tools (tools defined with func=None, commonly representing client-side tools). It ensures the workflow pauses and emits request_info when such a tool is called, and that resuming the workflow feeds back a proper tool response message to avoid OpenAI “orphaned tool_calls” 400 errors.

Changes:

  • Mark declaration-only function_call contents as user_input_request (and assign id) so AgentExecutor pauses and emits request_info.
  • Avoid duplicating function_call items into the assistant message when handling function-call results.
  • When resuming from user responses, send back function results with role="tool" so OpenAI receives valid tool responses.
  • Adds unit tests and a new sample demonstrating the behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/packages/core/agent_framework/_tools.py Marks declaration-only tool calls as user input requests; avoids re-adding function_call contents into the assistant message.
python/packages/core/agent_framework/_workflows/_agent_executor.py Uses role="tool" when resuming with function परिणाम (function_result) contents.
python/packages/core/tests/workflow/test_agent_executor_tool_calls.py Adds non-streaming, streaming, and parallel tests for declaration-only tool pause/resume behavior.
python/samples/getting_started/workflows/human-in-the-loop/agents_with_declaration_only_tools.py New sample demonstrating declaration-only tool calls pausing the workflow and resuming via responses={...}.
python/samples/getting_started/workflows/README.md Links the new sample in the workflows README table.

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

Labels

documentation Improvements or additions to documentation python workflows Related to Workflows in agent-framework

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Workflow doesn't pause when agent calls declaration_only tool, causing OpenAI 400 error

3 participants