upse agent endpoints#47983
Open
howieleung wants to merge 10 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors azure-ai-projects agent samples to create an agent version, configure the agent endpoint to route traffic to that version, and then use an endpoint-scoped OpenAI client (get_openai_client(agent_name=...)) for responses—while ensuring temporary versions are cleaned up via context managers.
Changes:
- Add shared sync/async context managers (
create_version_with_endpoint*) to create a version, update the agent endpoint to route 100% traffic to it, and cleanup on exit. - Update many agent samples to rely on the endpoint-scoped OpenAI client instead of passing
extra_body={"agent_reference": ...}. - Remove the older retrieve-sample helper and add lightweight per-folder
util.pyshims to reuse shared sample utilities.
Reviewed changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/ai/azure-ai-projects/samples/util.py | Adds shared context managers for version+endpoint setup/cleanup (sync/async) |
| sdk/ai/azure-ai-projects/samples/agents/util.py | Shim to re-export shared util helpers for samples/agents/ |
| sdk/ai/azure-ai-projects/samples/agents/tools/util.py | Shim to re-export shared util helpers for samples/agents/tools/ |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_toolboxes_with_search_preview.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_toolboxes_with_search_preview_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_work_iq_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_with_custom_search.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_preview.py | Uses context manager + endpoint-scoped OpenAI client (preview tool) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_toolbox_skill.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_to_agent.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_sharepoint.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi_with_project_connection.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search.py | Uses context manager + endpoint-scoped OpenAI client; removes agent_reference extra_body |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation.py | Uses context manager + endpoint-scoped OpenAI client (image generation header) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool.py | Uses context manager + endpoint-scoped OpenAI client; removes agent_reference extra_body |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_fabric.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_fabric_iq.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_fabric_iq_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use.py | Uses context manager + endpoint-scoped OpenAI client (computer tool loop) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_browser_automation.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_grounding.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_custom_search.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_azure_function.py | Uses context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_ai_search.py | Uses context manager + endpoint-scoped OpenAI client (streaming) |
| sdk/ai/azure-ai-projects/samples/agents/telemetry/util.py | Shim to re-export shared util helpers for samples/agents/telemetry/ |
| sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing.py | Uses context manager + endpoint-scoped OpenAI client; removes manual cleanup |
| sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_azure_monitor_tracing.py | Uses context manager + endpoint-scoped OpenAI client; removes manual cleanup |
| sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output.py | Uses context manager + endpoint-scoped OpenAI client; removes agent_reference extra_body |
| sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output_async.py | Async variant using endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/sample_agent_stream_events.py | Uses context manager + endpoint-scoped OpenAI client (streaming events) |
| sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic.py | Reworks retrieve demo to create agent version via new context manager |
| sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic_async.py | Async variant reworked to use new context manager |
| sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic.py | Uses context manager + endpoint-scoped OpenAI client; removes manual cleanup |
| sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic_async.py | Async variant using context manager + endpoint-scoped OpenAI client |
| sdk/ai/azure-ai-projects/samples/agents/agent_retrieve_helper.py | Removes older helper that created agent+conversation for retrieve samples |
| sdk/ai/azure-ai-projects/assets.json | Updates assets tag reference |
…sary comments in sample agent scripts
… to default value "MyAgent" across multiple sample scripts and tests.
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.
Description
Please add an informative description that covers that changes made by the pull request and link all relevant issues.
If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines