flightlesstux/agents-on-call
GitHub: flightlesstux/agents-on-call
基于 AWS Bedrock 和 Strands Agents SDK 构建的运维事件响应多 Agent 参考架构,以只读默认值和人工审批门控为核心设计理念。
Stars: 0 | Forks: 0
# Agents 待命
本代码库包含了 [ercan.ai](https://ercan.ai) 上“Agents on Call”系列的配套代码。它记录了一个用于运维事件响应的多 Agent 平台,该平台基于 AWS Bedrock 和 Strands Agents SDK 构建。
场景设定:一家中型 B2B SaaS 公司拥有约 50 名工程师和约 30 个 AWS 账户,需要更快的事件分诊和响应。自动化 Agent 代替直接呼叫待命人员的做法,负责处理第一道流程:收集上下文、检查 runbook、优化受影响工作负载的成本,并通过 Slack 向人类呈现决策树。这些 Agent 本身在默认情况下是只读的;每一个改变状态的操作都处于由人类操作的审批门控之后。
这是一个教育性质的参考架构,不能直接用于生产环境部署。护栏、审批门控和只读默认值的模式可以推广到各个组织,但在投入生产环境使用之前,需要针对特定组织进行强化。
## 架构

- **Hub-and-spoke AWS Organizations。** 一个管理账户持有 SCP 且不包含任何工作负载。一个安全账户持有 CloudTrail、GuardDuty 和 Security Hub 的委派管理员权限。大约 30 个工作负载账户作为分支,每个账户向 ops-tooling 账户暴露一个 `ops-readonly` 角色和一个单独的 `ops-mutate` 角色。
- **ops-tooling 账户是整个平台。** EventBridge 和一个 Slack 应用(API Gateway)是两个入口点。AgentCore Runtime 托管四个 Strands Agent:supervisor、incident-triage、runbook 和 cost。
- **模型层。** Bedrock 通过跨区域推理配置文件实现,每次调用都带有 Bedrock Guardrails,并为分诊和 runbook Agent 提供基于 runbook 语料库的 Knowledge Base。
- **工具层在构建上即是只读的。** AgentCore Gateway 暴露了四个 Lambda:`cloudwatch-read`、`logs-read`、`cost-read` 和 `ssm-execute`。前三个 Lambda 在目标分支中扮演 `ops-readonly` 角色。`ssm-execute` 是唯一的变更工具,且它无法直接触达分支。
- **审批门控与可观测性。** 变更提案会在 Step Functions 中通过 `waitForTaskToken` 暂停,将完整上下文发布到 Slack,并且仅在人类批准后才会继续;只有批准后的执行器 Lambda 可以扮演 `ops-mutate`。CloudWatch、S3 调用日志和 AWS Budgets 负责监控平台本身。
上面的图表是一个渲染的快照(`docs/img/topology.py`,使用 `diagrams` 库和官方 AWS 图标构建)。[`docs/architecture.md`](docs/architecture.md) 中的 Mermaid 图表是事实来源,它们更详细地逐个账户和逐层进行解析,其中包括 Well-Architected 映射。
## 博客系列
| # | 日期 | 标题 | 链接 |
|---|------|-------|------|
| 1 | 2026-05-28 | 场景:为什么运维团队需要雇佣 Agent | [ercan.ai/agents-on-call-part-1-the-scenario](https://ercan.ai/agents-on-call-part-1-the-scenario/) |
| 2 | 2026-06-04 | 基础:Terraform 先于 Token | [ercan.ai/agents-on-call-part-2-terraform-before-tokens](https://ercan.ai/agents-on-call-part-2-terraform-before-tokens/) |
| 3 | 2026-06-11 | 第一个 Agent:Strands 中的事件分诊 | [ercan.ai/agents-on-call-part-3-incident-triage-strands](https://ercan.ai/agents-on-call-part-3-incident-triage-strands/) |
| 4 | 2026-06-18 | 工具与 Gateway:MCP、白名单与只读默认值 | [ercan.ai/agents-on-call-part-4-gateway-read-only-default](https://ercan.ai/agents-on-call-part-4-gateway-read-only-default/) |
| 5 | 2026-06-25 | 团队:Supervisor 与三名专家 | [ercan.ai/agents-on-call-part-5-supervisor-three-specialists](https://ercan.ai/agents-on-call-part-5-supervisor-three-specialists/) |
| 6 | 2026-07-02 | 护栏:所有人都跳过的部分 | [ercan.ai/agents-on-call-part-6-bedrock-guardrails](https://ercan.ai/agents-on-call-part-6-bedrock-guardrails/) |
| 7 | 2026-07-02 | 容量规划:无人提前做的 Token 计算 | [ercan.ai/agents-on-call-part-7-sizing-token-math](https://ercan.ai/agents-on-call-part-7-sizing-token-math/) |
| 8 | 2026-07-16 | 生产环境:可观测性、评估与系统撒谎的那一天 | [ercan.ai/agents-on-call-part-8-observability-evals](https://ercan.ai/agents-on-call-part-8-observability-evals/) |
## 代码库结构
```
terraform/
00-foundation/ org accounts, spoke IAM roles, model access -> Part 2
10-agent-runtime/ AgentCore Runtime, all four agents + cost schedule -> Part 3, Part 5
20-gateway-tools/ AgentCore Gateway, the four tool Lambdas -> Part 4
30-guardrails/ Bedrock Guardrails, denied topics, PII masking -> Part 6
40-observability/ OTEL, CloudWatch dashboards, Budgets, DLQs -> Part 8
agents/
supervisor/ routes to triage, runbook, cost -> Part 3, Part 5
triage/ first agent, evidence-first incident triage -> Part 3
runbook/ runbook lookup against the Knowledge Base -> Part 5
cost_optimizer/ daily cost sweep agent -> Part 5
tools/ shared tool implementations behind the Gateway -> Part 4
docs/
architecture.md Mermaid source of truth for account and layer topology
sizing-model.md token math, quota ceilings, provisioned throughput breakeven -> Part 7
img/topology.py, topology.png this README's rendered AWS diagram
evals/ golden-set eval harness, CI gate on agent behavior -> Part 8
```
## 前置条件
- Terraform >= 1.9
- Python >= 3.12
- 拥有 Bedrock 访问权限的 AWS 账户(Claude 3 模型)
- Strands Agents SDK Python 包
每个部分都是独立的,可以单独部署。第 2 部分奠定了基础;第 3 到第 5 部分添加了 Agent 和控制措施;第 6 到第 8 部分进行了生产环境强化。
## 许可证
MIT,版权所有 2026 Ercan Ermis。
标签:AI智能体, AWS, DLL 劫持, DPI, 参考架构, 大语言模型, 用户代理, 运维自动化, 逆向工具