From 55d25e3fd9b2bb935c02b96da3fa7dad3f88be8a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 00:01:50 +0000 Subject: [PATCH 1/2] fix(approval): admit a Bot reply to its own Source Event without a card #4266 declared every bot_send_message irreversible and external, so each DM reply waited for a Human approval card and real-model turns hung. A reply that names only its trusted source_event_id is now local; any proactive destination stays external and keeps approval. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Lpx6qkvJqKRjdg67NfFT7X --- changes/source-reply-approval.md | 11 ++++++++++ docs/architecture/bot-approval-policy.md | 2 ++ docs/architecture/bot-approval-policy.zh.md | 2 ++ packages/core/src/workspaces/tool-effects.ts | 20 ++++++++++++++++++ packages/core/test/tool-effects.test.ts | 22 ++++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 changes/source-reply-approval.md diff --git a/changes/source-reply-approval.md b/changes/source-reply-approval.md new file mode 100644 index 0000000000..87e55c5503 --- /dev/null +++ b/changes/source-reply-approval.md @@ -0,0 +1,11 @@ +--- +section: Fixed +--- + +## en + +- Fixed every PersonaBot reply waiting for a Human approval card: a `bot_send_message` reply to its own Source Event is admitted directly again, while proactive sends to another Channel, Human, Bot or external target still need approval. + +## zh + +- 修复了 PersonaBot 每次回复都要等 Human 审批卡的问题:`bot_send_message` 回复自身 Source Event 时重新直接放行;主动发往其他 Channel、Human、Bot 或外部目标仍需审批。 diff --git a/docs/architecture/bot-approval-policy.md b/docs/architecture/bot-approval-policy.md index d67ce0a53a..435945cc5e 100644 --- a/docs/architecture/bot-approval-policy.md +++ b/docs/architecture/bot-approval-policy.md @@ -41,6 +41,8 @@ The target first uses deterministic code to determine whether the action needs a Implementation slice #4210 routes trusted irreversible external effects through the common approval owner even under Full Access. Deterministic rules resolve before the Reviewer; approval records capture the declared effects for presentation. Management keeps ADR-0249’s dedicated scope. Full Access does not by itself waive the external-effect approval specified in [E2 #4210](https://github.com/BotHarness/DeepSeekBot/issues/4210). The concrete effect declarations and admission mechanism remain in [E1 #4205](https://github.com/BotHarness/DeepSeekBot/issues/4205), E2 and [E4 #4212](https://github.com/BotHarness/DeepSeekBot/issues/4212). No claim is made that arbitrary behavior can be inferred reliably from a command string. +A `bot_send_message` reply to the Bot's own Source Event, with no other destination, is answering the conversation that asked; it is declared local and admitted without a card. A proactive send naming a Channel, Human, Bot, binding or Grant stays external and keeps approval. + Card-created Tool Approval Rules remain deterministic, Bot-scoped authorizations with their existing role, authority scope and execution checks. The Bot permissions table shows their source such as “From approval card”, role, scope and revoke action. This separate display does not turn them into the template editor's natural-language Always allow rows. They are not written into the shared template, granted to other Bots using it, or included in template copies. A natural-language row cannot override an already matched deterministic rule; the Human must revoke that rule to return those requests to review. Current ownership, Workspace Grant, device-target and rule-revocation checks remain independent of model permission. Effective policy management skips the model Reviewer and Full Access, but may use an explicitly saved authorization covering that management operation under ADR-0249. Existing ordinary rules do not gain management authority. Management approval identifies affected Bots. diff --git a/docs/architecture/bot-approval-policy.zh.md b/docs/architecture/bot-approval-policy.zh.md index 0a54b4dd81..1875ea68e7 100644 --- a/docs/architecture/bot-approval-policy.zh.md +++ b/docs/architecture/bot-approval-policy.zh.md @@ -41,6 +41,8 @@ Profile 有一个可选的全局默认模板,来源是共享 Approval Template 实现切片 #4210 将可信声明的不可撤销外部效果送入统一审批,Full Access 不豁免。确定性授权先于 Reviewer,审批记录保存本次效果供呈现;管理操作继续使用 ADR-0249 的专用显式授权范围。具体效果声明与准入机制见 [E1 #4205](https://github.com/BotHarness/DeepSeekBot/issues/4205)、[E2 #4210](https://github.com/BotHarness/DeepSeekBot/issues/4210) 与 [E4 #4212](https://github.com/BotHarness/DeepSeekBot/issues/4212);不声称能从任意命令文本可靠推断全部行为。 +`bot_send_message` 只回复 Bot 自身 Source Event、不指定其他目标时,是在回答发起请求的会话,声明为本地效果,不出审批卡。指定 Channel、Human、Bot、binding 或 Grant 的主动发送仍是外部效果,继续审批。 + 卡片 Always allow 保存的 Tool Approval Rule 是确定性授权,继续绑定具体 Bot、角色、授权范围及执行检查。Bot 权限表标注“来自卡片”、角色、作用范围及撤销入口;独立展示不会将它们变成模板编辑器中的自然语言 Always allow 行。它不写入共享模板,不授权使用同模板的其他 Bot,也不随模板复制。已经命中确定性规则时,模板中的自然语言不会覆盖它;需要重新审核时,由 Human 撤销该规则。 当前所有权、Workspace Grant、设备目标及授权撤销检查独立于模型判断。生效中的策略管理跳过 Reviewer 与 Full Access,须由 Human 决定,或使用 ADR-0249 独立管理范围中确实覆盖该操作的显式已保存授权。旧普通规则不因此获得管理权限。管理审批展示受影响的 Bot。 diff --git a/packages/core/src/workspaces/tool-effects.ts b/packages/core/src/workspaces/tool-effects.ts index 79e0b8e49a..e8ee9db481 100644 --- a/packages/core/src/workspaces/tool-effects.ts +++ b/packages/core/src/workspaces/tool-effects.ts @@ -141,6 +141,24 @@ function inputText(args: unknown): string { } } +const PROACTIVE_DESTINATIONS = [ + 'channel_id', + 'human_id', + 'bot_id', + 'binding_id', + 'conversation_id', + 'grant_id', +] as const; + +function repliesToSource(operation: object): boolean { + return ( + 'source_event_id' in operation && + typeof operation.source_event_id === 'string' && + operation.source_event_id.trim() !== '' && + PROACTIVE_DESTINATIONS.every((key) => !(key in operation)) + ); +} + export function toolEffects(name: string, args: unknown): ToolEffects | undefined { if (name === 'deepseekbot_cli') { if ( @@ -181,6 +199,8 @@ export function toolEffects(name: string, args: unknown): ToolEffects | undefine operation.method.toUpperCase() === 'GET' ) return { ...effects, changes: 'none' }; + if (name === 'bot_send_message' && operation && repliesToSource(operation)) + return { ...effects, reach: 'local' }; if (name === 'browser_tabs' && operation && 'action' in operation && operation.action === 'close') return { ...effects, reach: 'local' }; if ( diff --git a/packages/core/test/tool-effects.test.ts b/packages/core/test/tool-effects.test.ts index eeecfc51a1..d922453725 100644 --- a/packages/core/test/tool-effects.test.ts +++ b/packages/core/test/tool-effects.test.ts @@ -29,6 +29,28 @@ describe('public tool effects', () => { secrets: true, }); }); + it('admits a reply to its own Source Event without a card and keeps proactive sends under approval', () => { + const reply = { source_event_id: 'event-1', body: 'pong', end_turn: true }; + expect(toolEffects('bot_send_message', reply)).toEqual({ + changes: 'irreversible', + reach: 'local', + personalData: true, + }); + expect(toolApprovalRequired('bot_send_message', reply, false)).toBe(false); + for (const destination of [ + { channel_id: 'group-1' }, + { human_id: 'alice' }, + { bot_id: 'bot-2' }, + { binding_id: 'lark-1', conversation_id: 'chat-1' }, + { grant_id: 'grant-1' }, + ]) { + const proactive = { ...reply, ...destination }; + expect(toolEffects('bot_send_message', proactive)?.reach).toBe('external'); + expect(toolApprovalRequired('bot_send_message', proactive, false)).toBe(true); + } + for (const missing of [{ body: 'hello' }, { source_event_id: ' ', body: 'hello' }]) + expect(toolApprovalRequired('bot_send_message', missing, false)).toBe(true); + }); it('includes request delivery when restoring an Assignment with a message', () => { expect(toolEffects('unarchive_assignment', { session_id: 'assignment-1' })).toEqual({ changes: 'reversible', From 56c0e6a0173cc7236da58aa5e2ef5ab7483a0ff0 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 00:02:18 +0000 Subject: [PATCH 2/2] docs(changes): link the source reply fix Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Lpx6qkvJqKRjdg67NfFT7X --- ...source-reply-approval.md => 4334-source-reply-approval.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename changes/{source-reply-approval.md => 4334-source-reply-approval.md} (68%) diff --git a/changes/source-reply-approval.md b/changes/4334-source-reply-approval.md similarity index 68% rename from changes/source-reply-approval.md rename to changes/4334-source-reply-approval.md index 87e55c5503..22b2c1ae25 100644 --- a/changes/source-reply-approval.md +++ b/changes/4334-source-reply-approval.md @@ -4,8 +4,8 @@ section: Fixed ## en -- Fixed every PersonaBot reply waiting for a Human approval card: a `bot_send_message` reply to its own Source Event is admitted directly again, while proactive sends to another Channel, Human, Bot or external target still need approval. +- Fixed every PersonaBot reply waiting for a Human approval card: a `bot_send_message` reply to its own Source Event is admitted directly again, while proactive sends to another Channel, Human, Bot or external target still need approval ([#4334](https://github.com/BotHarness/DeepSeekBot/pull/4334)). ## zh -- 修复了 PersonaBot 每次回复都要等 Human 审批卡的问题:`bot_send_message` 回复自身 Source Event 时重新直接放行;主动发往其他 Channel、Human、Bot 或外部目标仍需审批。 +- 修复了 PersonaBot 每次回复都要等 Human 审批卡的问题:`bot_send_message` 回复自身 Source Event 时重新直接放行;主动发往其他 Channel、Human、Bot 或外部目标仍需审批([#4334](https://github.com/BotHarness/DeepSeekBot/pull/4334))。