Python: updated declarative samples and handling of non-pydantic response formats - #5022
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits intoApr 1, 2026
Conversation
Copilot started reviewing on behalf of
Eduard van Valkenburg (eavanvalkenburg)
April 1, 2026 09:00
View session
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Python declarative samples and extends structured output handling so response_format values provided as runtime JSON schema mappings (dicts) are preserved and parsed into response.value across multiple chat clients.
Changes:
- Update declarative samples/YAML to align with Foundry environment variables and loader defaults.
- Propagate non-Pydantic
response_formatmappings through core response types so JSON text is parsed intodictvalues. - Add/adjust tests across providers (OpenAI, Azure OpenAI, Foundry, Anthropic, Ollama, core) to cover dict
response_formatparsing.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/05-end-to-end/evaluation/foundry_evals/evaluate_tool_calls_sample.py | Minor sample instruction string formatting. |
| python/samples/04-hosting/a2a/a2a_agent_as_function_tools.py | Minor formatting of env var error message. |
| python/samples/02-agents/declarative/openai_agent.py | Use create_agent_from_yaml_path instead of manual YAML loading. |
| python/samples/02-agents/declarative/microsoft_learn_agent.py | Add explanatory module-level documentation for the sample. |
| python/samples/02-agents/declarative/inline_yaml.py | Update sample env var guidance and inline YAML to Foundry model variable. |
| python/packages/openai/tests/openai/test_openai_chat_completion_client.py | Add test coverage for dict response_format parsing; update integration expectations. |
| python/packages/openai/tests/openai/test_openai_chat_client.py | Add runtime JSON schema mapping parsing-path test; update integration expectations. |
| python/packages/openai/tests/openai/test_openai_chat_client_azure.py | Update integration expectations for runtime JSON schema parsing. |
| python/packages/openai/agent_framework_openai/_chat_client.py | Preserve non-Pydantic response_format on ChatResponse for parsing. |
| python/packages/ollama/tests/test_ollama_chat_client.py | Add test for dict response_format parsing. |
| python/packages/ollama/agent_framework_ollama/_chat_client.py | Thread response_format through Ollama parsing to enable JSON parsing. |
| python/packages/foundry/tests/foundry/test_foundry_chat_client.py | Add parsing-path test; update integration expectations. |
| python/packages/declarative/agent_framework_declarative/_loader.py | Update provider mapping and change default_provider to Foundry. |
| python/packages/core/tests/core/test_types.py | Add core type tests for mapping response_format parsing (sync + streaming). |
| python/packages/core/tests/core/test_observability.py | Ensure streaming finalizer passes through mapping response_format. |
| python/packages/core/tests/core/test_agents.py | Add agent-level tests for mapping response_format propagation/parsing. |
| python/packages/core/tests/core/conftest.py | Ensure test streaming clients pass through mapping response_format. |
| python/packages/core/agent_framework/_types.py | Add mapping structured format support and JSON parsing for value. |
| python/packages/core/agent_framework/_tools.py | Pass mapping response_format through streaming finalizer path. |
| python/packages/core/agent_framework/_evaluation.py | Minor formatting tweaks. |
| python/packages/core/agent_framework/_clients.py | Pass mapping response_format into ChatResponse.from_updates. |
| python/packages/core/agent_framework/_agents.py | Preserve mapping response_format when constructing AgentResponse. |
| python/packages/anthropic/tests/test_anthropic_client.py | Add test ensuring dict response_format is preserved for parsing. |
| agent-samples/foundry/MicrosoftLearnAgent.yaml | Update env var names to FOUNDRY_* conventions. |
Eduard van Valkenburg (eavanvalkenburg)
enabled auto-merge
April 1, 2026 10:36
Tao Chen (TaoChenOSU)
approved these changes
Apr 1, 2026
Eduard van Valkenburg (eavanvalkenburg)
force-pushed
the
fix_declarative_samples
branch
from
April 1, 2026 16:32
7e35e41 to
27da577
Compare
Giles Odigwe (giles17)
approved these changes
Apr 1, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Apr 1, 2026
Eduard van Valkenburg (eavanvalkenburg)
force-pushed
the
fix_declarative_samples
branch
from
April 1, 2026 18:45
27da577 to
beeb005
Compare
Eduard van Valkenburg (eavanvalkenburg)
enabled auto-merge
April 1, 2026 18:45
Giles Odigwe (giles17)
approved these changes
Apr 1, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Apr 1, 2026
Eduard van Valkenburg (eavanvalkenburg)
force-pushed
the
fix_declarative_samples
branch
from
April 1, 2026 19:10
beeb005 to
1ed97b4
Compare
Giles Odigwe (giles17)
approved these changes
Apr 1, 2026
Eduard van Valkenburg (eavanvalkenburg)
enabled auto-merge
April 1, 2026 19:13
Eduard van Valkenburg (eavanvalkenburg)
deleted the
fix_declarative_samples
branch
June 30, 2026 09:02
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 and Context
Fixed the declarative samples and noticed that non-pydantic response formats (json schema definition) was not handled in the response types.
Fixed now across the board.
Description
Contribution Checklist