-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: Fix declarative package powerfx import crash and response_format kwarg error #3841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes two Python declarative-agent creation failures: (1) importing agent_framework_declarative without a working .NET runtime due to an unconditional powerfx import, and (2) async provider-based agent creation failing on strict provider signatures due to passing response_format as an unexpected kwarg.
Changes:
- Wrap
from powerfx import Enginein_declarative_base.pywithtry/except (ImportError, RuntimeError)and gate evaluation when PowerFx isn’t available. - Pass structured output configuration via
default_options={"response_format": ...}instead of a directresponse_format=kwarg in provider-based agent creation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
python/packages/declarative/agent_framework_declarative/_workflows/_declarative_base.py |
Makes PowerFx import conditional and adds runtime handling when the engine is unavailable. |
python/packages/declarative/agent_framework_declarative/_loader.py |
Fixes provider creation to avoid strict-signature kwarg errors by moving response_format into default_options. |
python/packages/declarative/agent_framework_declarative/_workflows/_declarative_base.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Motivation and Context
from powerfx import Engineimport in_declarative_base.pythat makes the entireagent_framework_declarativepackage unusable without .NET installed.Wraps the import in
try/except (ImportError, RuntimeError)matching the existing pattern in_models.pyand_state.py._create_agent_with_providerpassingresponse_formatas a direct keyword argument toprovider.create_agent(), which fails on providers with strict signatures (e.g.AzureAIProjectAgentProvider). Movesresponse_formatintodefault_optionswhere all providers expect it.@toolfunctions receive custom context data (e.g., user tokens, service configs) passed by the caller.Description
powerfxshould be imported conditionally inagent_framework_declarative#3817Contribution Checklist