Skip to content

fix(memory): repair the MEMORY write path for thinking-mode providers - #328

Merged
LeXwDeX merged 3 commits into
devfrom
fix/memory-write-path
Aug 17, 2026
Merged

fix(memory): repair the MEMORY write path for thinking-mode providers#328
LeXwDeX merged 3 commits into
devfrom
fix/memory-write-path

Conversation

@LeXwDeX

Copy link
Copy Markdown
Owner

问题

实机(v1.0.24,thinking 模式模型)memory 写路径 100% 失败——从未有任何话题落盘。三段因果链均有日志/实测证据:

  1. D1 json 词契约MemoryModelgenerateObject(response_format json_object),供应商拒绝 prompt 中不含字面 json 的调用;MAINTAIN/MATCH 系统提示词零 json 字样。证据:2026-08-17T07:11:25Z WARN pre-compaction MEMORY maintenance failed / AI_APICallError 'Prompt must contain the word json'
  2. D2 thinking 吃光输出预算:match 256 / maintain 2048 tokens 被思考输出全额消耗。实测 9KB maintain 形状 payload:finish:length,reasoning_tokens 2048/2048,content_len 0
  3. D3 墙钟掐死活跃调用:prepare 5s / checkpoint 8s / 模型缝 8s 墙钟超时,而同模型同 payload 实测单次调用 15-17s。证据:07:27:55Z WARN MEMORY checkpoint failed cause=TimeoutError

另:08:57Z MEMORY select failed cause=LockTimeoutError 显示超时中断会泄漏 fence flock——锁纪律随之成为必须项。

修法

  • model.ts:接缝处 requireJsonToken 一次性保证字面 json(幂等);DEFAULT_TIMEOUT 8sRESPONSE_TIMEOUT 5min 仅作"彻底无响应"兜底(不是活动预算——流式逐 chunk liveness 欠账见 fix(memory): SSE-liveness debt — wall-clock guard contradicts streaming principle; periodic prepare path still long-holds locks #324)。
  • memory.ts 预算MATCH_OUTPUT_TOKENS 2048 / MAINTAIN_OUTPUT_TOKENS 16384,让结构化回复活过思考阶段。
  • 删墙钟:prepare/search/checkpoint 的 Effect.timeout 包裹全部移除。
  • checkpoint 异步维护 + 锁纪律:模型调用跑在 fence/lock 之外,仅提交段持锁(applyUpdate);维护后台 fork(原子 reserve+fork、fence 之后 kick、per-project 在途守卫、完成/中断/fork 失败都释放槽位);注入渲染用维护前话题。prepare/search 语义不变(并发查询合并、周期同步维护等钉住行为全部保持)。

验证

  • bun typecheck 干净;全 monorepo pre-commit turbo typecheck 绿
  • test/memory/86 pass(含新回归:json 保证、预算链 [2048,2048,16384]、二次 checkpoint 在途守卫不卡死)+ compaction 相关套件全绿
  • 双轴 code-review(Standards + Spec)发现项已全部处置:maintain/backgroundMaintain 重复抽取为 proposeMaintenance、在途守卫改 Set 并 Effect.uninterruptible 原子化 reserve+fork、kick 移到身份 fence 之后、审计补测

欠账与验收边界

fix: memory wiring repair and dag-init GitLab probe hardening
release batch: exerciser watchdog hardening and verify-to-delivery doctrine
Guarantee the literal json token at the MemoryModel seam (providers reject json_object calls without it), size match/maintain output budgets so structured replies survive reasoning, and retire the wall-clock prepare/checkpoint/in-model timeouts that killed active reasoning calls (issue #324 tracks the remaining streaming-liveness debt). Checkpoint maintenance runs in the background with an atomic per-project in-flight guard and commits under fence+lock only; prepare/search semantics unchanged.
@LeXwDeX
LeXwDeX merged commit 225bcfa into devAug 17, 2026
5 checks passed
@LeXwDeX
LeXwDeX deleted the fix/memory-write-path branch August 17, 2026 14:53
Sign up for freeto 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.

1 participant

@LeXwDeX