Skip to content

Conversation

moonbox3
Copy link
Collaborator

@moonbox3 moonbox3 commented Aug 5, 2025

Motivation and Context

The ResponsesAgent is duplicating messages in chat history preparation when messages contained multiple content items (text + images). The response_inputs.append() call is inside the content processing loop, causing each message to be added once per content item.

The fix:

  • Moved response_inputs.append() outside the content processing loop
  • Added unit test to verify multiple images don't get duplicated

Description

Contribution Checklist

@moonbox3 moonbox3 self-assigned this Aug 5, 2025
@moonbox3 moonbox3 requested a review from a team as a code owner August 5, 2025 06:19
@moonbox3 moonbox3 added python Pull requests for the Python Semantic Kernel agents labels Aug 5, 2025
@moonbox3
Copy link
Collaborator Author

moonbox3 commented Aug 5, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
agents/open_ai
   responses_agent_thread_actions.py36110072%169, 186, 197, 208–209, 376–378, 392, 397, 404, 422–423, 427, 471–473, 476, 494–495, 504–506, 510, 514–515, 519–521, 532–534, 556, 558–559, 566–567, 569–570, 572, 574–575, 577–578, 676, 681, 689–690, 692, 698, 703, 708–709, 716–718, 723–724, 726–731, 733, 737–738, 740, 744, 748, 753–754, 759, 762–763, 834–837, 878–879, 883–885, 887, 912–913, 915–919, 921, 931–932, 940, 944, 951, 957, 1021
TOTAL26786458382% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3680 22 💤 0 ❌ 0 🔥 1m 53s ⏱️

@TaoChenOSU TaoChenOSU added this pull request to the merge queue Aug 5, 2025
Merged via the queue into microsoft:main with commit 91392a7 Aug 5, 2025
32 checks passed
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
…ion (microsoft#12859)

### Motivation and Context

The ResponsesAgent is duplicating messages in chat history preparation
when messages contained multiple content items (text + images). The
`response_inputs.append()` call is inside the content processing loop,
causing each message to be added once per content item.

The fix:
- Moved `response_inputs.append()` outside the content processing loop
- Added unit test to verify multiple images don't get duplicated

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

- Fixed loop placement in `_prepare_chat_history_for_request`
- Added test `test_prepare_chat_history_multiple_images_no_duplication`
- Fixes microsoft#12848

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python: Bug: Responses Agent image count issue
4 participants