Bootstrap: sections cannot reuse budget that recent memories leave unused

未关闭
#54 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
18/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
领域
backend, search

调研方向

Start in src/search.ts, in the else branch of the GET /Memory/bootstrap handler where renderBootstrapSections runs before recent is packed. Compare the two packing shapes the issue describes and read the orientationShare reservation logic in summary-tree before choosing one. Done means a bootstrap with a registered section and few recent memories fills the budget with section items, and heavy recent use still gets its current share.

由索引模型根据 Issue 内容生成。

描述

Problem

GET /Memory/bootstrap packs in this order: pinned, needsReview, contributed sections, recent, relevant (src/search.ts, the else branch that calls renderBootstrapSections). A section is rendered with budgetChars = budget - used before recent is loaded and packed, so it cannot know how much room recent will actually use.

A section that wants to leave room for recent memories therefore has to reserve a fixed share. summary-tree 0.2.1 (HarperFast/summary-tree#5) caps orientation at orientationShare (default 0.5) of budgetChars. When recent memories are few or short, that reserved half goes unused and the bootstrap returns less than the budget allows.

Measured on the summary-tree eval at a 2,000-char budget: orientation covers 8 of 30 topics with the fixed share, against 16 of 30 when it could take the whole remaining budget.

Proposed direction

Let a section's unused reservation flow back, or let leftover budget flow to sections, instead of each section guessing a fixed share. Two shapes to compare:

  1. Pack recent before rendering sections. Load and pack recent (perhaps capped at a share of the budget), then render sections with the true remainder. Cost: sections can no longer render concurrently with the recent load, which adds latency to every bootstrap that has a section.
  2. Render sections with a soft and a hard budget. Sections return items in priority order; the server packs section items up to the soft share, packs recent, then packs further section items into whatever is left. Keeps the concurrency, but changes the section render contract (items must be ordered and individually droppable, which the per-item fits check already assumes).

Whichever shape is chosen, the per-item framing overhead from HarperFast/agent-memory#50 (itemOverheadChars) still applies.

Acceptance

  • With a section registered and few recent memories, the bootstrap fills the budget with section items rather than leaving the section's reserved share empty.
  • With many recent memories, recent still gets the share it gets today.
  • summary-tree can drop or relax orientationShare once this lands.
主要语言
JavaScript
星标
0
派生
0
平均合并
20 小时 29 分钟
30 天内合并 PR
28

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

HarperFast/agent-memory 的其他 Issue

查看 HarperFast/agent-memory 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。