rdxsai/sreagent

GitHub: rdxsai/sreagent

Sentinel 是一个基于 OpenTelemetry 遥测数据的自主 SRE 事件响应 agent,能够从告警出发自动追踪微服务故障根因并生成结构化报告。

Stars: 0 | Forks: 0

# Sentinel 一个自主的 SRE 事件响应 agent。给定一个触发的告警,它会调查已记录的微服务遥测数据,将症状追踪至其根本原因,并生成结构化的事件报告。它能解决六个已记录的事件,并附带 181 个单元测试和集成测试。 Sentinel 运行在一个基于 OpenTelemetry Demo 构建的、密封且可重放的遥测环境中:一个已知故障被注入到某个服务中,它产生的真实 traces、metrics 和 logs 被捕获,并将结果写入作为 agent 调查的 fixture。agent 仅读取公开的遥测数据;ground truth 被单独保存且仅用于评分。 ## 它的功能 - 一个 manager agent 对事件进行分类(它构建依赖图、查找 onset 并定位故障),然后委派给隔离的 investigator subagent,每个 subagent 深入调查一个候选服务并返回类型化的 finding,manager 随后将其调和为一份 root-cause 报告。 - 跨越十个 namespace(traces、metrics、logs、changes、correlate、topology、hypothesis、investigate、report、runbook)的 50 个工具,通过带有模型驱动选择和类型化、可组合的 Pydantic 输入输出的 decorator 和 schema registry 暴露。 - 生产环境脚手架:带 backoff 的 retries、rate limiting、类型化的 errors、结构化 logging,以及一个确定性的 hooks 层(leak-safety seal、tool-call budget、report gate、finding validation)。 - 一个评估工具,它根据密封的 ground truth 对每次运行进行评分,并报告跨重复次数的 pass@k。 - 一个实时 Web demo,它逐个 token 流式传输 agent 的推理、tool calls 和嵌套的 subagent 调查。 ## 快速开始 前置条件:Python 3.11+、Node 18+(用于 demo 前端)以及 Anthropic API key。 安装: ``` python -m venv .venv && source .venv/bin/activate pip install -e ".[dev]" echo "ANTHROPIC_API_KEY=sk-..." > .env ``` 运行测试: ``` scripts/test # or: python -m pytest tests/ ``` 运行评估(agent 调查已记录的事件并根据 ground truth 进行评分): ``` scripts/eval # all six incidents scripts/eval payment_failure_001 # one incident SENTINEL_EVAL_REPEATS=3 scripts/eval # reliability: pass@k over repeats ``` 运行实时 demo: ``` cd frontend && npm install && npm run build && cd .. scripts/server # serves the app + API at http://localhost:8000 ``` 打开 http://localhost:8000,选择一个事件,观看 agent 实时调查。要进行具有热重载的前端开发,请运行 `scripts/server`,并在第二个终端中在 `frontend/` 内运行 `npm run dev`(Vite 代理 API)。 ## 工作原理 记录 pipeline (`labs/otel`) 在自驱动的负载下运行固定 commit 版本的 OpenTelemetry Demo,在已知的 onset 处注入一个 feature flag,从 Prometheus(metrics)、Jaeger(traces)和 OpenSearch(logs)捕获遥测数据,运行一个触发单个 UserFacingDegradation 告警的告警层,并写入密封的 fixture:`public/` 供 agent 使用,`eval_only/` 供评分器使用。六个已记录的事件位于 `fixtures/` 中。 agent runtime (`sentinel/agent`) 是纯异步 Python:一个共享的 hooked loop 驱动 manager 和 investigator subagent。运行 agent 和 demo 仅需要已提交的公共 fixture;评分器还会额外读取仅用于评估的 ground truth,它被 seal 置于版本控制之外;只有重新记录新的 fixture 才需要实时 demo。 ## 项目结构 ``` sentinel/agent/ manager + investigator loop, hooks, events, runner sentinel/tools/ the 50 tools, the fixture store, typed I/O models sentinel/registry/ the decorator and schema tool registry sentinel/api/ FastAPI app: the /demo SSE stream and the alert webhook sentinel/fixtures/ fixture schemas and replay sentinel_tool_eval/ the evaluation harness and grader labs/otel/ the OpenTelemetry recording pipeline fixtures/ the six sealed incident fixtures (public telemetry) frontend/ the React and Vite demo UI tests/ unit and integration tests ``` ## 设计 请参阅 [MEMO.md](MEMO.md) 了解构建了什么、删减了什么、如果有更多时间会解决什么问题,以及设计决策和选择它们而非其他替代方案的原因。
标签:AI智能体, API集成, GET参数, OpenTelemetry, SRE, 偏差过滤, 可观测性, 根因分析, 用户代理, 自定义请求头, 运维自动化, 逆向工具