Python: Fixed declarative samples#4051
Merged
dmytrostruk merged 7 commits intomicrosoft:mainfrom Feb 18, 2026
Merged
Conversation
Member
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes several issues in the Python declarative agent stack that caused YAML-defined schema/types and model options to be mishandled, and updates declarative samples + tests to validate the corrected behavior.
Changes:
- Fix
AgentFactoryagent creation to pass parsed model/tool/output options viadefault_options(instead of**kwargs) so options aren’t silently dropped. - Fix YAML schema handling by mapping
type→kindinProperty.from_dict()and generating a more valid JSON Schema shape inPropertySchema.to_json_schema(). - Update declarative samples for dotenv initialization and
safe_modeusage; add unit tests covering these behaviors.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/02-agents/declarative/openai_responses_agent.py | Adds dotenv init and sets safe_mode=False for declarative YAML execution. |
| python/samples/02-agents/declarative/microsoft_learn_agent.py | Adds dotenv init and sets safe_mode=False when creating agents with Azure credential. |
| python/samples/02-agents/declarative/mcp_tool_yaml.py | Adjusts dotenv initialization ordering and keeps declarative MCP sample setup. |
| python/samples/02-agents/declarative/inline_yaml.py | Adds dotenv init and sets safe_mode=False for inline YAML that uses PowerFx env access. |
| python/samples/02-agents/declarative/get_weather_agent.py | Adds dotenv init for the sample’s environment-variable-based configuration. |
| python/packages/declarative/tests/test_declarative_models.py | Adds tests for type→kind mapping and JSON Schema generation. |
| python/packages/declarative/tests/test_declarative_loader.py | Adds tests ensuring output schema + chat options land in Agent.default_options. |
| python/packages/declarative/agent_framework_declarative/_models.py | Implements type→kind mapping and improves JSON Schema output formatting. |
| python/packages/declarative/agent_framework_declarative/_loader.py | Fixes passing parsed chat options into Agent(default_options=...) in sync/async paths. |
giles17
approved these changes
Feb 18, 2026
TaoChenOSU
approved these changes
Feb 18, 2026
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
Contribution Checklist