Skip to content

upse agent endpoints#47983

Open
howieleung wants to merge 10 commits into
mainfrom
howie/samples-28
Open

upse agent endpoints#47983
howieleung wants to merge 10 commits into
mainfrom
howie/samples-28

Conversation

@howieleung

Copy link
Copy Markdown
Member

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:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings July 9, 2026 21:21

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.

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.py shims 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

Comment thread sdk/ai/azure-ai-projects/samples/util.py Outdated
Comment thread sdk/ai/azure-ai-projects/samples/util.py Outdated
Comment thread sdk/ai/azure-ai-projects/samples/util.py Outdated
Comment thread sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants