Repository navigation
fix(kap-server): forward swarm member task events - #4922
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 75104eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
Collaborator
Author
Merged
6 tasks done
This was referenced Nov 14, 2026
wbxl2000
pushed a commit
that referenced
this pull request
Nov 16, 2026
* fix(agent-core-v2): avoid quadratic cloning during session replay (#4885) * fix(agent-core-v2): avoid quadratic cloning during session replay * fix(agent-core-v2): isolate replay assignments and preserve rollback order * refactor(agent-core-v2): make participant mutable replay explicit opt-in --------- Co-authored-by: kimi-agent-bot <[email protected]> * fix(agent-core-v2): validate Kimi media upload status (#4905) * fix(agent-core-v2): reject failed Kimi image extraction * chore: add Kimi image extraction changeset * fix(agent-core-v2): validate Kimi media upload status * fix(kap-server): forward swarm member task events (#4922) * test(agent-core-v2): make zero-timeout task wait deterministic (#4925) Co-authored-by: kimi-agent-bot <[email protected]> * feat(registry): support search_url and feedback_url on custom registry providers (#4875) * feat(registry): support search_url and feedback_url on custom registry providers * fix(sdk): honor provider.env credentials and custom_headers for feedback_url * refactor(core): submit feedback through the engine Web and desktop reach this machine through kap-server, so feedback submission resolves the active model's provider in the engine and is exposed on the same route and klient method. The SDK facade keeps the managed OAuth path and no longer re-derives provider credentials. * refactor(sdk): drop the unused feedback facade Product clients submit feedback through the engine. The SDK facade and oauth toolkit no longer keep a second managed-only submission path. * refactor(feedback): share engine schemas across route and klient The HTTP body uses the engine field names, so the route forwards it and the klient contract imports the same schemas. * refactor(feedback): drop unused kap and klient surfaces TUI reaches IFeedbackService through the harness. The HTTP routes, klient facade, and the schemas that only served them have no caller. * refactor(feedback): package and upload feedback attachments in the engine * refactor(feedback): keep FeedbackService internal to agent-core-v2 * test(cli): provide execFile in node:child_process mocks The feedback codebase scanner added in this branch calls promisify(execFile) at module scope and is now reachable from the agent-core-v2 index, so partial child_process mocks in these suites failed module evaluation. * feat(feedback): disclose submitted files, attach request_id, and drop text-only option (#4876) * feat(registry): support search_url and feedback_url on custom registry providers * fix(sdk): honor provider.env credentials and custom_headers for feedback_url * refactor(core): submit feedback through the engine Web and desktop reach this machine through kap-server, so feedback submission resolves the active model's provider in the engine and is exposed on the same route and klient method. The SDK facade keeps the managed OAuth path and no longer re-derives provider credentials. * refactor(sdk): drop the unused feedback facade Product clients submit feedback through the engine. The SDK facade and oauth toolkit no longer keep a second managed-only submission path. * refactor(feedback): share engine schemas across route and klient The HTTP body uses the engine field names, so the route forwards it and the klient contract imports the same schemas. * refactor(feedback): drop unused kap and klient surfaces TUI reaches IFeedbackService through the harness. The HTTP routes, klient facade, and the schemas that only served them have no caller. * refactor(feedback): package and upload feedback attachments in the engine * refactor(feedback): keep FeedbackService internal to agent-core-v2 * test(cli): provide execFile in node:child_process mocks The feedback codebase scanner added in this branch calls promisify(execFile) at module scope and is now reachable from the agent-core-v2 index, so partial child_process mocks in these suites failed module evaluation. * feat(feedback): disclose submitted files, attach request_id, and drop text-only option * fix(session-export): keep SESSION_NOT_FOUND for missing non-empty session ids The global-log-only fallback exists for feedback submissions without an active session (empty id). Scoping it to empty ids restores the 40401 envelope that kap-server's export route promises for unknown sessions. * test(agent-core-v2): pin retained request id semantics in llmRequester assertions * chore: sync web dist from code-app code-app: 11563df26b92f0035659083327976a2e9b8e6727 code-app-release: b0b6d9c7a45c96ca48039ff05789c6e90f76ef20 code-app-local-build: 005d2b437493b7ab04d01f70542f3b6356699f4d * ci: release packages (#4918) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(agent-core-v2): align request id back-sync with main --------- Co-authored-by: kimi-agent-bot <[email protected]> Co-authored-by: Haozhe <[email protected]> Co-authored-by: 7Sageer <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.




Requirement or Bug
桌面端与 Web 端用户在开启
/swarm执行AgentSwarm期间,对话中的 Swarm 面板一直显示“等待子任务加入…”,完成计数始终停留在0 / N,直到整个AgentSwarm工具调用全部结束后才一次性从结果文本回填。本 PR 恢复 Swarm 成员生命周期事件到/api/v1/ws实时task帧的转发,使运行中的子代理列表与完成进度恢复实时展示。Bug Reproduction Steps
/swarm开启 Swarm 模式。AgentSwarm。AgentSwarm工具结果尚未返回期间观察 Swarm 卡片:成员区域始终为空并提示“等待子任务加入…”,卡片计数保持0 / N不随单个子代理完成而递增。Root Cause
根本修复。
flowchart LR A[普通 Bash / 单个 Agent] --> B[ToolExecutor handler] B --> C[IAgentTaskService.onDidChangeTask] D[SwarmMemberTasks] --> E[IEventDispatcher: TaskStarted / TaskTerminatedNotice] C --> F[SessionTaskFeed] E -. "#4831 移除监听后断链" .-> F F --> G["/api/v1/ws: task 帧"]因为
SwarmMemberTasks不经过ToolExecutorhandler,只通过IEventDispatcher发布 durableTaskStarted与TaskTerminated(经taskKey折叠发出TaskTerminatedNotice);而#4831为恢复普通前台任务的实时通知,将SessionTaskFeed改为仅订阅IAgentTaskService.onDidChangeTask,漏掉了 Swarm 成员所在的IEventBus旁路,所以客户端 Task store 在运行期间收不到任何 Swarm 成员的实时task帧。Code Changes
在
packages/kap-server/src/transport/ws/v1/sessionTaskFeed.ts的SessionTaskFeed.watch中保留IAgentTaskService.onDidChangeTask订阅,同时恢复对IEventBus上TaskStarted与TaskTerminatedNotice的订阅,仅转发带swarmIndex的 Swarm 成员事件:这里按
info.kind === 'agent' && info.swarmIndex !== undefined识别 Swarm 成员,而不是按toolExecutor.handler(taskId) === undefined判重,是因为LoopService处理普通后台任务的tool.async_ended时会先同步release(taskId)再异步派发TaskTerminated;若按handler === undefined判断,普通后台任务在终态到来时已被移除,会导致终态task帧重复发送。运行中途重连或刷新时的task.list则继续由IAgentTaskService.list(true)从taskKey状态读取在跑的 Swarm 成员,无需额外拼装。Behavior Changes and Affected Users
AgentSwarm成员运行与结束时的/api/v1/wstask帧task帧;运行期间客户端 Task store 无 Swarm 成员记录swarmIndex的成员在启动(TaskStarted)与结束(TaskTerminatedNotice)时向已订阅父 agent 的连接推送running与endedtask帧#4831之前的既有服务端实时行为,载荷字段与 schema 不变)Bash、单个Agent、AskUserQuestion的task帧IAgentTaskService.onDidChangeTask推送一次swarmIndex为undefined,不会命中IEventBus转发分支产生重复帧code-app仓消费/api/v1/ws的task/task.list)packages/kap-server/src/transport/ws/v1/sessionTaskFeed.ts。消费方位于code-app仓(desktop 与 web 客户端通过/api/v1/ws的task/task.list帧更新tasksStore并驱动SwarmTool面板),本次未改动任何公开 schema 或字段名(apiSurface.snapshot.test.ts通过),新旧客户端均可直接解析。packages/kap-server/test/sessionEventBroadcaster.test.ts的agent frames用例覆盖普通前台任务 live 推送、普通后台任务 durable 事件不重复推送、跨 agent 不串台以及 Swarm 成员running/ended帧。kap-server+/api/v1/ws+ 客户端 Swarm 面板数据投影的三路并行子代理端到端验证(含运行中实时加入、中途新连接task.list恢复与逐个完成计数递增);未单独启动桌面 Electron 窗口做手工像素截图。验证明细
packages/kap-server/test/sessionEventBroadcaster.test.ts:54/54 通过packages/kap-server/test/wsConnectionV1.test.ts、packages/kap-server/test/conversationContract.e2e.test.ts、packages/agent-core-v2/test/agent/task/rpc-events.test.ts、packages/agent-core-v2/test/features/swarm/sessionSwarm.test.ts:209/209 通过packages/kap-server/test/apiSurface.snapshot.test.ts:1/1 通过@moonshot-ai/kap-servertypecheck、scopedoxlint --type-aware与根仓库corepack pnpm run build:全部通过Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.