Python: Preserve structured output on streaming harness tool-approval path - #7800
Closed
Shivani . (Shivani767) wants to merge 2 commits into
Closed
Conversation
… path Forward response_format through ToolApprovalMiddleware's stream finalizer so AgentResponse.value is parsed the same way as the non-streaming path.
Shivani . (Shivani767)
deployed
to
github-app-auth
August 20, 2026 18:24 — with
GitHub Actions
Active
Shivani . (Shivani767)
deployed
to
github-app-auth
August 20, 2026 18:24 — with
GitHub Actions
Active
Shivani . (Shivani767)
deployed
to
github-app-auth
August 20, 2026 18:24 — with
GitHub Actions
Active
Shivani . (Shivani767)
deployed
to
github-app-auth
August 20, 2026 18:25 — with
GitHub Actions
Active
Shivani . (Shivani767)
deployed
to
github-app-auth
August 20, 2026 18:25 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
Pull request overview
Preserves structured outputs when streaming responses pass through tool-approval middleware.
Changes:
- Forwards the effective response format to the outer stream finalizer.
- Adds streaming, auto-approval, and non-streaming regression tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
python/packages/core/agent_framework/_harness/_tool_approval.py |
Propagates structured-output format during stream finalization. |
python/packages/core/tests/core/test_harness_tool_approval.py |
Adds structured-output regression coverage. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Return the last inner AgentResponse from the streaming tool-approval finalizer so coalesced preamble text cannot clobber response.value.
Shivani . (Shivani767)
deployed
to
github-app-auth
August 20, 2026 18:38 — with
GitHub Actions
Active
Author
Shivani . (Shivani767)
deleted the
fix/7418-harness-streaming-structured-value
branch
August 20, 2026 18:44
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
Streaming harness runs that go through
ToolApprovalMiddlewarere-wrap the innerResponseStreamwithAgentResponse.from_updatesand did not forwardoutput_format_type.AgentResponse.valueis only parsed when_response_formatis set, so structured-output streaming runs returnedresponse.value is None. The non-streaming path is unaffected because it returns the innerAgentResponsedirectly.Description & Review Guide
ToolApprovalMiddleware._process_streamnow finalizes withAgentResponse.from_updates(..., output_format_type=...), using runoptions["response_format"]and falling back to the agent'sdefault_options.optionsthendefault_options) at wrap time, and that auto-approved tool calls still parse the final JSON message.Related Issue
Fixes #7418
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.