Skip to content

Python: Emit partial result for magentic pattern when retrieving final result, if available #12656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025

Conversation

moonbox3
Copy link
Collaborator

@moonbox3 moonbox3 commented Jul 2, 2025

Motivation and Context

When using the magentic orchestration pattern, if the max_round_count is hit, the final result shows as:

Final result:
Max round count reached.

The interim messages do show as part of the agent_response_callback; however, not everyone may have that configured. We should return more meaningful results, even if partial. This PR updates to try and get a partial result if it exists. When one calls:

value = await orchestration_result.get()

for the step5_magentic.py sample, with max_round_count=1 they should receive the partial result:

Final result:
Based on the available data, here is a comparison of the estimated training and inference energy consumption for ResNet-50, BERT-base, and GPT-2, along with the associated CO₂ emissions when training on an Azure Standard_NC6s_v3 VM for 24 hours.

**Model Architectures and Datasets:**

- **ResNet-50**: Image classification model trained on ImageNet.
- **BERT-base**: Text classification model fine-tuned on the GLUE benchmark.
- **GPT-2**: Text generation model trained on WebText.

... <rest omitted for brevity> ...

Description

Return partial results for magentic orchestration if they exist.

Contribution Checklist

@moonbox3 moonbox3 self-assigned this Jul 2, 2025
@moonbox3 moonbox3 requested a review from a team as a code owner July 2, 2025 02:17
@moonbox3 moonbox3 added python Pull requests for the Python Semantic Kernel agents labels Jul 2, 2025
@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
agents/orchestration
   magentic.py29210265%122–124, 256, 379, 447, 450, 457, 461, 463, 490–495, 497, 502, 504, 510, 512, 517–518, 520–521, 527, 529–530, 533–534, 540, 548–549, 558, 561–562, 564–567, 570–571, 575–578, 580–581, 583, 585–591, 594–595, 602, 611–613, 615, 617, 625–626, 628, 633, 637–638, 640, 642–643, 647–648, 650, 653, 657–659, 662, 666–667, 673–674, 676, 678, 692–693, 697–698, 700, 702, 704, 706, 715–719, 786–787
TOTAL26428451482% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3639 22 💤 0 ❌ 0 🔥 1m 51s ⏱️

@TaoChenOSU TaoChenOSU added this pull request to the merge queue Jul 2, 2025
Merged via the queue into microsoft:main with commit c15c885 Jul 2, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this to Sprint: Done in Semantic Kernel Jul 2, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 4, 2025
… when limits reached (#12839)

### Motivation and Context

<!-- 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.
-->
Related to #12687
Related to #12656 

Currently, the Magentic orchestration returns a static message if the
max reset limit or the max invocation limit is reached.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Return the last agent response if either of the limit is reached.

### 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 😄

---------

Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
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
Archived in project
Development

Successfully merging this pull request may close these issues.

Python: Bug: max_round_count ends loop without returning results—unlike AutoGen behavior
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy