Add sample routines for hosted agents with various triggers#48121
Open
howieleung wants to merge 1 commit into
Open
Add sample routines for hosted agents with various triggers#48121howieleung wants to merge 1 commit into
howieleung wants to merge 1 commit into
Conversation
howieleung
requested review from
bobogogo1990,
dargilco,
glharper,
kingernupur,
nick863,
trangevi and
trrwilson
as code owners
July 17, 2026 22:30
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates hosted-agent routine samples to self-provision temporary agent versions and adds GitHub issue trigger coverage.
Changes:
- Adds a GitHub issue-triggered routine sample.
- Makes existing routine samples create and clean up temporary hosted-agent versions.
- Documents required model and trigger configuration.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
sample_routines_with_timer_trigger.py |
Self-provisions an agent for timer routines. |
sample_routines_with_schedule_trigger.py |
Self-provisions an agent for scheduled routines. |
sample_routines_with_github_issue_trigger.py |
Adds GitHub issue-triggered routine usage. |
sample_routines_with_dispatch.py |
Self-provisions an agent for dispatched routines. |
sample_routines_crud.py |
Self-provisions an agent for CRUD demonstrations. |
Comments suppressed due to low confidence (3)
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_routines_with_timer_trigger.py:74
- The temporary agent version is cleaned up when this context exits, but the routine is deleted only on the normal path. Any polling/service error or
KeyboardInterruptafter creation leaves an enabled timer routine behind while restoring/deleting the agent version it was intended to invoke. Wrap the routine lifecycle intry/finally, as the schedule-trigger sample does, so the routine is deleted before this context unwinds.
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_routines_with_dispatch.py:79 - The temporary agent version is cleaned up when this context exits, but the routine is deleted only on the normal path. If dispatching or polling raises, the sample leaves a stale routine behind after restoring/deleting its backing agent version. Please protect the routine lifecycle with
try/finally, matching the schedule-trigger sample's cleanup pattern.
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_routines_crud.py:72 - The new temporary hosted-agent context always removes/restores its version, but the routine cleanup remains normal-path only. If any CRUD call fails after creation, this leaves a routine referring to an agent whose temporary version has already been removed. Please place routine deletion in a
finallyblock inside this context.
Comment on lines
+73
to
+77
| github_connection_name = os.environ["GITHUB_CONNECTION_NAME"] | ||
| poll_interval_seconds = int(os.environ.get("POLL_INTERVAL_SECONDS", "10")) | ||
|
|
||
| github_owner = os.environ["GITHUB_USERNAME"] | ||
| github_repository = os.environ["GITHUB_REPOSITORY"] |
| 4) GITHUB_CONNECTION_NAME - The Foundry GitHub RemoteTool connection name. | ||
| The connection must be GitHub-compatible and use PAT or OAuth2 credentials. | ||
| 5) GITHUB_USERNAME - The GitHub owner or organization name. | ||
| 6) GITHUB_REPOSITORY - The GitHub repository name in the format of https://github.com/xxx/xxx.git. |
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