feat: expose context-engine compaction delegate helper#49061
Conversation
Greptile SummaryThis PR extracts the compaction delegation logic from Key changes:
One minor point to consider: Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/context-engine/delegate.ts
Line: 31-40
Comment:
**`compactionTarget` silently dropped without documentation**
`params.compactionTarget` is part of the `ContextEngine.compact()` interface (as `"budget" | "threshold"`), but it is not forwarded to `compactEmbeddedPiSessionDirect` — which doesn't have that field in `CompactEmbeddedPiSessionParams`. This is intentional and consistent with the original `LegacyContextEngine` behavior.
However, since `delegateCompactionToRuntime` is now a **public API** for third-party plugin authors, the silent discard of `compactionTarget` is not obvious. A caller who passes `compactionTarget` via their `compact()` params would reasonably expect it to be honored.
Consider adding a note to the JSDoc to make this explicit:
```ts
/**
* ...
*
* Note: `compactionTarget` from the compact params is not forwarded to the
* runtime bridge — the underlying runtime does not expose this knob via this
* path. If you need compaction-target control, implement your own `compact()`
* algorithm.
*/
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 18f3de8 |
bc06ff7 to
3a64241
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a64241904
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
3a64241 to
cdef7a3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 205378e421
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
14f8281 to
86bce4f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86bce4fe78
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Hi @jalehman , Thanks for taking the time to clarify the semantics of I think this is a very meaningful improvement to the I believe this will help the OpenClaw context-engine ecosystem become both more mature and more vibrant over time. |
86bce4f to
2a9653c
Compare
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
What
Adds a public
delegateCompactionToRuntime(...)helper for context-engine plugins, refactors the built-inLegacyContextEngineto use the same bridge, and tightens the docs around the actual runtime meaning ofownsCompaction.Why
The current context-engine docs make it too easy to read
ownsCompaction: falseas automatic fallback to legacy compaction, but the active engine still handles/compactand overflow recovery. That confusion came up in these review threads: #46409 (comment) and #46409 (comment). It also blocks the non-owning/delegating plugin path discussed in #43920, because third-party engines had no supported way to reuse OpenClaw's built-in compaction runtime.Changes
delegateCompactionToRuntime(...)LegacyContextEngineto share the helperownsCompactionsemantics in docscompact()Testing
pnpm buildpnpm test -- src/context-engine/context-engine.test.ts -t "delegateCompactionToRuntime|legacy compact preserves runtimeContext"pnpm test -- src/plugin-sdk/index.test.ts -t "keeps the root runtime surface intentionally small|does not expose runtime modules"