Dudu-0223 6a4ee478d7 perf(client): optimize PTC definition complexity for Chat and Trajectory (#9387)
* perf(client): 让 PTC 嵌套分发折叠保持线性

客户端折叠会话历史时,updateDispatch 对每个 tool/ptc-dispatch-start 与
tool/ptc-dispatch 事件都用 findIndex 查找子调用、复制父调用的整个子节点
数组,并把全部父子关系复制进新的 Map。单个父调用下 n 个子调用因此是
O(n²):一个约 5 万事件、最大扇出约 2 万的 PTC 会话折叠要 8.9 秒,打开
会话时主线程被同步阻塞。

ToolState 改为按 parent/child id 索引的 DispatchTree,updateDispatch 就地
写入内层 Map(替换幂等、首次挂载定序),发布时 projectBlock 再物化数组,
发布出的工具调用树仍是不共享数组的不可变值。

conversation-fold 基准新增 ptc-dispatch-fan-out 用例:2 个根调用各结算
10,000 个嵌套子调用,参考机预期 100 ms(CI 预算 250 ms)。旧实现同一形状
在编译 worker 中耗时 9,295 ms,新实现 51–81 ms。

Refs #9385

* perf(client): 让 Trajectory 的 PTC 分发折叠保持线性

默认启用的 Trajectory Tool Definition 与修复前的 Chat 实现同构:每个
tool/ptc-dispatch[-start] 事件都 indexOf 查找子调用并复制调用 Map,首次挂载
时还复制子节点 Map、父节点 Map 和兄弟列表;根 tool/result 再复制调用 Map,
每次发布重建整棵投影树。Assembler 无论目标是否激活都会更新已注册的
Definition,所以即使只打开 Chat,2 个根调用各 10,000 个子调用的窗口也要
12,228 ms。

ToolState 改为持有就地更新的 DispatchTree(调用 Map、首次挂载顺序的子调用
id 列表、父节点 Map),每个事件 O(1);projectCall 增加按存储块、中断点和
子调用引用缓存的投影,未变化子树复用已发布对象,发布值不与树共享引用。

conversation-fold 的 ptc-dispatch-fan-out 用例在 worker 中注册 Trajectory
Tool Definition 与视图,并分别断言 Chat 与 Trajectory 目标的子调用数和
250 ms 预算。回退 Trajectory 实现时该用例超过 60 秒 worker 时限;修复后
Chat 63–72 ms,Trajectory 60–64 ms。

Refs #9385

* perf(client): 收紧 PTC 分发折叠的状态更新

按评审意见收紧 Chat 与 Trajectory 的 Tool Definition:

- updateDispatch 与 Trajectory 根 result 分支原地修改后返回同一 State,
  不再浅拷贝;start() 仍新建 State。ToolState 与 DispatchTree 去掉
  readonly,JSDoc 引用 Assembler 的 update() 规则,原因链接 Agent Note。
- 删除 Trajectory 的投影缓存及其身份用例,projectCall 与 master 一致,
  每次发布新建投影树。
- 基准两个目标共用一个预算常量,去掉 trajectoryViewDefinition 的类型断言。
- Agent Note 合并修复前后表格并更新为本次实测;统一负向对照数据,
  说明两种树布局的取舍,注明返回同一 State 参考了 #9400。

编译 worker 2×10,000:master 29,176 / 22,483 ms,修复后 58–63 / 53–59 ms
(激活 Chat / Trajectory);只回退 Chat 时门禁测得 9,073 ms 并失败。

Refs #9385
2026-11-27 16:12:10 +08:00
2026-08-13 13:07:24 +08:00

DeepSeek Harness

English | 中文

DeepSeek Harness (dsh) is an open-source agent harness developed by DeepSeek AI.

It is built on an everything-is-a-plugin architecture and powered by Cordis, whose design is described in A Programming Paradigm for Spatiotemporal Composability.

Documentation: https://deepseek-harness.github.io/deepseek-harness/

Developer preview

DeepSeek Harness is in developer preview and iterating rapidly. THERE WILL BE COMPATIBILITY-BREAKING CHANGES.

Review the safety notice before running the project.

Run

Run from npm

Install Node.js, then run:

npx @deepseek-ai/dsh web

The command starts the Web UI at http://127.0.0.1:3080 by default and opens it in the default browser for a local launch. An SSH launch only prints the host URL because the SSH client or editor owns the local forwarded address. Pass --no-open to run the server without opening a browser. See Web UI guide.

Run from source

To run from a repository checkout:

git clone https://github.com/deepseek-ai/deepseek-harness.git
cd deepseek-harness
pnpm install
pnpm run build
pnpm dsh web

pnpm run build prepares the repository artifacts. pnpm dsh web uses those built artifacts without rebuilding.

Community and support

Contributing

See CONTRIBUTING.md.

Development

Start with the development guide and architecture documentation.

pnpm run dev:web builds, serves, and rebuilds client bundles on source edits in one terminal, and make help lists the matching Make targets for Web and Desktop; the guide's application commands section owns the full table.

For agents, follow AGENTS.md.

Citation

@misc{deepseek-harness2026,
  title={DeepSeek Harness: Everything is a Plugin},
  author={DeepSeek-AI},
  year={2026},
  publisher={GitHub},
  howpublished={\url{https://github.com/deepseek-ai/deepseek-harness}},
}

License

MIT

Third-party dependencies and their licenses are disclosed in THIRD_PARTY_NOTICES.md.

S
Description
No description provided
Readme MIT
466 MiB
0 Stars 1 Watchers 1 Forks
Languages
TypeScript 94.6%
CSS 1.3%
JavaScript 1.1%
Python 1%
Swift 0.8%
Other 1.1%