Graphorin API reference v0.1.0
Graphorin API reference / @graphorin/memory / / ContextEngine
Interface: ContextEngine
Defined in: packages/memory/src/context-engine/engine.ts:245
Public surface of the ContextEngine instance returned by createContextEngine.
Stable
Methods
assemble()
assemble(memory, input): Promise<AssembledPrompt>;Defined in: packages/memory/src/context-engine/engine.ts:247
Assemble the layered system prompt for a single step.
Parameters
| Parameter | Type |
|---|---|
memory | Memory |
input | AssembleInput |
Returns
Promise<AssembledPrompt>
compactNow()
compactNow(input): Promise<{
extraContent: readonly MessageContent[];
hookFailures: readonly {
hookName: string;
reason: string;
}[];
result: CompactionResult;
}>;Defined in: packages/memory/src/context-engine/engine.ts:267
Run a compaction call. Phase 12 calls this when the trigger fires (source: 'auto-trigger') or the operator invokes agent.compact(...) (source: 'manual').
Parameters
| Parameter | Type |
|---|---|
input | { agentId: string; memory: Memory; messages: readonly Message[]; runId: string; scope: SessionScope; sessionId: string; signal?: AbortSignal; source: CompactionSource; summarizer?: CompactionSummarizer; } |
input.agentId | string |
input.memory | Memory |
input.messages | readonly Message[] |
input.runId | string |
input.scope | SessionScope |
input.sessionId | string |
input.signal? | AbortSignal |
input.source | CompactionSource |
input.summarizer? | CompactionSummarizer |
Returns
Promise<{ extraContent: readonly MessageContent[]; hookFailures: readonly { hookName: string; reason: string; }[]; result: CompactionResult; }>
config()
config(): ResolvedContextEngineConfig;Defined in: packages/memory/src/context-engine/engine.ts:283
Resolved configuration snapshot.
Returns
shouldCompact()
shouldCompact(messages, options?): Promise<boolean>;Defined in: packages/memory/src/context-engine/engine.ts:258
Trigger evaluation primitive used by Phase 12 (agent runtime) at the top of every step. Returns true when the in-flight buffer's token count crosses the per-provider trigger threshold. Pass precomputedTokens to amortize the count via the per-message cache surfaced by SessionMemoryStoreExt.totalCachedTokens(scope) (DEC-131) — the production hot path is an O(1) comparison when the cache is warm.
Parameters
| Parameter | Type |
|---|---|
messages | readonly Message[] |
options? | { precomputedTokens?: number; } |
options.precomputedTokens? | number |
Returns
Promise<boolean>