[Feature]: Best-effort Session operation events / Session 操作事件旁路上报
Issue Origin
Inferred by an AI agent and not observed or reproduced
Problem Statement
Follow-up to #4864 / #4860. On main f55cb417, Session.commit Phase 2 runs archive-summary and long-term memory extraction concurrently, but their operation boundaries do not reach task execution events. A task can remain running while one branch has already failed, with the error propagated only after gather finishes. record_event currently awaits a task snapshot write, so using it at each operation would add observability I/O to the business path.
本提案基于主线源码核对,尚未进行本轮真实业务复现:摘要与长期记忆提取缺少独立操作事件,并行失败可能直到汇总后才可见;直接等待事件写入还会把日志 I/O 加进提取主流程。
Proposed Solution
- Add started/completed/failed/cancelled/skipped events for archive_summary and long_term_memory_extraction. Report at the actual aggregate operation boundary; preserve retries, batching, cancellation, task outcome and recovery markers.
- Provide one best-effort, non-I/O event intake with bounded per-task and global memory. Piggyback pending events onto existing task snapshot writes; no event-only background task.json writes. Keep received event identity/time stable, acknowledge only the successfully saved batch, and include accepted events in the normal terminal write.
- Preserve include_events=true as persisted-history access; add opt-in access to buffered events on the same authorized task-detail endpoint. Pending data can be lost on process failure.
- Studio merges both sources into one timeline and copy output. Persistence state stays internal: no saved/pending badges, save controls or permanent caveats. Show notices only for known task-event drops, truncation or refresh failure.
为摘要处理、长期记忆提取接入五类粗粒度操作事件。事件是旁路:异常/过载不能改变业务结果,无新增日志 I/O;复用任务原有快照保存,实时查询沿用任务权限。前端统一展示事件并隐藏保存细节,仅对已知异常提示。
Alternatives Considered
Awaiting every event write can block the business path. A background writer updating the same task.json would still contend for task locks; an independent persistent event store/exporter adds migration, cleanup and late-event handling beyond this increment.
选择先复用现有快照,接受上次业务写入之后的缓冲事件可能在崩溃时丢失;独立后台日志存储留待实际需求。
Feature Area
Session Management
Use Case
When long-term extraction fails while summary generation is still active, show the failed operation immediately in Studio; later retain the summary result and final task outcome. Distinguish a policy skip from successful extraction, and do not describe an empty successful result as newly created memory.
用于定位 Session 内并行操作的失败、正常完成和明确跳过。
Example API (Optional)
Additional Context
Human-reviewed scope and semantics; AI-assisted implementation planned. Proposed validation: real Session commit flow with controlled model responses, early failure with a blocked sibling, two failures, policy skips, batching/retry preservation, cancellation, event-intake/encoding/overflow failures, concurrent snapshot acknowledgement, terminal/delete races, restart, ownership and Studio display/copy. No new implementation or test results are claimed by this proposal.
本提案先于实现发布,涉及 Memory、Platform/Task 与 Web Studio。计划复用现有契约测试,验证事件失败不改变业务,并明确内存缓冲与持久化的接口边界。后续具体重试/恢复事件与资源导入事件分开贡献。
Contribution
- [x] I am willing to contribute to implementing this feature