Repository navigation
Python: expose final-only loop responses in create_harness_agent - #10214
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits intoNov 10, 2026
Conversation
M-Hietala
temporarily deployed
to
github-app-auth
November 9, 2026 20:15 — with
GitHub Actions
Inactive
M-Hietala
temporarily deployed
to
github-app-auth
November 9, 2026 20:15 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A raw 0x97 byte makes the test module invalid UTF-8, causing a SyntaxError that prevents pytest from collecting its tests.
1 open issue
What changed in this PR
Exposes the existing final-only loop response option through Python’s create_harness_agent(), addressing #10209 without changing default aggregation or streaming behavior.
Changes:
- Adds keyword-only
loop_return_final_only: bool = Falseto the factory and type stub, forwarding it toAgentLoopMiddleware. - Documents the option’s behavior and when it is ignored.
- Adds regression coverage for non-streaming results, streaming behavior, and configuration without a loop.
| File | Description |
|---|---|
python/packages/core/tests/core/test_harness_agent.py |
Tests defaults, final-only responses, streaming parity, and ignored loop options. |
python/packages/core/AGENTS.md |
Documents the new harness loop option. |
python/packages/core/agent_framework/_harness/_agent.pyi |
Exposes the option in the typed factory signature. |
python/packages/core/agent_framework/_harness/_agent.py |
Adds, documents, and forwards the option to loop middleware. |
Review effort: Balanced
Fix typo in comment regarding function call results. Co-authored-by: Copilot Autofix powered by AI <[email protected]>
M-Hietala
temporarily deployed
to
github-app-auth
November 9, 2026 20:46 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Nov 10, 2026
3 tasks done
This branch was previously 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.

Motivation & Context
Looping harness agents currently return an aggregated non-streaming response containing earlier answers and injected loop prompts. Applications that only need the final answer cannot select the existing
AgentLoopMiddleware.return_final_onlybehavior throughcreate_harness_agent().This change exposes that option without changing the default behavior.
Description & Review Guide
What are the major changes?
Add the optional, keyword-only
loop_return_final_only: bool = Falseparameter tocreate_harness_agent()and its type stub. Forward it toAgentLoopMiddleware, document its behavior, and add regression coverage.What is the impact of these changes?
Non-streaming callers can opt into final-only responses. The default remains
False, preserving existing aggregation. Streaming updates and streaming finalization remain unchanged. The option is ignored whenloop_should_continueis not configured. Middleware ordering and approval handling are unchanged.All 186 tests in the harness factory and loop modules passed, along with focused Ruff, Pyright, and mypy checks. The full core suite has not been run for this change.
What do you want reviewers to focus on?
Runtime/stub signature consistency, unchanged defaults, forwarding to the existing middleware, and streaming parity. This follows the narrowly scoped factory-option proposal in Python: [Feature]: Option in create_harness_agent to return only the agent's answer from a looping run (result.text currently includes the loop's prompts) #10209; it does not change
AgentResponse.textglobally.Related Issue
Fixes #10209
AI Assistance
AI assistance details: Copilot assisted with implementation, tests, documentation, focused validation, and this PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after a language prefix) — a workflow keeps the label and title prefix in sync automatically.