Tethered agent sample - #526
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new tethered-agent sample under test_samples/ to demonstrate running an AgentApplication with the aiohttp hosting adapter while enabling outbound network egress restrictions via tethered.
Changes:
- Introduces an aiohttp server bootstrap (
start_server.py) wired with JWT authorization middleware and the SDK’sstart_agent_process. - Adds a sample agent (
agent.py) using MSAL connection management + OAuth authorization, with a couple of basic message routes. - Adds sample scaffolding (
main.py,requirements.txt,env.TEMPLATE) to run the sample and configure credentials.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test_samples/tethered-agent/src/start_server.py | aiohttp app bootstrap for /api/messages using CloudAdapter + JWT middleware. |
| test_samples/tethered-agent/src/main.py | Sample entrypoint enabling tethered egress allowlist then starting the server. |
| test_samples/tethered-agent/src/agent.py | Defines AGENT_APP, MSAL CONNECTION_MANAGER, and a few handlers (help/echo/get). |
| test_samples/tethered-agent/src/init.py | Marks src as a package for relative imports. |
| test_samples/tethered-agent/requirements.txt | Declares dependencies needed to run the sample. |
| test_samples/tethered-agent/README.md | Sample documentation placeholder. |
| test_samples/tethered-agent/env.TEMPLATE | Template environment variables for auth + connection routing. |
Suppressed comments (1)
test_samples/tethered-agent/src/start_server.py:33
run_appexpects an integer port;environ.get("PORT", 3978)will be a string whenPORTis set, which can raise aTypeErrorat startup. Also the try/except withraise erroris redundant and re-raising this way drops the original traceback context.
run_app(APP, host="localhost", port=environ.get("PORT", 3978))
except Exception as error:
raise error
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (4)
test_samples/tethered-agent/src/agent.py:6
- Unused import
path(not referenced anywhere in this module).
from os import environ, path
test_samples/tethered-agent/src/main.py:7
"www.botframework."is not a valid hostname pattern (missing TLD / wildcard) and is inconsistent with the other*.botframework.*allow-list entries, so it likely won't match any real endpoint.
"www.botframework.",
test_samples/tethered-agent/src/start_server.py:32
aiohttp.web.run_appexpectsportto be an int;environ.get("PORT")returns a string when set. Also the try/except re-raises asraise error, which loses the original traceback and adds no value here.
try:
run_app(APP, host="localhost", port=environ.get("PORT", 3978))
except Exception as error:
raise error
test_samples/tethered-agent/src/agent.py:42
- The welcome text says "Echo Agent sample" and references an echo feature, but this is the tethered-agent sample and also exposes a
/getcommand. This makes the sample instructions misleading.
await context.send_activity(
"Welcome to the Echo Agent sample 🚀. "
"Type /help for help or send a message to see the echo feature in action."
)
No description provided.