fix(kap-server): deliver session-level interaction events past agent filters - #3901
Conversation
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bafe66707
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
🟡 Changes recommended
The user-visible fix requires a patch changeset targeting @moonshot-ai/kimi-code.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes delivery and attribution of subagent approval and question interactions for filtered WebSocket clients.
Changes:
- Bypasses agent filters for session-level interaction events.
- Adds
agent_idto approval and question payloads. - Adds tests and bilingual API documentation.
File summaries
| File | Description |
|---|---|
packages/kap-server/src/transport/ws/v1/sessionEventBroadcaster.ts |
Bypasses filters and attributes interaction events. |
packages/kap-server/src/routes/approvals.ts |
Adds approval agent attribution. |
packages/kap-server/src/routes/questions.ts |
Attributes listed questions. |
packages/kap-server/src/routes/snapshot.ts |
Attributes snapshot questions. |
packages/kap-server/src/protocol/approval.ts |
Adds required agent_id. |
packages/kap-server/src/protocol/question.ts |
Adds optional agent_id. |
packages/kap-server/src/protocol/question-wire.ts |
Serializes question agent IDs. |
packages/kap-server/test/approvals.test.ts |
Tests attribution and fallback. |
packages/kap-server/test/sessionEventBroadcaster.test.ts |
Tests filtered delivery and replay. |
docs/en/reference/server-api.md |
Documents the field in English. |
docs/zh/reference/server-api.md |
Documents the field in Chinese. |
Review details
- Files reviewed: 11/11 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (filter === undefined) return true; | ||
| if (isGlobalEvent(envelope.type)) return true; | ||
| if (isAgentLifecycleEvent(envelope.type)) return true; | ||
| if (isInteractionEvent(envelope.type)) return true; |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
* feat(kimi-code): carry turn trace id and copilot stats in rating surveys (MoonshotAI#3907) * feat: expose resolved base_url on models.dev catalog provider items (MoonshotAI#3909) * fix(agent-core-v2): restore thinking for the openrouter reasoning dialect (MoonshotAI#3910) Keep string reasoning fields when a reasoning_details array is present, stamp each think part by source, and replay those fields on the next request. * ci: release packages (MoonshotAI#3862) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * docs(changelog): sync 2.0.1 from apps/kimi-code/CHANGELOG.md (MoonshotAI#3912) * fix(agent-core-v2): pre-shrink compaction history to the effective model window (MoonshotAI#3911) * fix(vscode): ignore Enter during IME composition in question dialog (MoonshotAI#3915) * fix(kap-server): deliver session-level interaction events past agent filters (MoonshotAI#3901) * revert(kap-server): drop the flat entity message protocol (v3 WS + history API) (MoonshotAI#3532) (MoonshotAI#3920) This reverts 64505e3. The v1 WS + legacy REST + transcript surfaces are alive on main and remain the single protocol surface; kimi-inspect returns to the transcript-based data model (keeping MoonshotAI#3747's removal of the prompt input, which adapted to the agent-core-v2 prompt-queue fold). * feat(oauth): parse goods_version from the managed /me profile payload (MoonshotAI#3921) * fix: keep turn ids above the wire-wide max and fold cold transcripts over the active branch (MoonshotAI#3922) * fix(agent-core-v2): floor the human turn clock at the wire-wide max on engine journal reset * fix(kap-server): fold the cold transcript snapshot over the restorable branch chain * fix(agent-core-v2): advance the human turn clock when a turn starts * fix(kap-server): split reused wire turn ids in the live transcript projector * fix(kap-server): adopt the completed cold tip for mid-turn attach events Continuation deltas after a lazy transcript attach belong on the last cold turn, not a newly split export id. * fix(agent-core-v2): remove the project-root assertion for cwd from the system prompt (MoonshotAI#3929) Co-authored-by: 7Sageer <7sageer@djwcb.cn> * chore: remove the tdd skill (MoonshotAI#3932) * fix(agent-core-v2): don't record turn.steer when an unconsumed steer seeds the next turn (MoonshotAI#3933) * chore: sync web dist from code-app (MoonshotAI#3934) * chore: sync web dist from code-app code-app: 44d7281c7a63ee3c7a907f9406e490efdbec7411 * chore: collapse web dist sync changesets into one summary entry * ci: release packages (MoonshotAI#3913) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: generate native Kimi ACP session titles (#15) --------- Co-authored-by: Grapedge <shiwang.lj@alibaba-inc.com> Co-authored-by: liruifengv <liruifeng1024@gmail.com> Co-authored-by: Haozhe <yanghaozhe@moonshot.ai> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 7Hanrui <qihanrui@moonshot.ai> Co-authored-by: 7Sageer <7sageer@djwcb.cn> Co-authored-by: Zixuan Chen <remch183@outlook.com>
根因
desktop(以及任何按 agent 过滤订阅的 WebSocket 客户端)的会话侧栏显示「待授权」,但消息流里永远出现不了可操作的授权卡片,刷新也不消失。断链分两层:
event.approval.*/event.question.*事件在 payload 顶层携带子 agent 的agentId,v1 广播器的matchesAgentFilter按每个连接的agent_filter(desktop 订阅的是['main'])把它们过滤掉——实时广播和 journal replay 两条路径共用同一个过滤器,客户端因此永远收不到交互明细。pendingInteraction: 'approval'是按 session 聚合所有 agent 算出来的,经session.work_changed(agentId硬编码main)正常下发——所以徽标能亮,卡片永远没有。turn_ended/agent_closed/purge三条清理路径都不触发,要等默认 2 小时子 agent 超时),所以刷新后徽标反复亮起。解决方案
event.approval.*/event.question.*)在matchesAgentFilter中直接放行。审批 / 提问是会话级人机操作(REST resolve 路径本来就不按 agent 过滤),事件量极小,不破坏 main-agent-only 订阅的节流意图;实时广播与 replay 共用同一过滤器,一处修改两条路径同时修复。toWireApproval增加agent_id(无 agent tag 时兜底main);toWireQuestion增加可选agent_id。REST 列表 / 快照 / WS 事件都携带该字段,客户端可据此把待处理交互归属到发起它的子 agent。影响范围
agent_id字段。agent_filter=['main']下的实时送达与 replay 送达、agent_id落值(子 agent tag 与 main 兜底);另经真实会话端到端验证:后台子 agent 的 Bash 审批送达到带过滤的 WS 订阅,处理后 resolved 事件正常送达。