Skip to content

Comments

Python: Fixed declarative samples#4051

Merged
dmytrostruk merged 7 commits intomicrosoft:mainfrom
dmytrostruk:sample-fixes-6
Feb 18, 2026
Merged

Python: Fixed declarative samples#4051
dmytrostruk merged 7 commits intomicrosoft:mainfrom
dmytrostruk:sample-fixes-6

Conversation

@dmytrostruk
Copy link
Member

Motivation and Context

  • Fixed AgentFactory to pass chat_options as default_options instead of **kwargs, which caused response_format, temperature, and other options to be silently dropped.
  • Fixed Property.from_dict() to map YAML type field to kind instead of discarding it.
  • Fixed PropertySchema.to_json_schema() to produce valid JSON Schema (added root "type": "object", converted per-property required booleans to top-level array, removed empty enum arrays).
  • Updated declarative samples to correctly initialize load_dotenv() and safe_mode for PowerFx expression support.
  • Added unit tests for the above fixes.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@dmytrostruk dmytrostruk self-assigned this Feb 18, 2026
Copilot AI review requested due to automatic review settings February 18, 2026 21:39
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 18, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/declarative/agent_framework_declarative
   _loader.py24011552%311–317, 481–486, 517, 550–553, 556–558, 561–567, 594–600, 644–653, 655, 658, 660, 671, 675–681, 690, 692, 694, 700, 702, 704, 706, 708, 721–726, 733–738, 740, 744–754, 756–761, 769, 771, 776, 779–782, 785–786, 789–790, 804–805, 808–809, 827, 834–838
   _models.py4842894%28, 31, 64, 69, 514, 555–558, 582, 590, 598, 606, 629, 655, 679, 707, 817, 879, 991, 1117, 1119, 1121, 1123, 1125, 1127, 1131, 1133
TOTAL21213329984% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4183 239 💤 0 ❌ 0 🔥 1m 16s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AgentFactory agent creation to pass parsed model/tool/output options via default_options (instead of **kwargs) so options aren’t silently dropped.
  • Fix YAML schema handling by mapping typekind in Property.from_dict() and generating a more valid JSON Schema shape in PropertySchema.to_json_schema().
  • Update declarative samples for dotenv initialization and safe_mode usage; 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 typekind 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 typekind 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.

@dmytrostruk dmytrostruk added this pull request to the merge queue Feb 18, 2026
Merged via the queue into microsoft:main with commit 57da1bc Feb 18, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants