xskill icon indicating copy to clipboard operation
xskill copied to clipboard

design(algorithms): 明确 Trajectory → Atom 与 Atom → Skills 的算法边界

Open tiammomo opened this issue 3 months ago • 6 comments

Problem

xskill 当前通过 TaskAgent、TaskClusterAgent 和 SkillEditAgent 完成从轨迹到 Skill 的处理,但这里实际包含两个不同的算法问题:

  1. Trajectory → Atom:从真实轨迹中抽取稳定、可复用的 Atom;
  2. Atom → Skills:基于 Atom 完成多标签路由、候选证据聚合和 Skill 优化。

两条链路串行依赖,但输入输出、错误类型和评测方法不同。如果同时修改 Atom 抽取与下游 Skill 算法,最终结果发生变化时,很难判断改进或退化来自哪一部分。

#315 和 PR #316 已经建立初步的 Atom 拆分与路由离线回放,但当前 replay 仍把拆分预测和路由预测放在同一套 fixture 中,并使用一个全局 run_manifest。它适合作为起点,还不能完全支持固定一条链路、单独比较另一条链路。

本 Issue 想确认的核心问题是:是否应把这两部分作为两条可独立优化、版本化和评测的算法链路,并以 Atom 作为它们之间的稳定契约。

本 Issue 只讨论算法边界和后续工作的拆分方式,不直接修改生产行为,也不要求在一个 PR 中完成后续优化。

Proposed solution

1. Trajectory → Atom

这一链路只负责从 Trajectory 生成 Atom。主要优化点包括:

  • 区分新目标、继续执行、追问、用户纠正和失败重试,减少误拆分与误合并;
  • 保证覆盖、顺序、源语言和近重复不变量;
  • 提高 intent、summary、used_skills 和终态信息的准确性;
  • 对难以确定的边界保留可评测的不确定信息;
  • 继续采用 LLM 提议语义边界、确定性代码校验和写入的方式。

这一链路独立评测边界 precision/recall/F1、Pk、WindowDiff、coverage、overlap、duplicate rate、源语言一致率和终态提取准确率。

Atom 写入后应作为带版本的上游事实供下游消费。下游如果需要修正 Atom 字段,应通过明确、可追溯的修正阶段完成,不能在路由过程中无版本地改写。

ux_score 是当前需要确认的边界问题。TaskAgent 会生成 ux_score,TaskClusterAgent 又可以通过 score_task 修改它。后续需要决定该分数属于 Atom 抽取、独立 Judge,还是显式的后处理结果。

2. Atom → Skills

这一链路以固定版本的 Atom 为输入,输出 Atom 与 Skill 的关联、候选证据和新的 Skill 版本。

内部包含两个步骤:

  • 路由:召回候选 Skill,保留一个 Atom 支撑多个 Skills 的关系,并为每个 (atom_id, skill) 独立计算 weightscore;
  • SkillEdit:对候选证据去重、处理冲突、合并可复用知识,并生成或更新 SKILL.md。

路由阶段独立评测多标签 precision/recall/F1、Recall@K、多 Skill 关系保留率和 weightscore 校准。SkillEdit 阶段评测证据利用率、重复与冲突处理、版本 churn、触发准确率,以及安装 Skill 后的任务成功率变化。

优化这一链路时应固定 Atom 数据和 Atom 算法版本,避免上游重新拆分影响路由和 SkillEdit 的对比结果。

3. 评测与工作拆分

建议保留三种实验方式:固定 gold Atom 比较 Skill 算法,固定下游算法比较 Atom 抽取,以及运行两条链路的端到端组合检查。

每条链路同时保留 Outcome Evaluation 和 Trajectory Evaluation。Outcome Evaluation 判断输出是否正确,Trajectory Evaluation 检查可观察的工具调用、重复步骤、错误路由、重试、写入结果和终态,不依赖模型隐藏思维链。

后续实现拆成两个主要 Issue/PR 方向:一个专注 Trajectory → Atom,另一个专注 Atom → Skills。分阶段 LLM backend 和运行记录是两条链路共用的支撑能力,适合单独做小 PR。system prompt、toolset 和 Agent 关系配置化可以继续讨论,但不与前两个算法 PR 捆绑。

xskill 继续负责流水线、状态机、重试、事务和写入不变量,模型或 Harness 只负责推理与 workspace 执行。

PR #323 已经处理同次 TaskAgent 运行中的相邻近重复 Atom 和源语言保持。后续工作应在现有 replay 与这些写入不变量上继续扩展,不重复建立同类基础设施。

Decisions requested

  1. 是否认可 Trajectory → Atom 与 Atom → Skills 是两条串行依赖、但可独立优化和评测的算法链路?
  2. 是否同意 Atom 作为两条链路之间的版本化契约,下游不再隐式改写上游事实?
  3. 是否同意路由和 SkillEdit 属于同一条 Skill 学习链路,但分别记录阶段指标?
  4. 是否同意先固定 Atom 优化 Skills,再固定下游算法优化 Atom,最后使用端到端结果检查整体效果?
  5. ux_score 应由 Atom 抽取、独立 Judge 还是显式后处理阶段拥有?

Alternatives considered

继续把 Atom 抽取、路由和 SkillEdit 作为一个整体优化,实现改动更直接,但无法可靠归因,也不利于分别选择模型和控制成本。

把三个 Agent 拆成完全独立的服务会增加状态同步、恢复和事务复杂度。当前更合适的拆分是算法、配置与评测边界,而不是拆散 xskill 的流水线所有权。

tiammomo avatar Aug 24 '26 03:08 tiammomo

AI可能降智了,给出的文字不是很可读的样子呢。 我理解下: 1.当前项目Agent可观测性有问题,我们无法追踪agent的行为,这三个skilleditagent、taskclusterAgent、TaskSplitterAgent的贡献归因其实不太明确。 2.我们应该支持,将每个subagent配置为不同的llmbackend,并且能够支持回退。 3.我们应该将不同的Agent任务benchmark化,并配置好可观测性~

针对第一个问题: 我们Agent开发,衡量效果主要出于两个方向, Outcome Evaluation:看最终结果对不对,任务是否完成。 Trajectory Evaluation:看执行轨迹是否合理,是否存在多余步骤、错误路由、违规动作、重复工具调用等。

目前我们xskill精度打榜的工作,是集中于skill的最终产出效果,但是Agent执行过程是否可信,我们的Agent管线各个部分表现是否合理,其实并没有关注,这就导致了我们提升精度成为了一个难题。

针对第二个问题: 这个可以开一个小pr进行支持~

针对第三个问题: 这个可以配合第一个问题一起来做。

另外的附录: 我觉得我们还应该考虑,将我们的Agent进行配置化,将sysp + tool + subagent抽象出来,这样比改动代码更加高效。 我觉得可以和1、3问题一起做(我比较感兴趣哈哈)

370025263 avatar Aug 24 '26 03:08 370025263

感谢补充,Outcome Evaluation 和 Trajectory Evaluation 的区分把评测问题说清楚了。我重新看了一遍,原 Issue 确实把核心算法问题和支撑设施混在了一起,所以现在把正文收敛为两条链路:

  1. Trajectory → Atom:关注如何从轨迹中抽取边界合理、内容稳定的 Atom;
  2. Atom → Skills:关注如何基于固定版本的 Atom 完成多标签路由、候选聚合和 SkillEdit。

两条链路串行依赖,但应独立版本化和评测,并以 Atom 作为中间契约。优化 Atom 时固定下游算法,优化 Skills 时固定 gold Atom,最后再看端到端结果。这样才能判断变化来自 Atom 抽取,还是来自路由、评分或 SkillEdit。

你提到的 Outcome Evaluation 和 Trajectory Evaluation 会同时用于两条链路。Outcome Evaluation 判断输出是否正确,Trajectory Evaluation 检查可观察的工具调用、重复步骤、错误路由、重试、写入结果和终态。项目已经有 trace 和日志,后续需要补的是可比较的阶段归因和 benchmark,而不是从零开始记录 Agent 行为。

不同阶段配置独立 LLM backend 适合另做一个小 PR,并保留现有 llm、llm_skill 的兼容回退。system prompt、tool 和 Agent 关系配置化也值得继续讨论,但我建议把它作为后续支撑能力,不和这两条算法链路的实现捆绑。配置可以引用经过注册和版本化的 Prompt 与 Toolset,流水线、状态机、事务和写入不变量仍由 xskill 代码负责。

另外,ux_score 当前由 TaskAgent 生成,又可以被 TaskClusterAgent 通过 score_task 修改,这正是两条链路之间字段所有权需要明确的例子。

#327 这次只讨论两条算法链路的边界和后续工作如何拆分,不直接修改生产行为。边界确认后,再分别建立 Atom 抽取、Skill 优化和共用支撑能力的小 Issue/PR。

tiammomo avatar Aug 24 '26 03:08 tiammomo

#347 已实现这里讨论的分阶段 LLM backend 支撑:split、cluster 和 edit 可以独立配置,并保留现有 llm、llm_skill 的兼容继承行为,未配置时生产行为不变。

这个 PR 只解决静态的分阶段 backend 选择,不实现请求失败后的自动 provider failover,因此使用 Refs #327,不会关闭本设计 Issue。

#346 同时补充了 Logical Task 与 Attempt 的固定离线回放基线,可作为后续阶段 benchmark 化和算法归因的可重复对照。

待 #327 对两条算法链路以及 ux_score 的字段所有权达成结论后,再继续拆分生产算法 PR。

tiammomo avatar Aug 25 '26 13:08 tiammomo

This boundary discussion reminds me of the central dogma in reverse: trajectory (raw sensory/transcript data) → atoms (folded protein domains) → skills (differentiated cell function). The key insight from biology is that each layer has its own folding code and quality control — you don't re-fold a domain in the cytosol because a ribosome made it slightly wrong; you chaperone it, tag it, or degrade it. The atom-as-contract proposal is exactly this: atoms are folded domains, downstream routing is the signaling network that assembles them into functional complexes (skills).

One concrete angle I'd like to push on: what if we treat the atom boundary confidence distribution as the actual interface, not a binary atom/split decision? Biology doesn't draw hard lines — splice variants, intrinsically disordered regions, and post-translational modification all create graded functional units. If the Trajectory→Atom pipeline outputs a segmentation graph with confidence-weighted edges (rather than a flat atom list), the Atom→Skills pipeline can make threshold decisions per skill — a narrowly-scoped skill might need high-confidence boundaries, while a broad heuristic skill can tolerate fuzzier atom edges.

This would also make the ux_score question more interesting: instead of asking "who owns the score," we could ask "which layer's quality control does this score represent?" If ux_score is domain-folding quality (did the atom fold cleanly?), it belongs upstream. If it's functional fitness (does this atom contribute usefully to a skill?), it belongs downstream. The two aren't the same — a perfectly extracted atom might be useless for skill formation, and a messy atom might still carry signal.

Has anyone looked at whether boundary uncertainty correlates with downstream routing error? If the correlation is strong, the graded interface pays for itself quickly.

bio1-aws avatar Aug 25 '26 19:08 bio1-aws

感谢建议。 xskill 目前不记录 Atom 边界置信度,所以我们还不能判断它是否会影响下游路由。 下一步先在离线 replay 中记录候选边界和路由结果,看看两者是否相关。 验证前,生产流水线仍输出确定、版本化的 Atom;ux_score 继续表示用户体验和任务结果,weightscore 继续表示 (atom_id, skill) 的支撑强度,暂不引入 per-skill resegmentation 或 segmentation graph。

tiammomo avatar Aug 25 '26 20:08 tiammomo

Q1/Q2 implementation decision confirmed for the next development phase.

  • ux_score belongs to Task Attempt / Outcome evaluation. It must not be used as Atom boundary quality or as Atom-to-Skill support.
  • weightscore remains the (atom, skill) support strength.
  • Atom remains the immutable segmented evidence unit; Task-grounded learning consumes a versioned Logical Task + Attempt + EvidenceRange bundle.
  • Existing Atom ux_score is compatibility input during migration, not the new ownership boundary.

Implementation sequence:

  1. #406 — versioned Task-grounded evidence bundle.
  2. #407 — route and edit Skills from that evidence, with explicit Atom fallback.
  3. #408 — benchmark-agnostic matched Formation recorder.
  4. Q2 continues through #381, #388, #409 and #410.

OfficeQA Full execution is not part of the current phase. The code and evidence contracts must remain benchmark-agnostic.

tiammomo avatar Sep 01 '26 14:09 tiammomo