Skip to content

feat(core): Persona.onDelivery 可丢弃整批 - #371

Closed
Voemp wants to merge 1 commit into
Pal-AI-Lab:mainfrom
Voemp:feat/persona-delivery-drop
Closed

Voemp wants to merge 1 commit into
Pal-AI-Lab:mainfrom
Voemp:feat/persona-delivery-drop

Conversation

@Voemp

@Voemp Voemp commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

中文

Persona.onDelivery 现在可在 CoreApi.deliveryDrop 为 true 时返回 { action: 'drop', reason }。Core 在投递前丢弃整批:不写 session、不调模型、不运行 onBatchEnd,钩子期间的 injectInternal 一并丢弃;游标照常推进,来源 World 的 onEventsSettled 收到 dropped。未声明 deliveryDrop 的 Core 忽略返回值,旧 Persona 与旧 Core 的行为不变。新增 DeliveryDecision 类型与四个测试,覆盖丢弃、水位推进、World 结算、不写 session/不调模型,以及 action: 'deliver' 照常投递。

English

Persona.onDelivery may now return { action: 'drop', reason } when CoreApi.deliveryDrop is true. Core drops the batch before delivery: no session write, no model call, no onBatchEnd; internal injections made during the hook are dropped too. The watermark still advances and the source World receives onEventsSettled(..., 'dropped'). A Core that does not declare deliveryDrop ignores the return value, so existing Personas and older Cores keep their behavior. Adds the DeliveryDecision type and four tests covering the drop path, watermark advancement, World settlement, the absence of a session write or model call, and the action: 'deliver' path.

Checks

  • pnpm test — Node 22: 287 files, 5186 passed, 3 skipped
  • pnpm run typecheck
  • pnpm typecheck:web
  • A bug fix carries a test that fails before the fix

Closes #370

- CoreApi.deliveryDrop 声明能力;DeliveryDecision 支持 {action:'drop', reason}
- 丢弃时不写 session、不调模型、不跑 onBatchEnd;仍推进 watermark 并记日志
- World.onEventsSettled 增加 dropped,区分 Persona 丢弃与操作者清空队列
- 补 drop/水位/World 结算与 CoreApi 能力测试,更新 Persona/World 文档
@Phantivia

Copy link
Copy Markdown
Member

谢谢把改法和兼容写得这么清楚。这个 PR 我们不合,#370 一起关,说明一下:

Cortico 的分工是:Persona 决定事件怎么摆给模型看(注入提示、交接时留哪些、用 deliveryGate 扣住再一起放行),但 Coo 有没有看到一件事、要不要回应,归主模型自己。整批丢弃会让主模型看不到这批事件,回不回也由别的模型替它定了,所以 Core 不提供跳过模型的投递决定。

「心」现在的语义沉默(往这一批里注入「不用回」,主模型自己 end_turn)照常可用,就是你们 ADR 0004 写的那条路;前缀命中缓存时,这次调用的成本不高。想少叫醒主模型,可以用 deliveryGate 扣住事件,按点名、积压数量或你自己的定时器放行,事件不会丢。另外提醒一句:用 provider 伪造模型回复来跳过调用,按扩展市场的规矩属于改语义,会被拉黑。

@Phantivia Phantivia closed this Nov 4, 2026
@Voemp
Voemp deleted the feat/persona-delivery-drop branch November 5, 2026 06:01
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.

Persona.onDelivery 无法在投递前丢弃整批事件

2 participants