mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-27 00:17:29 +00:00
feat: expose context-engine compaction delegate helper (#49061)
* ContextEngine: add runtime compaction delegate helper * plugin-sdk: expose compaction delegate through compat * docs: clarify delegated plugin compaction * docs: use scoped compaction delegate import
This commit is contained in:
@@ -1810,6 +1810,36 @@ export default function (api) {
|
||||
}
|
||||
```
|
||||
|
||||
If your engine does **not** own the compaction algorithm, keep `compact()`
|
||||
implemented and delegate it explicitly:
|
||||
|
||||
```ts
|
||||
import { delegateCompactionToRuntime } from "openclaw/plugin-sdk/core";
|
||||
|
||||
export default function (api) {
|
||||
api.registerContextEngine("my-memory-engine", () => ({
|
||||
info: {
|
||||
id: "my-memory-engine",
|
||||
name: "My Memory Engine",
|
||||
ownsCompaction: false,
|
||||
},
|
||||
async ingest() {
|
||||
return { ingested: true };
|
||||
},
|
||||
async assemble({ messages }) {
|
||||
return { messages, estimatedTokens: 0 };
|
||||
},
|
||||
async compact(params) {
|
||||
return await delegateCompactionToRuntime(params);
|
||||
},
|
||||
}));
|
||||
}
|
||||
```
|
||||
|
||||
`ownsCompaction: false` does not automatically fall back to legacy compaction.
|
||||
If your engine is active, its `compact()` method still handles `/compact` and
|
||||
overflow recovery.
|
||||
|
||||
Then enable it in config:
|
||||
|
||||
```json5
|
||||
|
||||
Reference in New Issue
Block a user