Skip to content

Python: Pass extra declarative model options through as regular options - #10005

Open
ni (nniiovoo) wants to merge 2 commits into
microsoft:mainfrom
nniiovoo:python-declarative-extra-options
Open

ni (nniiovoo) wants to merge 2 commits into
microsoft:mainfrom
nniiovoo:python-declarative-extra-options

Conversation

@nniiovoo

Copy link
Copy Markdown
Contributor

Motivation & Context

Extra provider options under model.options in a declarative agent end up under default_options["additional_chat_options"]. Nothing reads that key since #3140, so the OpenAI Chat and Responses clients get it as a kwarg and agent.run() fails with a TypeError. Repro is in #10004.

Description & Review Guide

  • What are the major changes? _parse_chat_options now merges the leftover additionalProperties into the top-level options instead of nesting them. chatToolMode still maps to tool_choice as before.
  • What is the impact of these changes? An option like user: alice reaches the provider the same way as agent.run(..., options={"user": "alice"}). Nothing else in the repo reads additional_chat_options.
  • What do you want reviewers to focus on? Precedence: if a key is set both as a named field and as an extra, the named field wins. Before Python: [BREAKING]: Introducing Options as TypedDict and Generic #3140 the extra won, so I can flip it if you prefer that.

Tests: I updated the 2 tests that checked additional_chat_options and added one that runs the agent through the OpenAI Chat and Responses clients with a mocked transport and checks the request body. The new test fails on main and passes here.

Related Issue

Fixes #10004

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: issue analysis, implementation, tests, and this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Signed-off-by: NNIIOVO <haimingni44@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the change aligning declarative model options with regular option handling.

No open issues 🎉

What changed in this PR

Fixes #10004 by aligning declarative model options with the framework’s regular options handling, preventing extra provider options from causing agent.run() failures with OpenAI clients.

Changes:

  • Passes extra model options through as top-level options rather than nesting them under additional_chat_options.
  • Gives named fields precedence on conflicts while preserving chatToolMode mapping.
  • Updates existing assertions and adds mocked-request regression coverage for OpenAI Chat and Responses.
File Description
python/​packages/​declarative/​tests/​test_declarative_loader.py Verifies flattened options, named-field precedence, and provider request payloads.
python/​packages/​declarative/​agent_framework_declarative/​_loader.py Merges extra properties into regular chat options without overriding named fields.

Review effort: Balanced

…test

Signed-off-by: NNIIOVO <haimingni44@gmail.com>

This branch was previously deployed

1 inactive deployment
github-app-auth — 053d94f5 Deployed Nov 3, 2026 by nniiovoo via add_label #26922
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Extra provider options in declarative model.options break agent.run() with OpenAI clients

2 participants