Python: keep agent loop marker from provider SDKs - #7860
Python: keep agent loop marker from provider SDKs#7860Eduard van Valkenburg (eavanvalkenburg) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 42a18a81-57d5-4912-8dbd-f1a48db57a45
There was a problem hiding this comment.
Pull request overview
Prevents the agent-loop marker from reaching provider SDKs while preserving loop-scoped provider behavior.
Changes:
- Removes
_agent_loop_iterationfrom outbound chat options. - Adds streaming and non-streaming regression coverage with strict option validation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/packages/core/agent_framework/_agents.py |
Filters the private loop marker at the client boundary. |
python/packages/core/tests/core/test_harness_loop.py |
Verifies marker filtering and provider-option forwarding. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 11be6b80f408
Model: gpt-5.6-sol
Overview
The change removes the framework-private loop marker only from the copied options sent to chat clients, while preserving it in SessionContext.options for turn-scoped provider lifecycle handling. The shared preparation path covers streaming and non-streaming calls, and the regression test verifies both strict transport compatibility and preservation of ordinary provider options. No publishable Critical, High, or Medium issue was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
Agent loop middleware stamps
_agent_loop_iterationinto run options so turn-scoped context providers can defer theirafter_runwork to the loop boundary. Because remaining run options are also forwarded as provider-specific options, the private marker reached provider SDKs and caused real clients such as Ollama and Foundry to reject the unexpected keyword argument.This change keeps the marker available for provider scoping while preventing framework-private metadata from crossing the chat-client transport boundary.
Description & Review Guide
_agent_loop_iterationfrom the final merged chat options passed to the client, without removing it fromSessionContext.options. Add streaming and non-streaming regression coverage using a strict transport signature.Related Issue
Fixes #7821
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.