feat(core): 主循环报告运行阶段 RunPhase,控制台终端页按它显示状态 - #181
Merged
Merged
Conversation
Phantivia
force-pushed
the
feat/run-phase
branch
from
October 6, 2026 03:33
0f186d4 to
38ec8ef
Compare
- RunPhase 的 state 为 idle、delivering、model、tools、backoff、handoff,带本批轮序号、 执行中的工具名(含流式提前执行的调用)、backoff 的 retryAt 与进入时刻;getStatus().phase 返回当前值。 - state 或 round 改变、工具开始或结束时,同步通知可见 World 的 onRunPhase 与 MainLoop.onRunPhase 的订阅,异常记 warn。 - 一批的轮次结束即回到 idle,onBatchEnd、onIdle 在 idle 下运行。暂停与投递闸门不并入, 仍由 paused、scheduleBlocked 报告。 - 测试覆盖带工具调用一批的阶段序列、隐藏 World 不收通知,以及 backoff 的 retryAt 与重试时刻。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- /ws/debug 新增 phase 帧,RunPhase 每次变化时推送。status 帧要估算 token、扫描投递积压, 不随工具开始与结束重算。 - 时间线下方那行原先在最后一条是 user Item 时显示「已进上下文,尚无 assistant 输出」; 现在显示投递、等待模型、执行工具(带工具名)、重试时刻或交接,idle 时收起。查看后台会话 或调试通道断开时不显示。 - 测试覆盖追加 user 消息不再点亮状态行,phase 帧决定显示与收起。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ISO 时刻按 AGENTS.md §2 以 *At 命名,与同一接口的 retryAt 一致。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phantivia
force-pushed
the
feat/run-phase
branch
from
October 6, 2026 03:42
38ec8ef to
cbbc698
Compare
Merged
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.


基于已合并的 #180。处理 #157 的 A4。
改动
Core:
RunPhase。 主循环记录此刻在做什么,每个字段都是 Core 直接观察到的事实:state:idle(等下一批,批末钩子也在此状态运行)、delivering(把一批事件写入主 session,含等待Persona.onDelivery)、model、tools(本轮输出已结束,执行工具调用)、backoff(模型调用失败后等待重试)、handoff。round:本批的轮序号;running:正在执行的工具名,含流式提前执行的调用;retryAt:backoff 时下一次请求的时刻;enteredAt:进入当前 state 的时刻。onRunPhase与MainLoop.onRunPhase的订阅;getStatus().phase返回当前值。暂停与投递闸门不并入,仍由paused、scheduleBlocked报告。控制台。
/ws/debug新增phase帧,每次变化推送;status帧要估算 token、扫描投递积压,不随工具开始与结束重算。终端页时间线下方那行原先在最后一条是 user Item 时显示「已进上下文,尚无 assistant 输出」(从时间线推断);现在按 phase 显示投递、等待模型、执行工具(带工具名)、重试时刻或交接,idle 时收起。测试
tests/core/loop.test.ts:带工具调用的一批,可见 World 依次看到 delivering → model(1) → tools(1) → 工具开始与结束 → model(2) → idle,隐藏 World 收不到;可重试的失败进入 backoff,retryAt是重新请求的时刻。tests/web/feature-live.test.ts:追加 user 消息不再点亮状态行,phase 帧决定显示与收起(旧代码上第一条断言失败)。pnpm test4826 通过,pnpm run typecheck、pnpm typecheck:web无报错。World 在运行中挂载或重新可见时,要等下一次变化才收到当前值;
WorldHost没有读取当前 phase 的接口。English
Core's main loop now keeps a
RunPhase(idle, delivering, model, tools, backoff, handoff, with the round, the running tool names, the retry time and when the state was entered). Visible Worlds receive it throughonRunPhaseandgetStatus().phasereturns it.The console's Terminal page shows this phase instead of inferring "in context, no assistant output yet" from the timeline. The phase travels in a separate
/ws/debugframe, because the status frame estimates tokens and scans the delivery backlog. Builds on the merged #180; addresses #157 A4.🤖 Generated with Claude Code