mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
36ce0950e4
Remove linking, multicast, durable delivery, and host push machinery from the v1 hosting core. Keep those scenarios in a proposed follow-up ADR and update channel packages, samples, docs, tests, and workspace metadata around the smaller host/channel contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1.6 KiB
1.6 KiB
local_telegram — @tool, file-backed history, hooks, Telegram
Builds on foundry_hosted_agent/ with the hooks and config most real apps need:
- A
@tool-decorated function call (get_weather) so streaming and tool invocation are exercised end-to-end. FileHistoryProvider(./storage/sessions)so per-user/per-chat history survives restarts.- A
responses_hookthat keys each session off the OpenAIsafety_identifierfield, so multiple users on the Responses endpoint do not share history. - A
telegram_hookthat keys per-chat sessions viatelegram_isolation_key. - Two extra Telegram commands (
/new,/whoami).
app:app is a module-level Starlette ASGI app, so this sample runs under
Hypercorn (multi-process).
Run
export FOUNDRY_PROJECT_ENDPOINT=https://<your-project>.services.ai.azure.com
export FOUNDRY_MODEL=gpt-4o
export TELEGRAM_BOT_TOKEN=...
az login
uv sync
uv run hypercorn app:app \
--bind 0.0.0.0:8000 \
--workers 4
Single-process for quick iteration:
uv run python app.py
Call locally
uv sync --group dev
# Plain call:
uv run python call_server.py "What is the weather in Tokyo?"
# Resume an existing session by AgentSession id (works across channels):
uv run python call_server.py --previous-response-id telegram:8741188429 "What did we discuss?"
This sample is local-only — it shows the
agent-framework-hostingserver stack as a standalone process. For a Foundry-Hosted-Agents-compatible packaging (Dockerfile +agent.yaml+azure.yaml), seefoundry_hosted_agent/.