Skip to content

For hosted agent, remove rbac assignment, make all of them always cre…#47887

Open
howieleung wants to merge 3 commits into
mainfrom
howie/samples-25
Open

For hosted agent, remove rbac assignment, make all of them always cre…#47887
howieleung wants to merge 3 commits into
mainfrom
howie/samples-25

Conversation

@howieleung

Copy link
Copy Markdown
Member

…ate version or create from code, call update details and use agent endpoint. and tear down by restore back the agent detail and delete hosted agent. Removed echo agent and use basic agent instead

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.

…ate version or create from code, call update details and use agent endpoint. and tear down by restore back the agent detail and delete hosted agent. Removed echo agent and use basic agent instead

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

This PR reworks the azure-ai-projects hosted-agent samples so they no longer depend on RBAC role assignment. RBAC support (rbac_util.py, ensure_agent_identity_rbac[_async]) is removed, and the image/code/session samples now consistently create a version, route the agent endpoint to it via update_details, exercise it, and then tear down (restore the original endpoint and delete the version). The old echo-agent asset is replaced with basic-agent, the zip helper is renamed to zip_directory, and shared create_version_from_code[_async] context managers centralize the create/wait/route/teardown lifecycle. Sample renames (sample_create_hosted_agent[_async].py..._from_image[_async].py) and the removal of sample_agent_endpoint[_async].py are reflected in the sample-test parametrization.

Changes:

  • Remove RBAC assignment path and the echo-agent container asset; standardize samples on create_version_from_code[_async] + update_details + endpoint restore + version delete.
  • Rename zipzip_directory and the select_echo_agent_code_zip helper → select_basic_agent_code_zip; add shared lifecycle context managers.
  • Update sample-test discovery/parametrization (new session/log-stream entries, renamed image samples) and add a _resolve_sample_path_from_filename fallback in sample_executor.py.

Reviewed changes

Copilot reviewed 27 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
samples/hosted_agents/hosted_agents_util.py Adds create_version_from_code[_async] context managers; renames helper to select_basic_agent_code_zip; drops get_latest_active_agent_version[_async].
samples/hosted_agents/sample_create_hosted_agent_from_image.py Renamed from sample_create_hosted_agent.py; RBAC replaced with endpoint routing (stale RBAC/echo-agent docstrings remain; no teardown).
samples/hosted_agents/sample_create_hosted_agent_from_image_async.py New async image sample with endpoint routing + teardown (stale echo-agent ref and unneeded mgmt deps in docstring).
samples/hosted_agents/sample_create_hosted_agent_from_code[_async].py Switch to basic-agent, hardcode agent name, add endpoint routing + teardown.
samples/hosted_agents/sample_sessions_crud[_async].py, sample_sessions_files_upload_download[_async].py, sample_session_log_stream[_async].py Create a temporary version via the new context manager instead of resolving an existing active version.
samples/hosted_agents/sample_toolbox_with_skill.py, sample_agent_user_identity_isolation.py Use create_version_from_code; remove RBAC and inline lifecycle handling.
samples/hosted_agents/rbac_util.py, sample_agent_endpoint[_async].py, sample_create_hosted_agent_async.py, assets/echo-agent/* Deleted.
samples/hosted_agents/assets/Dockerfile New Dockerfile for building an agent image.
samples/util.py, samples/skills/sample_skills_upload_and_download[_async].py zipzip_directory rename and callers updated.
tests/samples/test_samples.py, test_samples_async.py, sample_executor.py, test_util.py Update sample-test parametrization/skip lists and add synthetic-path fallback logic.
Comments suppressed due to low confidence (3)

sdk/ai/azure-ai-projects/samples/hosted_agents/sample_create_hosted_agent_from_image.py:15

  • This docstring still claims the sample sets up agent identity RBAC via ensure_agent_identity_rbac, but RBAC was removed from this sample in this PR (the rbac_util import and the ensure_agent_identity_rbac call are gone, and rbac_util.py is deleted). The statement is now inaccurate and should be updated to reflect that the sample routes the agent endpoint via update_details.
    sdk/ai/azure-ai-projects/samples/hosted_agents/sample_create_hosted_agent_from_image.py:30
  • This references the assets/echo-agent folder, which is deleted in this PR (its main.py, README.md, and requirements.txt are removed). The replacement asset is assets/basic-agent (a new assets/Dockerfile is also added). Please update the reference so users aren't pointed at a nonexistent folder.
    sdk/ai/azure-ai-projects/samples/hosted_agents/sample_create_hosted_agent_from_image.py:93
  • Unlike its async counterpart sample_create_hosted_agent_from_image_async.py (which captures original_agent_endpoint, restores it, and deletes the created version in a finally block), this sync sample configures the endpoint via update_details but never restores the original endpoint or deletes the created version. This diverges from the PR's stated goal of "tear down by restore back the agent detail and delete hosted agent" and, on repeated runs, leaves the agent endpoint pointed at a version and accumulates undeleted versions. Consider wrapping the body in try/finally with endpoint restore and version cleanup to match the async variant.

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