Python: fix: pass Foundry agent default headers#6040
Open
he-yufeng wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds support for passing default_headers from RawFoundryAgent / FoundryAgent into the underlying OpenAI client creation, and adds tests to validate the behavior.
Changes:
- Add
default_headerskwarg to agent constructors and forward it through client initialization. - Extend docstrings to document the new
default_headersbehavior. - Add unit tests asserting
default_headersis forwarded and included in__init__signatures.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/packages/foundry/tests/foundry/test_foundry_agent.py | Adds tests verifying default_headers is forwarded and present in __init__ signatures. |
| python/packages/foundry/agent_framework_foundry/_agent.py | Adds default_headers parameter and forwards it through constructor plumbing with doc updates. |
Comment on lines
+522
to
+525
| mock_project.get_openai_client.assert_called_once_with( | ||
| default_headers=default_headers, | ||
| agent_name="hosted-agent", | ||
| ) |
Comment on lines
+542
to
+545
| mock_project.get_openai_client.assert_called_once_with( | ||
| default_headers=default_headers, | ||
| agent_name="hosted-agent", | ||
| ) |
Comment on lines
+515
to
+520
| RawFoundryAgent( | ||
| project_client=mock_project, | ||
| agent_name="hosted-agent", | ||
| allow_preview=True, | ||
| default_headers=default_headers, | ||
| ) |
| FoundryAgent( | ||
| project_client=mock_project, | ||
| agent_name="hosted-agent", | ||
| allow_preview=True, |
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.
Fixes #6027.
Summary
default_headerstoRawFoundryAgentandFoundryAgentTo verify
python -m pytest python/packages/foundry/tests/foundry/test_foundry_agent.py -q -k "default_headers or explicit_parameters"python -m ruff check python/packages/foundry/agent_framework_foundry/_agent.py python/packages/foundry/tests/foundry/test_foundry_agent.pypython -m py_compile python/packages/foundry/agent_framework_foundry/_agent.py python/packages/foundry/tests/foundry/test_foundry_agent.pygit diff --check