数据与AI
需要查看 Cargo 运行成功/错误指标并导出运行…
当需要从 Cargo 统计运行或批次指标、下载 run 输出,或导出 segment/model 数据时使用。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 60/100 ×0.15
适用场景
需要查看 Cargo 运行成功/错误指标特定
解决思路
- 若 `cargo-ai whoami` 已返回 workspace,说明已登录,跳过 Bootstrap。
- 安装 CLI:`npm install -g @cargo-ai/cli`;若不能全局安装,则每条命令前加 `npx @cargo-ai/cli`。
- 登录:`cargo-ai login --email you@company.com`(邮件验证码,无需浏览器,首次使用会创建账号);也可用 `--oauth`(浏览器)或 `--token <api-token>`(CI)。
- 在执行任何写入前用 `cargo-ai whoami` 确认当前 workspace。
- 所有命令把 JSON 打印到 stdout;失败时非零退出并返回 `{"errorMessage": "..."}`。
- 任何创建 run 或 batch 的操作都是异步的,传 `--wait-until-finished` 或轮询对应的 `get`。
- 如果安装了完整 skill bundle,查看 `../cargo/references/prerequisites.md` 获取 CLI 版本固定、token 权限范围和仅管理员可用的表面。
- 先发现资源,因为多数 analytics 命令需要 UUID。
- 列出所有 plays:`cargo-ai orchestration play list`(name, workflowUuid)。
- 列出所有 tools:`cargo-ai orchestration tool list`(name, workflowUuid)。
- 列出所有 workflows:`cargo-ai orchestration workflow list`(仅 uuid,无 name)。
- 列出所有 agents:`cargo-ai ai agent list`(uuid, name)。
- 列出所有 connectors:`cargo-ai connection connector list`(uuid, name, integrationSlug)。
- 列出所有 models:`cargo-ai storage model list`(uuid, name, slug)。
- 快速参考命令:`cargo-ai orchestration run get-metrics --workflow-uuid <uuid>`。
- 快速参考命令:`cargo-ai orchestration run download --workflow-uuid <uuid> --is-finished`。
- 快速参考命令:`cargo-ai orchestration run count --workflow-uuid <uuid> --statuses error`。
- 快速参考命令:`cargo-ai orchestration query execute "SELECT status, count() FROM runs GROUP BY status"`。
- 快速参考命令:`cargo-ai segmentation segment download --model-uuid <uuid> --filter '{"conjonction":"and","groups":[]}'`。
- 选择命令:`run get-metrics` / `run count` 是 workflow 范围内的预定义聚合,已有 `workflowUuid` 时最佳。
- 选择命令:`orchestration query execute` 是整个 workspace 的临时 SQL(覆盖 `runs`、`batches`、`spans`、`records`),适合跨 workflow 分析、按节点拆分和时间序列。
- 选择命令:`run download` / `run download-outputs` 用于逐 record 输出检索。
- 选择命令:`segment download` / `storage query execute` 用于存储数据(Companies、Contacts 等)。
- 获取 workflow run 聚合指标:`cargo-ai orchestration run get-metrics --workflow-uuid <uuid>`。
- 按 release 限定指标:`cargo-ai orchestration run get-metrics --workflow-uuid <uuid> --release-uuid <uuid>`。
- 按 batch 限定指标:`cargo-ai orchestration run get-metrics --workflow-uuid <uuid> --batch-uuid <uuid>`。
- 按日期范围限定指标:`cargo-ai orchestration run get-metrics --workflow-uuid <uuid> --created-after <start-date> --created-before <end-date>`。
- 统计匹配条件的 run 数量:`cargo-ai orchestration run count --workflow-uuid <uuid> --statuses error`。
- 统计已完成 run:`cargo-ai orchestration run count --workflow-uuid <uuid> --is-finished --created-after <start-date> --created-before <end-date>`。
- 统计某个 batch 的 run:`cargo-ai orchestration run count --workflow-uuid <uuid> --batch-uuid <uuid>`。
- `run count` 支持:`--statuses`、`--batch-uuid`、`--release-uuid`、`--is-finished`、`--created-after`、`--created-before`、`--record-id`、`--record-title`。
- 对于跨 workflow 分析或 `run count` 未暴露的形状(按节点失败拆分、p95 时长、随时间变化的错误率),使用 `orchestration query execute`。
- 用 `orchestration query execute` 对运行时表 `runs`、`batches`、`spans`、`records` 执行 SQL;表名不加 schema 前缀,workspace 自动限定。
- 查 workspace 最近一天错误率:`cargo-ai orchestration query execute "SELECT countIf(status='error') / count() AS error_rate FROM runs WHERE created_at > now() - INTERVAL 1 DAY"`。
- 查本周各 workflow 失败 run:`cargo-ai orchestration query execute "SELECT workflow_uuid, count() AS errors FROM runs WHERE status='error' AND created_at > now() - INTERVAL 7 DAY GROUP BY workflow_uuid ORDER BY errors DESC"`。
- 查最近 24h 各节点失败数:`cargo-ai orchestration query execute "SELECT node_slug, count() AS failures FROM spans WHERE execution_status='error' AND execution_started_at > now() - INTERVAL 1 DAY GROUP BY node_slug ORDER BY failures DESC"`。
- 查本月各 workflow credit 花费:`cargo-ai orchestration query execute "SELECT workflow_uuid, sum(credits_used_count) AS credits FROM batches WHERE created_at >= toStartOfMonth(now()) GROUP BY workflow_uuid ORDER BY credits DESC"`。
- `orchestration query execute` 只读且有限制:30s 执行时间、10000 结果行、10000000 扫描行;用 `created_at`/`execution_started_at` 条件缩小范围。
- 下载 run 结果时区分两个命令:`run download` 是每 run 一行、每 node 一列(gzipped CSV)。
- `run download` 返回 `{"url": "..."}`,即 gzipped CSV 的签名 URL;每行是 run:`_uuid`、`_workspace_uuid`、`_workflow_uuid`、`_record_id`、`_record_title`、`_created_at`、`_finished_at`、`_status`、`_error_message`,后面每个 node slug 一列。
- `run download` 的每个 node 列保存该执行的 `title`,是截断的人类可读摘要,不是 node 输出;文件里没有 `runContext` 和 `executions[]`;把它当跨多个 run 的状态板,不要当 node 产出证据。
- `run download` 下载 workflow 全部 run:`cargo-ai orchestration run download --workflow-uuid <uuid>`。
- `run download` 按日期范围:`cargo-ai orchestration run download --workflow-uuid <uuid> --created-after <start-date> --created-before <end-date>`。
- `run download` 按特定状态:`cargo-ai orchestration run download --workflow-uuid <uuid> --statuses success,error`;run 状态为 idle、pending、running、success、error、cancelling、cancelled、skipped,不是 finished/failed。
- `run download` 下载所有到达终态的 run:`cargo-ai orchestration run download --workflow-uuid <uuid> --is-finished`;`--is-finished` 是 `finished_at IS NOT NULL`,比 success+error 更宽,cancelled 和 skipped 也会标记 finishedAt,不要互相替代。
- `run download` 从特定 batch:`cargo-ai orchestration run download --workflow-uuid <uuid> --batch-uuid <uuid>`。
- `run download-outputs` 是获取平台内 action 结果的规范方式,映射 API `POST /v1/orchestration/runs/download-outputs`;返回 `{"url": "..."}`,即 CSV(默认)或 JSON 文件的签名 URL。
- `run download-outputs` 每 run 一行:同样 `_` 前缀 run 元数据,加上 `input`(第一个 node 的解析后配置)和 `output`(所选 node 的 context;省略 `--output-node-slug` 时默认最后执行的 node)。
- `run download-outputs` 基本用法:`cargo-ai orchestration run download-outputs --workflow-uuid <uuid> --format json --limit 20`;`--workflow-uuid` 是唯一必填 flag。
- `run download-outputs` 固定输出 node 并按 batch 过滤:`cargo-ai orchestration run download-outputs --workflow-uuid <uuid> --output-node-slug <slug> --batch-uuid <uuid>`。
- 找 `output-node-slug`:`cargo-ai orchestration release get <release-uuid>`,查看 `nodes[].slug`;终端输出 node 通常名为 `output` 或 `end`。
- `run download-outputs` 不传 `--limit` 会覆盖 workflow 所有匹配 run,只需要样本时传 `--limit`。
- 按 record 而非按 run:`cargo-ai orchestration record download-outputs` 接受相同 `--workflow-uuid` / `--output-node-slug`,每 record 一行;用 `--limit` 和 `--offset` 分页(CLI ≥ 1.0.90)。
- 导出过大的集合时,用固定切片遍历:先 `--limit 1000 --offset 0`,再 `--offset 1000`,依此类推;`run download-outputs` 也按相同方式分页,只是分页对象是 run。
- 要获取多个 run 的完整 `runContext`,不能一次调用完成;完整 per-node context 是 per-run S3 object,只有 `orchestration run get <run-uuid>` 会 hydrate,一次一个 run。
- 上述两个导出都是投影:`download` 给出多个 run 的 node title;`download-outputs` 给出首个 node 的 input + 一个 node 的 output;要中间全部内容,循环 `run get`,UUID 从 `../cargo-diagnostics/references/run-trace.md` §0 的发现阶梯获取。
- Orchestration SQL 不能替代完整 runContext:`runs` 和 `spans` 有 status、timing、credits,但没有 node input/output 列。
- 下载 batch 结果:`cargo-ai orchestration batch download --uuid <batch-uuid> --output-node-slug <node-slug>`。
- 找 batch 的 `output-node-slug`:先 `cargo-ai orchestration batch get <batch-uuid>` 获取 release UUID,再 `cargo-ai orchestration release get <release-uuid>` 查看 `nodes[].slug`。
- 处理部分 batch 失败:batch 的 `status: success` 仍可能包含单个 run 失败;在把结果当作完整前总是检查 batch 错误。
- Step1 检查 batch 摘要:`cargo-ai orchestration batch get <batch-uuid>`,读取 `.runsCount`(提交总记录)、`.executedRunsCount`(到达终态的记录)、`.failedRunsCount`(报错记录)。
- Step2 统计失败 run:`cargo-ai orchestration run count --workflow-uuid <uuid> --batch-uuid <batch-uuid> --statuses error`。
- Step2 下载失败 run:`cargo-ai orchestration run download --workflow-uuid <uuid> --batch-uuid <batch-uuid> --statuses error`。
- Step3 诊断:分析为什么失败、按根因分组、选样 run、读取 `runContext` 是 `cargo-diagnostics` 的职责;加载 `../cargo-diagnostics/references/batch-error-sweep.md` 并传入 batch UUID。
- Step4 只重跑失败记录:在诊断并修复底层问题(connector 凭据、坏输入数据、限流)后,从失败 run 下载中提取 record IDs,然后 `cargo-ai orchestration batch create --workflow-uuid <uuid> --data '{"kind":"recordIds","recordIds":["id1","id2","id3"]}'`。
- 按 node output slug 过滤:先从 batch 获取 release UUID(`batch get` → `.releaseUuid`)。
- 按 node output slug 过滤:再找 node slug(`release get` → `nodes[].slug`)。
- 按 node output slug 过滤:最后下载该 node 的输出(`cargo-ai orchestration batch download --uuid <batch-uuid> --output-node-slug <node-slug>`)。
- 导出 segment 数据:filter JSON 使用 `conjonction`(不是 `conjunction`),这是有意为之;完整语法见 `cargo-orchestration` skill 的 `references/filter-syntax.md`。
- 全量导出:`cargo-ai segmentation segment download --model-uuid <uuid> --filter '{"conjonction":"and","groups":[]}'`。
- 带排序和限制导出:`cargo-ai segmentation segment download --model-uuid <uuid> --filter '{"conjonction":"and","groups":[]}' --sort '[{"columnSlug":"created_at","kind":"desc"}]' --limit 1000`。
- 重要:`segment download` 需要 `--model-uuid`,不是 `--segment-uuid`;从 `segment list` 获取 `modelUuid`。
- 需要实时分页查询并 enrichment 时,使用 `cargo-orchestration` skill 的 `segmentation segment fetch`。
- 每个命令支持 `--help`,例如 `cargo-ai billing usage get-metrics --help`、`cargo-ai orchestration run download --help`、`cargo-ai segmentation segment download --help`。
适用边界 · 注意事项
- 当问题变成“为什么”时(为什么这个 run 失败、为什么输出错误或为空、哪个根因解释这些错误、为什么这个 play 很贵),不要用本技能,改用 `cargo-diagnostics`。
- 当询问 credits、套餐、发票、订阅或用量计费时,不要用本技能,改用 `cargo-billing`。
- 未安装 `@cargo-ai/cli`、未登录 Cargo 账号或没有所需 workspace/权限时不可用;本技能依赖 Cargo 平台与 CLI。