Agents SDK 智能体生产加固
agents-sdk-to-prod
评估、创建、加固、部署或审查 Python Microsoft 365 Agents SDK 智能体的生产就绪度,以及其直接的托管/运维文件。仅用于 Agents SDK 场景,不用于无关的应用加固。
- License 许可
- MIT
- 所属仓库
- microsoft/Agents
- 最近更新
- 2026-11-14
- Stars
- ★ 1.1k
- Forks
- 346
01 前言 Front Matter
- name
- agents-sdk-to-prod
- description
- Assess, create, harden, deploy, or review production readiness of Python Microsoft 365 Agents SDK agents and their direct hosting/operations files. Use only for Agents SDK scenarios, not unrelated application hardening.
02 资源文件 136
- 参考文档references/readiness-matrix.md7.2 KB
- 脚本resources/initialize/backend/__init__.py31 B
- 其他resources/initialize/backend/.env.example996 B
- 其他resources/initialize/backend/.gitignore2.2 KB
- 其他resources/initialize/backend/.models.example376 B
- 脚本resources/initialize/backend/bootstrap.py6.6 KB
- 其他resources/initialize/backend/deploy/nginx/nginx.conf961 B
- 其他resources/initialize/backend/deploy/nginx/nginx.conf.template1.0 KB
- 许可证resources/initialize/backend/LICENSE1.0 KB
- 脚本resources/initialize/backend/main.py3.9 KB
- 其他resources/initialize/backend/pyproject.toml1.0 KB
- 参考文档resources/initialize/backend/README.md225 B
- 参考文档resources/initialize/backend/requirements.txt209 B
- 脚本resources/initialize/backend/scripts/generate_nginx_conf.py843 B
- 脚本resources/initialize/backend/src/config/__init__.py1.3 KB
- 脚本resources/initialize/backend/src/config/dotenv.py1.4 KB
- 脚本resources/initialize/backend/src/config/files.py4.5 KB
- 脚本resources/initialize/backend/src/config/logger.py5.4 KB
- 脚本resources/initialize/backend/src/config/paths.py1.6 KB
- 脚本resources/initialize/backend/src/config/settings.py5.9 KB
- 脚本resources/initialize/backend/src/core/__init__.py417 B
- 脚本resources/initialize/backend/src/core/agents/__init__.py246 B
- 脚本resources/initialize/backend/src/core/agents/base.py9.9 KB
- 脚本resources/initialize/backend/src/core/agents/factory.py4.3 KB
- 脚本resources/initialize/backend/src/core/auth.py2.4 KB
- 脚本resources/initialize/backend/src/core/validators/__init__.py127 B
- 脚本resources/initialize/backend/src/core/validators/general_agent.py833 B
- 脚本resources/initialize/backend/src/db/__init__.py1.1 KB
- 脚本resources/initialize/backend/src/db/connection.py3.9 KB
- 脚本resources/initialize/backend/src/db/models.py1.6 KB
- 脚本resources/initialize/backend/src/db/repositories.py1.7 KB
- 脚本resources/initialize/backend/src/db/repository.py2.3 KB
- 脚本resources/initialize/backend/src/helpers/__init__.py1.9 KB
- 脚本resources/initialize/backend/src/helpers/cors.py979 B
- 脚本resources/initialize/backend/src/helpers/date_utils.py2.0 KB
- 脚本resources/initialize/backend/src/helpers/error_handlers.py2.7 KB
- 脚本resources/initialize/backend/src/helpers/exceptions.py2.8 KB
- 脚本resources/initialize/backend/src/helpers/frontend_runner.py3.3 KB
- 脚本resources/initialize/backend/src/helpers/middleware.py3.2 KB
- 脚本resources/initialize/backend/src/helpers/nginx.py1.2 KB
- 脚本resources/initialize/backend/src/helpers/port_utils.py4.4 KB
- 脚本resources/initialize/backend/src/helpers/rate_limit.py1.8 KB
- 脚本resources/initialize/backend/src/helpers/retry.py3.0 KB
- 脚本resources/initialize/backend/src/helpers/tailscale.py6.7 KB
- 脚本resources/initialize/backend/src/providers/__init__.py487 B
- 脚本resources/initialize/backend/src/providers/email.py3.3 KB
- 脚本resources/initialize/backend/src/providers/google.py1.2 KB
- 脚本resources/initialize/backend/src/providers/llm/__init__.py190 B
- 脚本resources/initialize/backend/src/providers/llm/config.py1.4 KB
- 脚本resources/initialize/backend/src/providers/llm/model.py1.8 KB
- 脚本resources/initialize/backend/src/providers/proxy/manager.py4.6 KB
- 脚本resources/initialize/backend/src/routers/__init__.py315 B
- 脚本resources/initialize/backend/src/routers/agent.py1.1 KB
- 脚本resources/initialize/backend/src/routers/auth.py3.9 KB
- 脚本resources/initialize/backend/src/routers/dependencies.py1.3 KB
- 脚本resources/initialize/backend/src/schema/__init__.py1.1 KB
- 脚本resources/initialize/backend/src/schema/agent.py1.7 KB
- 脚本resources/initialize/backend/src/schema/auth.py1.9 KB
- 脚本resources/initialize/backend/src/schema/common.py1.3 KB
- 脚本resources/initialize/backend/src/services/__init__.py187 B
- 脚本resources/initialize/backend/src/services/agent.py1.6 KB
- 脚本resources/initialize/backend/src/services/auth.py6.7 KB
- 脚本resources/initialize/backend/tests/__init__.py29 B
- 脚本resources/initialize/backend/tests/conftest.py1.5 KB
- 脚本resources/initialize/backend/tests/core/__init__.py1 B
- 脚本resources/initialize/backend/tests/core/test_agent.py4.9 KB
- 脚本resources/initialize/backend/tests/core/test_auth.py6.4 KB
- 脚本resources/initialize/backend/tests/core/test_factory.py5.5 KB
- 脚本resources/initialize/backend/tests/helpers/test_tailscale.py3.6 KB
- 脚本resources/initialize/backend/tests/routers/__init__.py—
- 脚本resources/initialize/backend/tests/routers/test_agent.py3.6 KB
- 脚本resources/initialize/backend/tests/routers/test_auth.py14.5 KB
- 脚本resources/initialize/backend/tests/services/__init__.py—
- 脚本resources/initialize/backend/tests/services/test_agent.py2.0 KB
- 脚本resources/initialize/backend/tests/services/test_auth.py13.5 KB
- 脚本resources/initialize/backend/tests/test_health.py634 B
- 脚本resources/initialize/backend/tests/test_llm_provider.py2.3 KB
- 脚本resources/initialize/backend/tests/test_proxy_manager.py1.1 KB
- 参考文档resources/initialize/frontend/templates/chrome-extension/components.json524 B
- 参考文档resources/initialize/frontend/templates/chrome-extension/manifest.json791 B
- 参考文档resources/initialize/frontend/templates/chrome-extension/options.html318 B
- 参考文档resources/initialize/frontend/templates/chrome-extension/package.json875 B
- 参考文档resources/initialize/frontend/templates/chrome-extension/panel.html315 B
- 参考文档resources/initialize/frontend/templates/chrome-extension/popup.html314 B
- 脚本resources/initialize/frontend/templates/chrome-extension/setup.py12.1 KB
- 参考文档resources/initialize/frontend/templates/chrome-extension/sidepanel.html323 B
- 脚本resources/initialize/frontend/templates/chrome-extension/src/background/index.ts2.0 KB
- 其他resources/initialize/frontend/templates/chrome-extension/src/components/layout/theme-provider.tsx581 B
- 其他resources/initialize/frontend/templates/chrome-extension/src/components/layout/user-menu.tsx15.1 KB
- 脚本resources/initialize/frontend/templates/chrome-extension/src/content/index.ts2.5 KB
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/options/App.tsx5.4 KB
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/options/main.tsx245 B
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/panel/App.tsx15.9 KB
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/panel/main.tsx239 B
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/popup/App.tsx5.7 KB
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/popup/main.tsx245 B
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/sidepanel/App.tsx5.5 KB
- 其他resources/initialize/frontend/templates/chrome-extension/src/entry/sidepanel/main.tsx245 B
- 脚本resources/initialize/frontend/templates/chrome-extension/src/hooks/use-chrome-storage.ts1.8 KB
- 脚本resources/initialize/frontend/templates/chrome-extension/src/lib/utils.ts169 B
- 其他resources/initialize/frontend/templates/chrome-extension/src/styles/globals.css21.6 KB
- 参考文档resources/initialize/frontend/templates/chrome-extension/tsconfig.json624 B
- 脚本resources/initialize/frontend/templates/chrome-extension/vite.config.ts1.2 KB
- 其他resources/initialize/frontend/templates/frontend/.gitignore32 B
- 其他resources/initialize/frontend/templates/frontend/app/(app)/layout.tsx615 B
- 其他resources/initialize/frontend/templates/frontend/app/(auth)/layout.tsx560 B
- 其他resources/initialize/frontend/templates/frontend/app/(auth)/login/page.tsx334 B
- 其他resources/initialize/frontend/templates/frontend/app/(public)/layout.tsx231 B
- 其他resources/initialize/frontend/templates/frontend/app/(public)/page.tsx488 B
- 其他resources/initialize/frontend/templates/frontend/app/layout.tsx3.3 KB
- 其他resources/initialize/frontend/templates/frontend/app/not-found.tsx1.2 KB
- 参考文档resources/initialize/frontend/templates/frontend/components.json520 B
- 其他resources/initialize/frontend/templates/frontend/components/auth/login-form.tsx9.3 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/app-shell.tsx1.4 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/header.tsx1.0 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/login-modal.tsx10.6 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/navbar.tsx2.8 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/sidebar.tsx10.4 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/theme.tsx6.6 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/toast.tsx4.0 KB
- 其他resources/initialize/frontend/templates/frontend/components/layout/user-menu.tsx22.5 KB
- 其他resources/initialize/frontend/templates/frontend/components/ui/dropdown-menu.tsx8.9 KB
- 其他resources/initialize/frontend/templates/frontend/globals.css20.8 KB
- 脚本resources/initialize/frontend/templates/frontend/hooks/use-auth.ts1.6 KB
- 脚本resources/initialize/frontend/templates/frontend/hooks/use-sidebar.ts1.9 KB
- 脚本resources/initialize/frontend/templates/frontend/lib/api.ts3.6 KB
- 脚本resources/initialize/frontend/templates/frontend/lib/sse.ts1.9 KB
- 脚本resources/initialize/frontend/templates/frontend/lib/utils.ts373 B
- 脚本resources/initialize/frontend/templates/frontend/next.config.ts1.1 KB
- 参考文档resources/initialize/frontend/templates/frontend/package.json454 B
- 脚本resources/initialize/frontend/templates/frontend/scripts/generate-types.sh946 B
- 脚本resources/initialize/frontend/templates/frontend/setup.py21.2 KB
- 参考文档resources/initialize/frontend/templates/frontend/tsconfig.json357 B
- 参考文档resources/scaffold-ui.md20.2 KB
- 脚本scripts/bootstrap.py2.4 KB
- 脚本scripts/setui.py12.5 KB
03 SKILL.md 正文
Move a Python Agents SDK agent toward production
Use this skill for microsoft_agents.hosting.core, microsoft_agents.hosting.aiohttp, and related SDK packages. Preserve the selected scenario and change only
files that directly run, host, secure, observe, test, deploy or operate the agent.
An external dependency requiring changes outside that scope needs an explicit
scope decision. A question or review request is read-only.
Sources
- Read Prepare an agent for production on Microsoft Learn first, using the Python language selection. Treat the article and its linked shared production controls as normative.
- Read the packaged readiness matrix for control IDs, statuses, applicability, dependencies and evidence rules.
- Inspect
samples/python/production-reference/, or the reference. It demonstrates one bounded Web Chat/App Service/Blob profile. - Inspect the target's actual SDK APIs and dependency baseline. The reference uses stable released packages; verify the installed APIs before changing the user's dependency version or selecting production controls.
Workflow
1. Discover
- Determine whether the user wants a new sample, an assessment, or changes to an existing sample. Do not ask when the request or repository already shows the answer.
- Inspect the candidate Agents SDK sample before asking questions. If multiple samples exist, identify the requested sample or ask which one is in scope.
- Identify channel, cloud, host, inbound audiences and issuers, trusted calling applications, downstream identities, outbound hosts, state, external dependencies, data classes, retention, scale, side effects, long-running work, model calls, retrieval, tools, token-bearing downloaders, attachments, transcripts, and proactive messaging.
- State the deployment boundary. Do not broaden channel, host, identity, data, or application scope without user approval.
2. Assess
- Classify every applicable readiness control as
verified,implemented,missing,not applicable, orblockedusing the readiness matrix. - Cite repository evidence for each
verifiedorimplementedresult. Do not infer production evidence from the presence of source code. - For review or question-only requests, stop at guidance and assessment. Do not modify files.
3. Agree
- Recommend the smallest suitable production profile and defaults.
- Ask only for unresolved decisions that materially affect architecture, cost, identity, channel, data handling, or side effects.
- Present the implementation sequence and identify changes that would extend beyond Agents SDK-related code. Obtain approval for that expansion.
4. Implement
- Add required controls first. Add conditional controls only for capabilities present in the selected scenario.
- Preserve the agent's intended behavior. Do not refactor unrelated code as part of production hardening.
- Add or update tests and operations documentation with each control. Keep secrets and sensitive user content out of source, generated files, logs, errors, prompts, and telemetry.
5. Verify
- Run the repository-supported build, lint, unit, and integration checks that apply to the changed Agents SDK code.
- Exercise failed production configuration, authentication rejection, issuer and audience/lifetime rejection, applicable caller authorization, service URL claim and outbound-host validation, payload rejection, safe errors, probes, graceful shutdown, and telemetry shutdown/redaction.
- Validate state recovery and conflict handling only when state exists. Validate conditional controls only for capabilities in scope.
- Separate local verification from deployed evidence. Do not claim that a control is verified when its required environment was not exercised.
6. Handoff
Report:
- The selected deployment boundary and current maturity state.
- Controls verified with file, test, deployment, or operator evidence.
- Controls implemented but not verified in the required environment.
- Missing or blocked controls and their production impact.
- Controls marked not applicable and why.
- The next deployment, smoke-test, rollback, and operations actions.
Keep this assessment current through follow-up discussion. Answer questions without losing the selected boundary, decisions, statuses, or next phase.
Maturity states
- Code-hardened: applicable source controls exist and local checks pass.
- Deployment-ready: infrastructure, production configuration, smoke tests, rollback, and operator documentation exist.
- Production-verified: the deployed environment has passed authentication, state recovery where applicable, telemetry, alert, traffic-protection, smoke, and rollback checks.
Language invariants
- For aiohttp, use SDK JWT middleware/decorators exactly once on protected routes. Keep health endpoints outside authentication and explicitly protect new custom routes.
- Set
AgentAuthConfiguration.validate_issuer=True, require exact audience and expiration, disable anonymous production access, and select the expected token family, tenant and cloud. Authorize verifiedclaims_identitycaller claims for trusted-app endpoints before adapter processing. - Verify the issuers actually accepted by the installed SDK. Its trusted
first-party Entra issuers can extend the configured issuer list. For the bounded
public-cloud Bot Framework profile, additionally require the verified
claims_identityissuer to equalhttps://api.botframework.comafter JWT validation and before adapter processing. Other profiles need their own issuer policy; do not apply this Bot-only restriction to trusted-app endpoints. - Pass
OutboundHostValidatorexplicitly toCloudAdapter. Confirm downloader support before sharing it; host suffix validation alone does not provide DNS or arbitrary-client protection. - Use the Blob service URL (not container URL) with
BlobStorageConfigand async credentials. The released SDK overwrites state unconditionally; use the reference's ETag wrapper or an equivalent durable concurrency-safe provider when needed. - Preserve async cleanup: drain aiohttp, close clients/credentials, then flush telemetry. Verify published package versions and deployment wheel hashes.
Shared invariants
- Production state that must survive turns/restarts/replicas requires a durable store. Stateless agents do not need a state provider.
- Wildcard connection selection is not authorization. Keep exact audience, verified issuer/caller checks, and outbound policy.
- Validator host entries can allow subdomains. Exact channel middleware and arbitrary-client/network controls remain separate decisions.
- Health endpoints may be anonymous; routes with mutations/downstream access require authentication and applicable authorization.
- Caller-aware edge protection, deployed alerts, recovery and rollback require environment evidence. Do not certify a deployment from sample code.
- Keep secrets, tokens, prompts/messages and unnecessary identity attributes out of errors, logs, generated artifacts and telemetry.
04 同仓库更多 Skills
sync-teams-samples-to-agents-sdk
CI instructions for a bounded Teams SDK to Agents SDK sample synchronization using the selected language profile.
teams-sdk-to-agents-sdk-typescript-migration
Migrate a JavaScript or TypeScript application using the Microsoft Teams SDK App runtime to Microsoft 365 Agents SDK while preserving its Teams behaviors. Use for Teams SDK migrations, including automated sample synchronization; use the separate Bot Framework migration skill for botbuilder applications.
Teams 应用清单创建与审核
teams-app-manifest
为现有的 Microsoft 365 Agents SDK 应用程序创建或审核 Microsoft Teams 应用清单,方法是将声明的意图和源代码证据映射到已发布清单所支持的能力。适用于 manifest.json 缺失、不完整,或需要对照已实现的 Teams 功能进行核查的情况。除非另行要求,否则不配置 Microsoft Entra、Azure Bot、开发者门户(Developer Portal)或部署。
Agents SDK Azure 资源预配
agents-sdk-provision
在为 Microsoft Agents SDK 应用预配 Azure 资源时使用——包括创建 Azure Bot Service 资源、设置 Entra 应用注册、配置身份凭据(UserManagedIdentity、FederatedCredentials 或 ClientSecret)、添加 Teams 频道、运行 Bicep 部署以实现 SSO,或通过 az CLI 设置 OAuth 用户登录连接。即使用户没有说“预配”也应触发——在诸如“在 Azure 上搭建我的机器人”“部署我的机器人”“为我的机器人配置 Azure”“让 Teams SSO 跑起来”等请求时使用。适用于所有语言(dotnet、Node.js、Python)。
Agents SDK Python 可观测性配置
agents-sdk-python-otel
用于为 Python 版 Microsoft 365 Agents SDK 应用添加、配置、验证或排查 OpenTelemetry 可观测性。当用户提及 OpenTelemetry、OTel、遥测、traces、metrics、logs、OTLP、Aspire Dashboard、Application Insights、Azure Monitor、分布式追踪、自定义 tracer 或 meter、span 采样,或观测 microsoft_agents SDK 信号时触发。
Teams SDK 至 Agents SDK 迁移
teams-sdk-to-agents-sdk-dotnet-migration
用于将客户的 Teams SDK(teams.net)机器人迁移到 .NET 平台的 Microsoft 365 Agents SDK。当项目依赖 Microsoft.Teams.Plugins.AspNetCore、Microsoft.Teams.Apps 或 Microsoft.Teams.Api 并调用 builder.AddTeams() / app.UseTeams() 时触发。