Skip to content

Add sample routines for hosted agents with various triggers#48121

Open
howieleung wants to merge 1 commit into
mainfrom
howie/samples-230
Open

Add sample routines for hosted agents with various triggers#48121
howieleung wants to merge 1 commit into
mainfrom
howie/samples-230

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 17, 2026 22:30
@azure-pipelines

Copy link
Copy Markdown
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.

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

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 KeyboardInterrupt after creation leaves an enabled timer routine behind while restoring/deleting the agent version it was intended to invoke. Wrap the routine lifecycle in try/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 finally block 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.
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