Repository navigation
Python: Support response_format in GitHubCopilotAgent - #9810
Dineshsuriya D (droideronline) wants to merge 5 commits into
Conversation
Forward response_format as response_schema to the Copilot SDK send and send_and_wait calls, keep it out of create_session kwargs, and parse AgentResponse.value for streaming and non-streaming runs.
There was a problem hiding this comment.
🟡 Changes recommended
Structured-output parsing can incorrectly use trailing subagent text instead of the root answer, while mapping schemas and aliased models can trigger serialization or validation failures.
3 open issues
What changed in this PR
Adds opt-in structured output support to GitHubCopilotAgent, bringing it closer to other Agent Framework providers and addressing #9809.
Changes:
- Accepts Pydantic models or JSON Schema mappings through
response_format. - Forwards schemas to streaming and non-streaming SDK calls, excludes them from session creation, and enables
AgentResponse.valueparsing. - Adds tests for schema forwarding, default options, unstructured requests, and streaming results.
| File | Description |
|---|---|
python/packages/github_copilot/tests/test_github_copilot_agent.py |
Adds structured-output tests for both response modes. |
python/packages/github_copilot/agent_framework_github_copilot/_agent.py |
Adds the option, SDK forwarding, and structured response parsing. |
Review effort: Balanced
Parse the streaming structured value from root-agent text only, convert mapping schemas to plain dicts before they reach the SDK, and validate Pydantic models by alias to match the schema the SDK requests.
|
Hi Eduard van Valkenburg (@eavanvalkenburg) , please take a look when you get a chance |
|
Eduard van Valkenburg (@eavanvalkenburg) - the pipeline failure is fixed. Could you please retrigger the pipeline when you get a chance? Thanks! |
|
Eduard van Valkenburg (@eavanvalkenburg) - I moved the alias parsing into core as you suggested (790ac8e), and fixed the typing failure in the new aliased-model tests (3d1e5c8). Could you please retrigger the pipeline when you get a chance? If everything is green, would it be possible to get this into the next release? We are waiting on structured output for the GitHub Copilot agent. Thanks! |


Motivation & Context
GitHubCopilotAgentignoredresponse_format, so structured output was unavailable even though the Copilot SDK supports it (github/copilot-sdk#2590, in SDK v1.0.15 and later, within the existing>=1.0.16pin).Description & Review Guide
response_format(Pydantic model type or JSON Schema mapping) toGitHubCopilotOptions.response_schematosend_and_wait(non-streaming) andsend(streaming). Per-run options overridedefault_options.response_formatis stripped from thecreate_sessionkwargs so it no longer reaches the SDK session factory.AgentResponse.valueis parsed from the final text: viaresponse_format=on the non-streaming response andoutput_format_type=in the streaming finalizer.response_formatthe SDK receivesresponse_schema=None, which is the existing behavior.Related Issue
Fixes #9809
AI Assistance
AI assistance details: implementation and tests.
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.