Skip to main content
这是内部开发笔记,不对外公开。

设计理念

核心原则:Less is more Data Steward 的使命:
  1. 学习 - 理解业务数据含义
  2. 发现 - 找到有趣的模式/异常
  3. 协作 - 与用户定义规则
  4. 交接 - 触发 Analysis Agent 深入调查
不做的事
  • ❌ KPI 监控(用户有 dashboard)
  • ❌ 数据质量检查(有专门工具)
  • ❌ Schema 变更检测(data engineering 的活)
  • ❌ 定时任务调度(ops 的活)

存储架构

纯 Markdown,没有 SQLite。
/data/memory/
├── context.md               # 业务上下文(公司、目标、已知模式)
├── rules.md                 # 用户定义的关注规则
├── understanding/           # 对每个数据源的理解
│   └── {conn_id}.md
├── discoveries/             # 发现的东西
│   └── {timestamp}_{slug}.md
├── requests/                # 交给 Analysis Agent 的请求
│   └── {id}.md
├── briefings/               # 给用户的摘要
│   └── latest.md
└── docs/
    └── guide.md             # Agent 指南

文件格式

context.md

业务上下文,帮助 Agent 理解整体背景:
# Business Context

## Company
电商公司,主营服装和配饰,B2C 模式

## What Matters
- GMV 增长
- 用户留存
- 客单价提升

## Known Patterns
- Black Friday 销售额是平时 3x
- Q4 是最大季度
- 周末订单比工作日高 20%

## Notes
正在拓展 B2B 业务线

rules.md

用户定义的关注规则:
# Watch Rules

## Active Rules
- [ ] 日收入下降超过 15%
- [ ] 订单取消率超过 5%
- [ ] 出现异常大单(>$10,000)

## Recently Triggered
- [x] 收入下降 → discoveries/2024-01-15_revenue_drop.md

understanding/{conn_id}.md

对每个数据源的完整理解:
# orders_db

## Overview
电商订单数据,包含订单、用户、商品信息。

## Key Tables
- orders: 订单记录
- users: 用户信息
- products: 商品目录

## Key Fields
- orders.total_amount: 订单金额(含税)
- orders.status: PENDING → PAID → SHIPPED → COMPLETED

## Business Context (Confirmed)
- 大促后通常有 10-15% 自然回落
- 周末订单量比工作日高约 20%

## Data Quirks ⚠️
重要的数据陷阱,避免重复踩坑:
- customer_id 为 NULL 表示游客订单
- status='PENDING_V2' 是历史遗留,等同于 'PENDING'
- 2020年前的数据用 UTC+8 时区

## Useful Patterns
有用的查询模式:
- 日收入:SELECT date, SUM(amount) FROM orders GROUP BY date
- 活跃用户:SELECT COUNT(DISTINCT user_id) FROM events WHERE date = today

## Open Questions
- discount_type 字段的含义?
- 为什么有些商品库存是负数?

discoveries/{timestamp}_{slug}.md

发现的东西,用 frontmatter 标记状态:
---
status: new
type: anomaly
connection_id: orders_db
---

# 11月收入下降 12%

## What I Found
11月收入 $125k,比10月 $142k 下降 12%。

## Evidence
- 订单量持平
- 客单价下降 10%
- 大单数量减少 42%

## Possible Explanations
1. 大促结束效应
2. B2B 订单减少
3. 季节性?

## Suggested Action
需要深入调查,已创建分析请求。
Status: newinvestigatingconfirmeddismissed

requests/{id}.md

交给 Analysis Agent 的请求:
---
status: pending
discovery: 2024-01-15_revenue_drop
---

# 调查11月收入下降

## Question
11月收入下降 12%,为什么?是问题还是正常现象?

## Context
见 discoveries/2024-01-15_revenue_drop.md

## For Analysis Agent
1. 是否季节性模式?
2. 什么导致客单价下降?
3. 为什么大单减少?

## Result
(Analysis Agent 完成后填写)

Agent 工作流程

读取 context.md(了解业务背景)

读取 understanding/(已有知识)

探索数据 (sample, query)

检查 rules.md(用户规则)

发现有趣的东西?
        ↓ Yes
写入 discoveries/

需要深入调查?
        ↓ Yes
创建 requests/

更新 briefings/latest.md

继续探索...

消息系统

只有两种消息:
  1. 初始消息 - 首次启动时
  2. 继续消息 - 之后一直发 “Continue”
Agent 自己决定做什么,不需要复杂的消息编排。

与 Analysis Agent 的交接

Continuous Learning Agent          Analysis Agent
        │                               │
        │  发现异常                      │
        │      ↓                        │
        │  创建 requests/{id}.md        │
        │      ↓                        │
        │  (status: pending)            │
        │      ↓                        │
        └──────────────────────────────→│

                                   读取请求

                                   深入调查

                                   填写 Result

                                   更新 status

代码位置

组件文件
Agent 指南prompts_steward.pyGUIDE
继续消息prompts_steward.pyCONTINUE_MESSAGE
初始消息prompts_steward.pybuild_initial_message()
目录初始化modal/agent.py_init_memory_structure()
指南写入modal/agent.py_init_guide()

设计决策

选择原因
纯 MarkdownAgent 自然读写,人类方便检查
没有 SQLite不需要复杂查询,避免双存混乱
context.md业务上下文帮助解读数据
Data Quirks section避免重复踩坑,累积知识
合并 quirks/patterns 到 understanding减少文件数,集中维护
没有任务调度Agent 自己决定做什么
聚焦发现这是我们的差异化价值

差异化定位

现有工具做什么SkoutLab
Dashboard展示你定义的指标发现你没想到的指标
监控告警基于规则触发自动学习什么是异常
BI 工具回答已知问题发现未知问题
SkoutLab 的定位:发现你不知道要问的问题。