Skip to content

Python: Fix Ollama approval resume message handling - #7480

Open
moonbox3 wants to merge 2 commits into
microsoft:mainfrom
moonbox3:fix-7451-ollama-approval-resume
Open

Python: Fix Ollama approval resume message handling#7480
moonbox3 wants to merge 2 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 synthesizes a control-only user message when a user resumes an approved tool call. The Ollama connector rejected that message because it has no text or data content, preventing approval-gated tools from completing on AG-UI surfaces backed by Ollama.

Description & Review Guide

  • What are the major changes? Ignore a user message composed solely of function approval responses when preparing Ollama model input, and add a regression test through the public OllamaChatClient.get_response() API.
  • What is the impact of these changes? AG-UI approval resumes can continue through the Ollama connector; ordinary empty or unsupported user messages retain their existing validation behavior.
  • What do you want reviewers to focus on? The narrow control-only condition and the regression transcript, which verifies that the normal user, assistant tool call, and tool result still reach Ollama.

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

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ollama/agent_framework_ollama
   _chat_client.py233996%404, 406, 417, 421–422, 437, 448, 530, 556
TOTAL44049411890% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9068 34 💤 0 ❌ 0 🔥 2m 27s ⏱️

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

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

2 participants