Skip to content

Python: Fix AG-UI approval resume at the protocol boundary - #7480

Merged
moonbox3 merged 4 commits into
microsoft:mainfrom
moonbox3:fix-7451-ollama-approval-resume
Aug 4, 2026
Merged

Python: Fix AG-UI approval resume at the protocol boundary#7480
moonbox3 merged 4 commits into
microsoft:mainfrom
moonbox3:fix-7451-ollama-approval-resume

Conversation

@moonbox3

@moonbox3 moonbox3 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

AG-UI approval resumes can replay a terminal function result before the approval response synthesized from the resume payload. Connector-specific filtering would scatter AG-UI protocol semantics across providers and can allow stale approval controls to be replayed. The fix belongs at the AG-UI protocol boundary so every connector receives the appropriate transcript.

Description & Review Guide

  • What are the major changes? Validate approval responses against the server-owned pending registry, correlate request and interrupt aliases by call occurrence, reject stale, unknown, or cross-call responses, and remove only completed local approval controls before static execution and provider handoff. Hosted approvals retain trusted server metadata, expose an accepted-only decision schema, and remain provider-bound; deferred approvals remain available to in-run middleware.
  • What is the impact of these changes? AG-UI approval resumes no longer re-execute completed local tools or send local approval controls to a raw chat client. Hosted and deferred tool flows keep their existing paths. There are no Ollama-specific changes; Ollama works through the corrected AG-UI transcript.
  • What do you want reviewers to focus on? Occurrence and alias matching, the local-versus-hosted boundary, and the endpoint regressions that observe the raw provider input.

Related Issue

Fixes #7451

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 the title prefix in sync automatically.

Copilot AI review requested due to automatic review settings August 3, 2026 05:02
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 3, 2026 05:02 — with GitHub Actions Inactive
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 3, 2026 05:02 — with GitHub Actions Inactive
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 3, 2026 05:02 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 3, 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 an incompatibility between AG-UI’s synthesized approval-resume user messages and the Ollama connector by dropping control-only approval-resume messages during Ollama message formatting, and adds a regression test to ensure the rest of the transcript (user → assistant tool call → tool result) still reaches Ollama.

Changes:

  • Skip role="user" messages that contain only function_approval_response content when formatting user messages for Ollama.
  • Add a regression test validating the approval-resume message is omitted from the outgoing Ollama messages payload.

Reviewed changes

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

File Description
python/packages/ollama/agent_framework_ollama/_chat_client.py Drops control-only approval-resume user messages by returning an empty formatted message list.
python/packages/ollama/tests/test_ollama_chat_client.py Adds a regression test asserting the approval-resume message is not forwarded to Ollama.

Comment thread python/packages/ollama/agent_framework_ollama/_chat_client.py Outdated
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _agent_run.py131911291%139, 199, 218, 265, 283, 299–300, 422, 475–476, 483, 592, 596, 598, 615, 642–643, 761, 773, 787, 791, 795, 798, 803, 808, 817, 820, 827–833, 866, 878, 889, 892, 928, 982–986, 1039, 1054, 1057, 1059, 1085, 1111–1113, 1173, 1175, 1177, 1180–1184, 1198, 1206–1211, 1220–1221, 1270–1273, 1284, 1292, 1324, 1339, 1365, 1377, 1407, 1411, 1414, 1416, 1457–1459, 1520, 1583, 1589–1590, 1829, 1837, 1867, 1871, 1916, 2118, 2246, 2306, 2323, 2361, 2467, 2495, 2503, 2505, 2508, 2514, 2569, 2572, 2582–2583, 2590, 2637
   _run_common.py6014193%76, 151–152, 154, 156, 159, 165, 167, 181, 188, 212–213, 226, 245, 281, 325, 337, 339, 341, 344–348, 526, 806–807, 1131–1132, 1137, 1139–1141, 1150, 1158, 1170, 1172–1175, 1238
TOTAL44657410390% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9130 34 💤 0 ❌ 0 🔥 2m 30s ⏱️

@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.

Automated Code Review

Reviewers: 5 | Confidence: 54% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by moonbox3's agents

@moonbox3
moonbox3 marked this pull request as ready for review August 3, 2026 05:14
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 3, 2026 05:14 — with GitHub Actions Inactive

@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.

Automated Code Review

Reviewers: 4 | Confidence: 35% | Result: All clear

Reviewed: Correctness, Security Reliability, Failure Modes, Design Approach


Automated review by moonbox3's agents

@moonbox3
moonbox3 temporarily deployed to github-app-auth August 3, 2026 05:25 — with GitHub Actions Inactive
@moonbox3
moonbox3 enabled auto-merge August 3, 2026 05:33
Comment thread python/packages/ollama/agent_framework_ollama/_chat_client.py Outdated
@moonbox3
moonbox3 force-pushed the fix-7451-ollama-approval-resume branch from af69d2f to b2d4435 Compare August 4, 2026 00:52
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 4, 2026 00:53 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added the documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs label Aug 4, 2026
@moonbox3 moonbox3 changed the title Python: Fix Ollama approval resume message handling Python: Fix AG-UI approval resume at the protocol boundary Aug 4, 2026
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 4, 2026 00:53 — with GitHub Actions Inactive
@moonbox3
moonbox3 temporarily deployed to github-app-auth August 4, 2026 02:07 — with GitHub Actions Inactive
@moonbox3
moonbox3 added this pull request to the merge queue Aug 4, 2026
Merged via the queue into microsoft:main with commit 5f3ca8f Aug 4, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Ollama connector rejects the approval-resume message AG-UI synthesizes

4 participants