Skip to content

feat(openclaw-plugin):context engine refactor design & enforce token budget and reduce context bloat#891

Merged
chenjw merged 4 commits intovolcengine:mainfrom
Mijamind719:codex/context-engine-refactor
Mar 23, 2026
Merged

feat(openclaw-plugin):context engine refactor design & enforce token budget and reduce context bloat#891
chenjw merged 4 commits intovolcengine:mainfrom
Mijamind719:codex/context-engine-refactor

Conversation

@Mijamind719
Copy link
Copy Markdown
Collaborator

Description

fix(openclaw-plugin): enforce token budget and reduce context bloat

Extract resolveMemoryContent() helper to eliminate duplicate content-resolution
logic between buildMemoryLines and buildMemoryLinesWithBudget. Add JSDoc and
inline comment documenting intentional first-line budget overshoot (spec §6.2).
Tighten test assertion from <=120 to <=106 tokens.

Change nullish coalescing (??) to truthy fallback (||) in
resolveMemoryContent() so empty-string abstracts fall back to item.uri
instead of producing empty content lines.

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

chethanuk and others added 4 commits March 20, 2026 18:21
…olcengine#730) (volcengine#796)

* test(openclaw-plugin): add vitest test infrastructure for volcengine#730

* fix(openclaw-plugin): raise recallScoreThreshold default from 0.01 to 0.15 (volcengine#730)

* fix(openclaw-plugin): narrow isLeafLikeMemory boost to level-2 only (volcengine#730)

* fix(openclaw-plugin): prefer abstract over full content fetch in memory injection (volcengine#730)

* feat(openclaw-plugin): add recallMaxContentChars and recallPreferAbstract config (volcengine#730)

* feat(openclaw-plugin): enforce tokenBudget in injection with decrement loop (volcengine#730)

* fix(openclaw-plugin): update recallScoreThreshold placeholder to match new default (volcengine#730)

* fix(openclaw-plugin): deduplicate content resolution and document budget behavior (volcengine#730)

Extract resolveMemoryContent() helper to eliminate duplicate content-resolution
logic between buildMemoryLines and buildMemoryLinesWithBudget. Add JSDoc and
inline comment documenting intentional first-line budget overshoot (spec §6.2).
Tighten test assertion from <=120 to <=106 tokens.

* fix(openclaw-plugin): use truthy fallback for empty abstract strings (volcengine#730)

Change nullish coalescing (??) to truthy fallback (||) in
resolveMemoryContent() so empty-string abstracts fall back to item.uri
instead of producing empty content lines.
Co-authored-by: Mijamind <mijamind@163.com>
Co-authored-by: GPT-5.4 <noreply@openai.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 23, 2026

CLA assistant check
All committers have signed the CLA.

@Mijamind719 Mijamind719 changed the title context engine refactor design & enforce token budget and reduce context bloat feat(openclaw-plugin):context engine refactor design & enforce token budget and reduce context bloat Mar 23, 2026
@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

- 调用 `session.commit(wait=false)` 提交 OpenViking session
- 异步:commit 在后台执行,afterTurn 立即返回,更新 session中 CompactState, 下一轮 Compact状态检查 中确认完成

兜底 flush:进程退出时(service.stop() / SIGTERM / SIGINT),遍历所有 buffer 执行 commitAndReset,确保未提交的累积内容不丢失
Copy link
Copy Markdown
Collaborator

@chenjw chenjw Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

依赖在退出时的commit,感觉不太容易做到, 建议在正常上传记忆和commit的时候就需要确保这种异常后的恢复工作。 这样在异常退出后就无需做了。

@chenjw chenjw merged commit 3b5b9a4 into volcengine:main Mar 23, 2026
5 of 6 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants