fix(orchestrator): agent 节点收尾兼容 dsh-session 新 API,修「events is not iterable」 - #128
Merged
Conversation
…rable」 dsh-session 0.1.2-alpha.5(随今晨全局 dsh 0.1.2-alpha.4 升级引入)删除了 Session.events getter,只留 snapshotEvents() 方法。引擎 agent 节点收尾路径 (summarize/countTurns/sumUsage/buildTrace)与轮询看门狗仍裸访问 agent.session.events → undefined → for...of 抛「events is not iterable」, 节点结果整体被吞(无输出、无用量、纯错误串)。轮询 scanEvents 有 catch 静默,收尾路径无保护,故报错只在节点完成时出现。 - lib/index.js:新增 sessionEventsOf(session) 兼容读取——新 SDK 走 snapshotEvents()(try/catch 降级空数组),旧 SDK 回退 .events 数组, 异常形态(session 已释放)给空数组按「无事件」降级;替换全部 8 处 裸 .events 访问(scanEvents/看门狗/summarize×2/sumUsage/countTurns/ buildTrace/replayTrace 的 insp.events 加 Array.isArray 防御) - test/live-trace.test.mjs:新增 2 例——新旧 session 形态取值优先级、 异常形态降级不抛错 验证:orchestrator 30 套全绿(含 live-trace 8 例)、全量 npm test 通过。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
用户报告正在运行的工作流中 agent 节点(3.1-交通停车沿革编制)跑完 112.3s 后报错
events is not iterable:无输出、无用量记录、纯错误串。根因
dsh-session 0.1.2-alpha.5(随今晨 01:54 全局 dsh 0.1.2-alpha.4 升级引入,已实测确认:0.1.0-rc.8 有
get events(),0.1.2-alpha.5 已删除,只留snapshotEvents()方法)删除了Session.eventsgetter。引擎 agent 节点多处裸访问
agent.session.events→ 新 SDK 下是undefined→for...of抛events is not iterable:scanEvents(index.js:1484)有 try/catch 静默——所以节点运行全程看似正常(进度流里轮数/预览全空但不报错)summarize(1599)第一个裸迭代即抛,节点结果(输出/用量/turns/trace)整体被吞——这正是用户看到的症状方案
sessionEventsOf(session)兼容读取:新 SDK 走snapshotEvents()(try/catch 降级空数组,覆盖 session 已释放形态),旧 SDK 回退.events数组;persistence.load回放的insp.events加Array.isArray防御.events访问(scanEvents/看门狗/summarize×2/sumUsage/countTurns/buildTrace/replayTrace)'(agent 无输出)'),不再吞掉整个节点验证
npm test通过运维说明
正在跑的工作流里已报错的节点需重跑(断点续跑即可);dsh 进程须彻底重启后插件 HMR 才会加载新代码(
pkill -f 'dsh web'后重启)。