Repository navigation
fix(agentchat): pass cancellation_token in MagenticOne structured_output ledger call - #8408
Open
xuan (yuee3) wants to merge 1 commit into
Open
xuan (yuee3) wants to merge 1 commit into
xuan (yuee3) wants to merge 1 commit into
Conversation
…put ledger call The structured_output branch of the progress ledger retry loop was the only model_client.create() call in MagenticOneOrchestrator that did not forward cancellation_token, so cancelling a run could not interrupt an in-flight LLM call for models that support structured output (e.g. OpenAI), delaying cancellation by a full orchestration round. Also fix the ledger parse error message, which reported len(progress_ledger) (the parsed ledger dict) instead of len(output_json) (the extracted JSON objects being validated).
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
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.
Summary
Fixes a missed
cancellation_tokenpropagation in the MagenticOne orchestrator's progress-ledger model call for thestructured_outputbranch, introduced when structured output support was added in #5863.In
_orchestrate_step, the ledger retry loop has three branches. Thestructured_outputbranch was the onlymodel_client.create()call inMagenticOneOrchestratorthat did not forwardcancellation_token:Consequence: when a user cancels a MagenticOne run and the model client supports structured output (e.g. OpenAI), the in-flight progress-ledger LLM call is not interrupted, delaying cancellation by a full orchestration round. All other
create()calls in the orchestrator already forward the token.This PR also fixes an off-by-variable bug in the ledger parse error message in the same loop: it reported
len(progress_ledger)(the parsed ledger dict) instead oflen(output_json)(the extracted JSON objects actually being validated).Changes
_magentic_one_orchestrator.py: passcancellation_token=cancellation_tokenin thestructured_outputledger call; fix the error message to reportlen(output_json).test_magentic_one_group_chat.py: addtest_magentic_one_group_chat_structured_output_cancellation_token— runs a MagenticOne team with aReplayChatCompletionClientconfigured withstructured_output=Trueand asserts every recordedcreate()call received the run'sCancellationToken.Testing
main(ledger call recordedcancellation_token=None) and passes with the fix.pytest tests/test_magentic_one_group_chat.py-> 8 passed.pytest tests/test_group_chat.py-> 91 passed; the 2 failures (test_declarative_groupchats_with_config) are pre-existing and unrelated to this change (missing OpenAI credentials; fail identically on pristinemain).ruff check/ruff format --checkclean on the changed files.