Skip to content

fix(agent): 修正上下文整理会话完成态【已审核 PR】 - #1738

Merged
ErlichLiu merged 2 commits into
proma-ai:mainfrom
Andreaseszhang:fix/context-compaction-completion-status-202608181520
Aug 19, 2026
Merged

fix(agent): 修正上下文整理会话完成态【已审核 PR】#1738
ErlichLiu merged 2 commits into
proma-ai:mainfrom
Andreaseszhang:fix/context-compaction-completion-status-202608181520

Conversation

@Andreaseszhang

Copy link
Copy Markdown
Contributor

概述

修复 Agent 会话在主任务已经正常结束、仅进行上下文整理时的左侧状态显示。此前所有仍处于流状态的压缩阶段都会被统一标记为 running,导致用户无法区分“任务仍在执行”和“任务已完成、只是在整理上下文”。本 PR 只将无需自动续跑的成功主任务压缩标记为 completed;运行中压缩、CompactContext 触发的自动续跑以及异常结束仍保持 running。

改动

  • apps/electron/src/main/lib/adapters/pi-agent-adapter.ts — 根据成功 agent_end、是否需要原任务续跑,给后续 compaction_start 传递 afterCompletedTurn 标记。
  • apps/electron/src/main/lib/adapters/pi-agent-adapter.test.ts — 覆盖正常完成、CompactContext 续跑和异常结束三种判定路径。
  • packages/shared/src/types/agent.ts — 扩展压缩事件和 SDK system message 的显式类型契约。
  • apps/electron/src/renderer/hooks/useGlobalAgentListeners.ts — 将跨进程压缩标记转换为 renderer AgentEvent。
  • apps/electron/src/renderer/atoms/agent-atoms.ts — 仅对带完成标记的压缩显示 completed/绿色状态。
  • apps/electron/src/renderer/atoms/agent-atoms.test.ts — 覆盖任务执行中压缩保持 running、任务成功结束后压缩显示 completed。
  • apps/electron/package.jsonpackages/shared/package.json — 递增受影响包版本。

测试方法

  1. bun test apps/electron/src/main/lib/adapters/pi-agent-adapter.test.ts apps/electron/src/renderer/atoms/agent-atoms.test.ts
  2. bun run typecheck
  3. bun run --filter='@proma/electron' build:main
  4. git diff --check

以上验证均已在基于 upstream 最新 main3d69bd9)的快照上通过,聚焦测试结果为 26/26。

备注

  • 运行中自动压缩和 CompactContext 续跑不会被标记为完成,避免出现任务尚未结束却显示绿色的情况。
  • 真实“正常任务最终答复后自然触发自动压缩”的 UI 截图仍需在对应开发版中进行运行时验收。

Made with Proma · GitHub

@ErlichLiu
ErlichLiu force-pushed the fix/context-compaction-completion-status-202608181520 branch from 855b186 to a44b646 Compare August 19, 2026 08:49
Andreaseszhang and others added 2 commits August 19, 2026 16:50
仅当主 Agent 已成功结束且无需自动续跑时,才将上下文整理阶段显示为 completed;运行中压缩、CompactContext 续跑和异常结束保持 running。

Made-with: Proma
Remove the PR-specific test file and test cases as requested.

Made-with: Proma
@ErlichLiu
ErlichLiu force-pushed the fix/context-compaction-completion-status-202608181520 branch from a44b646 to bcef7b3 Compare August 19, 2026 08:50
@ErlichLiu
ErlichLiu merged commit 330554e into proma-ai:main Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants