Python: Fix spurious Magentic custom manager warning#6261
Open
moonbox3 wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a misleading warning in the Python orchestration MagenticBuilder where supplying a custom manager/manager_factory always triggered “Custom manager provided; all other manager arguments will be ignored.” due to max_stall_count having a non-sentinel default. It makes omitted max_stall_count distinguishable from an explicit override, and adds regression tests around the warning behavior and default resolution.
Changes:
- Update
MagenticBuilder/_set_managerto use the existing_MISSINGsentinel formax_stall_count, resolving it to3only when constructingStandardMagenticManager. - Adjust the warning condition so it only fires when standard-manager options were actually provided alongside a custom manager.
- Add tests to verify (1) no warning for custom manager/manager_factory without standard options, (2) warning still occurs when a standard option is explicitly set, and (3)
manager_agent_factorystill uses the defaultmax_stall_count=3.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/uv.lock | Updates locked dependencies (notably azure-ai-agentserver-responses to 1.0.0b7 and related transitive additions) consistent with current workspace requirements. |
| python/packages/orchestrations/tests/test_magentic.py | Adds regression tests covering the warning behavior and default max_stall_count resolution for agent factory builds. |
| python/packages/orchestrations/agent_framework_orchestrations/_magentic.py | Introduces _MISSING sentinel handling for max_stall_count and refines warning logic; resolves default only when instantiating StandardMagenticManager. |
Replace the bare object() sentinel with typing_extensions.Sentinel per
PEP 661 (now final). Sentinel provides a proper name and repr
('<_MISSING>') and is the idiomatic approach going forward.
Refs microsoft#4306
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…osoft#6261) Use int | Sentinel for max_stall_count parameter type annotation instead of int with cast(Any, _MISSING) to properly express that the parameter can hold either an int or the _MISSING sentinel value. This fixes the pyright reportUnnecessaryComparison errors caused by the types int and Sentinel having no overlap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
moonbox3
commented
Jun 2, 2026
The sentinel is user-visible as a default in public init signatures, so use UNSET (no leading underscore) instead of the private _MISSING name. Drop the now-unnecessary reportPrivateUsage ignores on the UNSET imports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| enable_plan_review: bool = False, | ||
| checkpoint_storage: CheckpointStorage | None = None, | ||
| output_from: Sequence[_ParticipantOutputSpecifier] | Literal["all"] | None = cast(Any, _MISSING), | ||
| output_from: Sequence[_ParticipantOutputSpecifier] | Literal["all"] | None = cast(Any, UNSET), |
eavanvalkenburg
approved these changes
Jun 2, 2026
giles17
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fixes #4306.
MagenticBuilderloggedCustom manager provided; all other manager arguments will be ignored.whenever a custommanagerormanager_factorywas supplied, even when the caller did not pass any standard-manager options. This happened becausemax_stall_countdefaulted to3, so the warning check could not distinguish an omitted value from an explicit override.Description
Updates
MagenticBuilderto use the existing_MISSINGsentinel formax_stall_countso omitted values remain distinguishable from explicitly supplied values. The builder resolves omittedmax_stall_countto3only when constructing aStandardMagenticManager.Adds regression coverage for custom manager and manager factory configurations that should not warn, preserves the warning when a standard-manager option is explicitly supplied with a custom manager, and verifies
manager_agent_factorystill receives the defaultmax_stall_count.Contribution Checklist