Python: Add Foundry-hosted Telegram sample - #7883
Python: Add Foundry-hosted Telegram sample#7883Eduard van Valkenburg (eavanvalkenburg) wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an end-to-end Foundry-hosted Telegram agent sample using APIM, Cosmos DB, Key Vault, and Application Insights.
Changes:
- Implements Telegram request handling and streamed delivery.
- Adds Azure infrastructure and deployment automation.
- Adds tests, evaluation configuration, documentation, and validation integration.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/scripts/workspace_poe_tasks.py |
Excludes the sample from workspace typing checks. |
python/pyrightconfig.samples.json |
Adds the sample to Pyright exclusions. |
python/samples/04-hosting/README.md |
Advertises the Telegram hosted sample. |
python/samples/04-hosting/foundry-hosted-agents/README.md |
Adds the Invocations sample link. |
python/samples/04-hosting/af-hosting/local_telegram/README.md |
Cross-links the hosted variant. |
telegram/main.py |
Implements the hosted Telegram runtime. |
telegram/deploy.sh |
Provisions, deploys, validates, and registers the webhook. |
telegram/azure.yaml |
Defines the hosted-agent service. |
telegram/pyproject.toml |
Declares runtime and development dependencies. |
telegram/README.md |
Documents deployment, operation, and limitations. |
telegram/eval.yaml |
Configures hosted-agent evaluation. |
telegram/infra/main.bicep |
Defines subscription-level deployment. |
telegram/infra/resources.bicep |
Provisions Azure resources and RBAC. |
telegram/infra/telegram-policy.xml |
Authenticates and adapts Telegram webhooks. |
telegram/tests/test_main.py |
Tests runtime and Telegram behavior. |
telegram/tests/test_infrastructure.py |
Tests deployment configuration. |
telegram/.agentignore |
Limits hosted deployment contents. |
telegram/.gitignore |
Ignores local generated files. |
telegram/.env.example |
Provides local configuration examples. |
telegram/.agent_configs/baseline/metadata.yaml |
Defines evaluation metadata. |
telegram/.agent_configs/baseline/instructions.md |
Defines the evaluation baseline. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 7670f4a27347
Model: gpt-5.6-sol
Overview
The sample establishes a clear Telegram-to-APIM-to-Foundry flow with strong webhook-secret handling, managed-identity authentication, bounded downloads, token-safe errors, and focused tests for command and streaming behavior. Four residual integration defects affect advertised media handling, durable Cosmos history, webhook-secret rotation, and idempotent RBAC provisioning. The production limitations appropriately disclose retry, deduplication, concurrency, and network-hardening gaps.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
4 verified findings remained after source verification (4 medium) across 2 files. Details are attached to the affected lines below.
Affected areas: python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/deploy.sh, python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/main.py
Add a deployable Telegram webhook sample using APIM, Foundry Hosted Agents, Cosmos DB history, Key Vault secrets, streaming responses, and Azure Monitor telemetry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5dde1074-f970-4233-ac2b-b24d50fcf709
Load the hosted agent prompt from the same baseline instructions file used by evaluation tooling and include that file in direct-code deployments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5dde1074-f970-4233-ac2b-b24d50fcf709
Synchronize APIM secrets before webhook registration, tighten Cosmos RBAC checks, constrain media to serializer-safe formats and sizes, and remove the non-scoreable evaluation target. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5dde1074-f970-4233-ac2b-b24d50fcf709
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5dde1074-f970-4233-ac2b-b24d50fcf709
eb1edfb to
76dfae5
Compare
Motivation & Context
Agent Framework has Telegram protocol helpers and Foundry Invocations hosting support, but it does not yet have an end-to-end sample showing how to expose a Telegram bot through a Foundry Hosted Agent. This adds a deployable learning sample covering the complete Telegram, API Management, Foundry, Agent Framework, and Telegram Bot API path.
Description & Review Guide
pyproject.toml/uv dependency management, focused tests, deployment documentation, and links from the hosting sample indexes.Related Issue
Fixes #6587
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and the title prefix in sync automatically.