Skip to content

Commit d8f2645

Browse files
authored
refactor(memory-wiki): move compiled cache to plugin state (#110167)
* feat(plugin-sdk): prepare memory prompts asynchronously * refactor(memory-wiki): move compiled cache to plugin state * fix(plugin-sdk): export memory prompt preparer type * refactor(plugin-sdk): keep prompt preparer type private * test(memory-wiki): isolate compiled cache state * chore(memory-wiki): satisfy changed gates * fix(memory): preserve prepared prompts across context engines * docs(plugin-sdk): refresh API baseline * fix(memory): revalidate prepared prompt ownership * fix(codex): propagate sandboxed memory context * test(memory-wiki): seed durable vault identity * refactor(memory-wiki): keep cache lifecycle internal * fix(memory-wiki): harden compiled cache publication * style(memory-wiki): format cache lifecycle changes * test(memory-wiki): support extension test lib target * style(memory-wiki): remove redundant catch * refactor(memory-wiki): keep vault generation helper private
1 parent 3d1b771 commit d8f2645

56 files changed

Lines changed: 2870 additions & 718 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/.generated/plugin-sdk-api-baseline.sha256‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1ab1c0c13b0ee6dc1ef34bb8f7688107a3f3a36dbbf5c0de8aed1c4c002ce773 module/index
1+
4f222069c2ba0c355b72e48a27da2294484dcce0a9b4b3fd3a7ea90a134130c7 module/index
22
f8baddc86ac0e924c7806957f90a6ebdd5916a362ad24b665824503ee77fc6a9 module/access-groups
33
7a8753532854ff6f6d2a0c8e6386653adce285f9f6a9b5e56e88c9ea49e79cc2 module/account-core
44
e7519fd1b7ff7003a6c8b9b640ffedd443a3754a10efc82877d48cd98cc6ba28 module/account-helpers
@@ -13,7 +13,7 @@ e5e67ddf3cab38fcbf9220bc3160715897e2709d9a9ff6ff36f1ecc9453c2367 module/agent-c
1313
30452bae2a689fb75dcb6dba9ef11e5b95f9cbe0c62eb190a0fcb82d0a19ae52 module/agent-core
1414
74daa746deb548379d3f0d6eac3c4d082df1034c4360cc03bf51fee0f10a2e4d module/agent-harness
1515
e09226afd443cee02ed648f032f53bfeb60585617bb523a649995764d3c38da9 module/agent-harness-exec-review-runtime
16-
1a89aff5b4fe0775a776e934a99df462589cf346542acd52fe7ea4a1279ce35d module/agent-harness-runtime
16+
6131781d5c77140711114835b64e087cc81eb87fde6644dd6b2b1f3dafb28d32 module/agent-harness-runtime
1717
ec22d7a039fb58d0b8343ad149322960d3d8ca58b3f4c70f2fa8a099f8186d0c module/agent-harness-task-runtime
1818
5f63bf587bf3547d59d0dc5d0dc2fee54745aa6edaab4aa3ae700dba03443edb module/agent-harness-tool-runtime
1919
5168648cd946abad8a92822889f13ceacc87ed502314a66190d0b1eb8ebe76ea module/agent-media-payload
@@ -35,13 +35,13 @@ a5e9215460bc99fb6e6cdd4bc67eb6466a5e99f28279e13d1769599c18dfe0b3 module/approva
3535
6c81b9122ab0a5c3190700c0a234047274a8d48edddcc8f26d3859b886696068 module/async-lock-runtime
3636
ad60ccc4fe9084d47f0477e02d9296bacad32f26d7456e2a84be8d25a53a25c2 module/boolean-param
3737
333a906d4ad9d3e89102ab7eb9059a7f9c7277328041223ee3b0713442f56a29 module/browser-config
38-
1fcdba7e1d79400bf585f3e0278633c52d4b2d5d1ef8f9ecab5745bfef63c486 module/bundled-channel-config-schema
38+
95772920b307d37a852d9f1b879b5f1fbdc35520da39c803d290c2e23306b00b module/bundled-channel-config-schema
3939
b6e53fb9c69840d71785325cd9a244809ffd6d3f0dd08ed0cccf816dd993f210 module/channel-actions
4040
fcfd76dbfe818e8e8574a425f340fee935acf53d4484e961f54c3ec760fb15fe module/channel-activity-runtime
4141
24c53c9cefacd8c1bec2aa91ba2b01e606f8b8477bc5cb2f99567225a4dcf67c module/channel-config-helpers
4242
a82cc04b1cda7a647850a13c3de552ab638550c7042f887f32bb0ced7227d143 module/channel-config-primitives
4343
929b3f55b60e3885e33644ed3e1757b82349e1beeeede02eda80f7bf7eea4631 module/channel-config-schema
44-
d73888857348fc8ccc21d6e7113a6c2594a2c1b70dc80763987199a718d17a9e module/channel-config-schema-legacy
44+
19cdd42fdae93a84200c96237bf71de49fef9db5fecc9879288de82ce1107f75 module/channel-config-schema-legacy
4545
8740f7cc786a380043e41aaf710ac47931b3587c122bb152d5f0231f98fd5351 module/channel-config-writes
4646
2dd98659d9600e755f09ef00dd91c36692b8562ed3700461937e94f6cd1e640a module/channel-contract
4747
2a5b6694afc08c18248cacaa2af6bf4d448a646799684c7f7be825c4159fc7cb module/channel-core
@@ -89,17 +89,17 @@ a224ce0381a32ed7a9d2261669c444f7f46701c15bf2f6121e9b057d9910da78 module/command
8989
eb4c757fe0086c1dbfa4c3f3caf3dcff0d3cab3924c608237f08f740a6ee5f59 module/command-status
9090
10f073c8c7c7384843cb89548e01cf66241e23ebabea01ccc1f9ac7e774f563e module/command-status-runtime
9191
d340686cf814326b5a554a32cc5ca324a9e1254a933c4d9d8d1ada5ac7109a10 module/command-surface
92-
965428a4ea5cb85a6cdebbf2a976123c1f8056298b75134589d701dfd3adb29d module/compat
92+
251197439b471bc18d7470023b75a4b342884d7096217de9c7e8831ad037818f module/compat
9393
2cf2f7732af5491a14466fc984f833ddce2b0f6a20b1c82796c3ee856e2966ce module/concurrency-runtime
9494
a821f9cc4e6f9339399d99e73f58c3b00baf139aa9d85c22d73c89d8be5702d2 module/config-contracts
9595
20f3f8042de53e4eee61b64de9102c8c202b9299e6a29235647a4729f70145f2 module/config-mutation
9696
316949815affe623ac63951a5db580527f02663576dffa084f02768f612c0c1c module/config-runtime
97-
0468278d29417b56a187fdc8af8c7e29cd5363f90d0fc98352747bc2dccd68b1 module/config-schema
97+
76000159a81c16a708d605473d9babb6f902299c8c15066fb708a16c65482d98 module/config-schema
9898
bfe6eec12f45bc2fda6df28699681b22dfd819a2261aabe8e0c789a20a017058 module/config-types
9999
42d15153981cfe3adc1d5f91621434c56f07a9bd48c15ce34742f72dd040c142 module/context-visibility-runtime
100100
03636897fb99cb73e4d8620c8a0e0d72b4d52fc32bf94f525af2aa88c489c6c2 module/conversation-binding-runtime
101101
c1ea9510dfda047609a99d5d2cd1f1560f5d469a36e6b695766213d695c25b0f module/conversation-runtime
102-
5dd9d423f43dc332073f5b37ef087425da046d639a518af7e0354ebaff561dd0 module/core
102+
d3363f5751848982fa35722402c27a5563d9efd22e0735b83e75629f9361f41b module/core
103103
93b61bc7893ed37047c97c10360588c0acf5df72cf49c54678ce68ed8d07f65c module/cron-store-runtime
104104
e6fc74e18435cd4639801d9bd1f224154d1cd9405cdb3ba91a24b67c0792e9d2 module/dangerous-name-runtime
105105
4af19d59c2f18674e7d7f7dc1b358b644dc707e6bd601dc47168bd9e4a669940 module/dedupe-runtime
@@ -111,7 +111,7 @@ feb743a5f25297abc7bb47d22ef060e0ed54b0cff69ac50885681dfade970f8e module/deliver
111111
371ee1fd78810526745c93c24c4b85562c981676adcc33aaa0c627f5d2d45810 module/direct-dm-guard-policy
112112
91278c800e0f87d7111f226e1cfcb6f29552936fec7215b3b69be4da7e2ee8fb module/directory-config-runtime
113113
ea81ef06956c1bc0853fa00afbbc2b5a4019116aaf8a436e1b27d06f7a2c9e88 module/directory-runtime
114-
e324635b9484d58d1fc0ddf210a817ef0738b31bac58ad4762a8cd9cf1440981 module/discord
114+
04f2efcb8ad7b36eca498d0bbf13090ea7a642ac346e06e91b629a7704a52629 module/discord
115115
f41f9b34ab771c894293453bcdf072860c7cd509dd4e0172156634a816b8d727 module/document-extractor
116116
3ac20ebba52de5a2f18807c0c8ade6e61f59e260a35fc1d077c9dedb9960dabd module/embedding-providers
117117
46c05a90b66032d1d7ad08445840a4bf81aa2bd325348f87710ad4538daf38f6 module/error-runtime
@@ -159,7 +159,7 @@ a5f59c9acbcaa3f82247bf806eb5ba08032373fb853719f0ec9457690f16fc70 module/media-m
159159
c5e3eb1a584f4b8126d9d6c177a840ec9103671e8d1242634ee67db9b5b9e573 module/media-understanding
160160
c0ffaed532578cf33493992e1ff806b2268b8e3774a92edbaede5cf5bda162a6 module/media-understanding-runtime
161161
927014fec9d2e9384c696db06138a2e0f6a9cb1e33b9ec4bb1a8dba84adf3520 module/meeting-runtime
162-
f6e428d474a1c7c9354068d4fc8391b4231a9e99d15ee5ea5fdf4180a7b28159 module/memory-core
162+
bdcdb7db74523c557b6bcaa98a47210ad90f16bc97f9143227d03108c7fd8c23 module/memory-core
163163
6ae3c62fd51b36439cd3f22286f2e52c6bb27bc85de648650b805c3b7603a487 module/memory-core-engine-runtime
164164
2bc363010e81c6990c30fd6743e3ffa37320ec39b91abfc222302dc812d8bd33 module/memory-core-host-embedding-registry
165165
ae67c256150b14f1a58738dce0a703071035b86ec26fc344ab03e942253aa72c module/memory-core-host-engine-embeddings
@@ -174,7 +174,7 @@ deb9953dbae4323348197f7aa90de855446d89db6abaac8434104464b16341f5 module/memory-
174174
f8eb835f0769eba8324033141ecddb9f45bdb3d3241d2a5959fe8426ba6a2280 module/memory-core-host-runtime-files
175175
ebbf937b2258487f773b8a6fbd6c648feea96399cae5fbea18ec7d29e027523d module/memory-core-host-secret
176176
16bdd82751898ffa98157fd27c86fa0eb9ea415fb8ed703eb4e9b170f0a9501b module/memory-core-host-status
177-
0f911f63448af365031f92f0c90c3e852ad047e60a85ac42a41d3b90bc320cd4 module/memory-host-core
177+
646773d8282a2ac6a89101685c406200935ddb3459a2830e820da132fa433b3c module/memory-host-core
178178
7d68cbdfa0d5fad1ab32ba3792787daf386bc4ff7975fd5e25117e92563a2897 module/memory-host-events
179179
059856bc3671ccba7a2191f47c0295e0a91a374f7048cc2bc22784b389d15182 module/memory-host-files
180180
ba07f497aa5469915ebb5b6787148ff1f0f267d7e48c48f0c95d32b7dda8d91a module/memory-host-markdown
@@ -314,7 +314,7 @@ c3c90ba2b012732413c5275d65a1c0ff07a937cd67d04d1acbd6207243544d43 module/tool-re
314314
9d6ab352913a573b226e054e1dc8c6d088493aea9954950c65585923b5b6895a module/tool-send
315315
5d02a59fe9a44a4aaaf027427238874d5ff883688b22b213e05c9f171edfbff5 module/transcripts
316316
14ec8a05b813027a5afb9b92eab79995e0d61768545783081ff1515a84383b2c module/transport-ready-runtime
317-
7626acd98e981a1fd00f1df3dd4ea6b1e21f4b18107d06efac7ee697c3538c99 module/tts-runtime
317+
eb92e9bf85a08cf263e61b5b3497010b1de73f19bdcc5e826b0b9416ad053b90 module/tts-runtime
318318
bf0ffa969b46486f52201900956ed266107f062b22e9be73e5b81356a32185f1 module/types
319319
20946e039f15f52023735836f5d48c72a51c4ace80c019edcb0301571cc79101 module/video-generation
320320
37c7c8e392583c905c4ad6546dfe4f76e52771ef0272b41a57fd4418d70f638e module/video-generation-core

‎docs/cli/wiki.md‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ openclaw wiki get <path-from-json-result>
120120

121121
### `wiki compile`
122122

123-
Rebuild indexes, related blocks, dashboards, and compiled digests. Writes stable machine-facing artifacts under:
124-
125-
- `.openclaw-wiki/cache/agent-digest.json`
126-
- `.openclaw-wiki/cache/claims.jsonl`
123+
Rebuild indexes, related blocks, dashboards, and the compiled query/prompt snapshot. The snapshot is persisted in OpenClaw's shared SQLite plugin state and kept in memory for synchronous prompt projection; it does not create cache files in the vault.
127124

128125
If `render.createDashboards` is enabled, compile also refreshes report pages.
129126

‎docs/concepts/context-engine.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ export default function register(api) {
168168

169169
The factory `ctx` includes optional `config`, `agentDir`, and `workspaceDir`
170170
values so plugins can initialize per-agent or per-workspace state before the
171-
first lifecycle hook runs.
171+
first lifecycle call. Before a non-legacy `assemble()` call, the host completes
172+
registered async memory prompt preparation. The synchronous
173+
`buildMemorySystemPromptAddition(...)` helper reads that immutable run snapshot;
174+
pass the supplied tool, citation, agent, and session context through unchanged.
172175

173176
Then enable it in config:
174177

‎docs/plugins/architecture-internals.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,12 @@ export default function (api) {
11001100
The factory `ctx` exposes optional `config`, `agentDir`, and `workspaceDir`
11011101
values for construction-time initialization.
11021102

1103+
The host completes registered async memory prompt preparation before calling a
1104+
non-legacy engine's `assemble()`. `buildMemorySystemPromptAddition(...)` stays
1105+
synchronous and reads that immutable run snapshot while `assemble()` is active.
1106+
Pass the supplied tool and citation context through unchanged so the snapshot
1107+
cannot cross run boundaries.
1108+
11031109
`assemble()` may return `contextProjection` when the active harness has a
11041110
persistent backend thread. Omit it for legacy per-turn projection. Return
11051111
`{ mode: "thread_bootstrap", epoch }` when the assembled context should be

‎docs/plugins/memory-wiki.md‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,26 @@ claims:
196196
197197
## Compile pipeline
198198
199-
Compile reads wiki pages, normalizes summaries, and emits stable
200-
machine-facing artifacts under:
201-
202-
- `.openclaw-wiki/cache/agent-digest.json`
203-
- `.openclaw-wiki/cache/claims.jsonl`
204-
205-
Agents and runtime code read these digests instead of scraping Markdown.
199+
Compile reads wiki pages, normalizes summaries, and persists a machine-facing
200+
snapshot in OpenClaw's shared SQLite plugin state. Runtime code uses the
201+
lifecycle-owned owner snapshot to load SQLite during async prompt preparation;
202+
synchronous prompt assembly never scrapes Markdown or reads cache files.
206203
Compiled output also powers first-pass wiki indexing for search/get, claim-id
207204
lookup back to owning pages, compact prompt supplements, and report
208205
generation.
209206
207+
Source edits and vault restores become machine-facing only after the next
208+
compile. Restarting or refreshing the plugin lifecycle compares the vault's
209+
causally chained compile publication with SQLite and rejects a snapshot from a
210+
newer, rolled-back state. A compiler that started before the rollback cannot
211+
publish against the restored predecessor. Prompt preparation does not poll the
212+
vault or install file watchers.
213+
After rollback quarantine, a compile in the running process clears the owner
214+
immediately; a separate compiler process requires plugin lifecycle refresh so
215+
the daemon can confirm the new durable publication.
216+
Compiled caches are rebuildable: cache rows from before publication epochs are
217+
treated as misses and replaced by the next compile; they are not migrated.
218+
210219
## Dashboards and health reports
211220
212221
When `render.createDashboards` is enabled, compile maintains dashboards under
@@ -270,7 +279,7 @@ plugin supports corpus selection.
270279
## Prompt and context behavior
271280

272281
When `context.includeCompiledDigestPrompt` is enabled, memory prompt sections
273-
append a compact compiled snapshot from `agent-digest.json`: top pages only,
282+
append a compact compiled snapshot from plugin state: top pages only,
274283
top claims only, contradiction count, question count, confidence/freshness
275284
qualifiers. This is opt-in because it changes prompt shape; it mainly matters
276285
for context engines or prompt assembly that explicitly consume memory

‎docs/plugins/sdk-overview.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ advertised node command.
197197
| `api.registerInteractiveHandler(registration)` | Interactive handler |
198198
| `api.registerAgentToolResultMiddleware(...)` | Runtime tool-result middleware |
199199
| `api.registerMemoryPromptSupplement(builder)` | Additive memory-adjacent prompt section |
200+
| `api.registerMemoryPromptPreparation(prepare)` | Async preparation for a memory-adjacent prompt section |
200201
| `api.registerMemoryCorpusSupplement(adapter)` | Additive memory search/read corpus |
201202
| `api.registerHostedMediaResolver(resolver)` | Resolver for browser-style hosted media URLs |
202203
| `api.registerMcpServerConnectionResolver(...)` | Per-requester MCP transport (`url`/`headers`) for a static server name |
@@ -308,6 +309,15 @@ capturing one global path during registration. If an agent id is required but
308309
missing in a multi-agent operation, fail closed rather than choosing an
309310
arbitrary agent.
310311

312+
Use `registerMemoryPromptPreparation(...)` when prompt text depends on async
313+
plugin state. The callback runs once before each full agent prompt and receives
314+
the same tool, agent, session, and sandbox context as synchronous memory prompt
315+
builders. Validate the current storage-owner instance before loading persisted
316+
state, then return only lines for that run. OpenClaw freezes those lines and
317+
hands the immutable result to synchronous prompt assembly. Keep persistence,
318+
atomic replacement, and owner-removal deletion inside the owning plugin; do not
319+
poll or read files from a prompt builder.
320+
311321
Telegram interactive handlers can return `{ submitText }` to route text through
312322
Telegram's normal inbound agent path after the handler succeeds. OpenClaw keeps
313323
the callback button when inbound policy skips the text or processing fails, so

‎docs/refactor/database-first.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,10 +1342,10 @@ sessionId})`; create, branch, continue, list, and fork flows live in their
13421342
per vault/run id instead of writing `.openclaw-wiki/import-runs/*.json`.
13431343
Rollback snapshots remain explicit vault files until import-run snapshot
13441344
archival is moved into blob storage.
1345-
- Memory Wiki compiled digests now store SQLite plugin blob rows instead of
1346-
writing `.openclaw-wiki/cache/agent-digest.json` and
1347-
`.openclaw-wiki/cache/claims.jsonl`. The migration provider imports old cache
1348-
files and removes the cache directory when it becomes empty.
1345+
- Memory Wiki compiled digests now store compressed SQLite plugin-blob rows
1346+
instead of writing `.openclaw-wiki/cache/agent-digest.json` and
1347+
`.openclaw-wiki/cache/claims.jsonl`. The cache is rebuildable, so doctor
1348+
deletes old cache files without importing them.
13491349
- ClawHub skill install tracking now stores one SQLite plugin-state row per
13501350
workspace/skill instead of writing or reading `.clawhub/lock.json` and
13511351
`.clawhub/origin.json` sidecars at runtime. Runtime code uses tracked-install

‎extensions/codex/src/app-server/attempt-context.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,14 @@ describe("Codex app-server attempt context", () => {
180180
sessionKey: "agent:marketing-agent:session-1",
181181
sessionAgentId: "marketing-agent",
182182
memoryToolNames: ["memory_search", "memory_get"],
183+
sandboxed: true,
183184
});
184185

185186
expect(context.memoryToolRouted).toBe(true);
186187
expect(observedContext).toMatchObject({
187188
agentId: "marketing-agent",
188189
agentSessionKey: "agent:marketing-agent:session-1",
190+
sandboxed: true,
189191
});
190192
expect(context.memoryCollaborationInstructions).toContain(
191193
"agent=marketing-agent session=agent:marketing-agent:session-1",

‎extensions/codex/src/app-server/attempt-context.ts‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import {
1515
type EmbeddedRunAttemptResult,
1616
} from "openclaw/plugin-sdk/agent-harness-runtime";
1717
import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
18-
import { buildMemorySystemPromptAddition } from "openclaw/plugin-sdk/core";
18+
import {
19+
buildMemorySystemPromptAddition,
20+
prepareMemorySystemPromptAddition,
21+
} from "openclaw/plugin-sdk/core";
1922
import { MESSAGE_TOOL_DELIVERY_HINTS } from "openclaw/plugin-sdk/message-tool-delivery-hints";
2023
import type { CodexDynamicToolFunctionSpec, CodexDynamicToolSpec, JsonValue } from "./protocol.js";
2124
import { flattenCodexDynamicToolFunctions } from "./protocol.js";
@@ -170,6 +173,7 @@ export async function buildCodexWorkspaceBootstrapContext(params: {
170173
sessionKey: string;
171174
sessionAgentId: string;
172175
memoryToolNames: readonly string[];
176+
sandboxed?: boolean;
173177
}): Promise<CodexWorkspaceBootstrapContext> {
174178
try {
175179
const memoryToolsAvailable =
@@ -257,13 +261,14 @@ export async function buildCodexWorkspaceBootstrapContext(params: {
257261
turnScopedDeveloperInstructionFiles,
258262
),
259263
memoryCollaborationInstructions: shouldInjectCodexOpenClawPromptContext(params.params)
260-
? renderCodexWorkspaceMemoryCollaborationInstructions({
264+
? await renderCodexWorkspaceMemoryCollaborationInstructions({
261265
files: memoryReferenceFiles,
262266
toolNames: params.memoryToolNames,
263267
memoryToolRouted: memoryToolsAvailable,
264268
citationsMode: params.params.config?.memory?.citations,
265269
agentId: params.params.agentId ?? params.sessionAgentId,
266270
agentSessionKey: params.sessionKey,
271+
sandboxed: params.sandboxed,
267272
})
268273
: undefined,
269274
heartbeatCollaborationInstructions:
@@ -857,20 +862,22 @@ function renderCodexWorkspaceMemoryReference(params: {
857862
return lines.join("\n").trim();
858863
}
859864

860-
function renderCodexWorkspaceMemoryCollaborationInstructions(params: {
865+
async function renderCodexWorkspaceMemoryCollaborationInstructions(params: {
861866
files: EmbeddedContextFile[];
862867
toolNames: readonly string[];
863868
memoryToolRouted: boolean;
864869
citationsMode?: Parameters<typeof buildMemorySystemPromptAddition>[0]["citationsMode"];
865870
agentId?: string;
866871
agentSessionKey?: string;
867-
}): string | undefined {
872+
sandboxed?: boolean;
873+
}): Promise<string | undefined> {
868874
const memoryRecallInstructions = params.memoryToolRouted
869-
? renderCodexMemoryRecallInstructions({
875+
? await renderCodexMemoryRecallInstructions({
870876
toolNames: params.toolNames,
871877
citationsMode: params.citationsMode,
872878
agentId: params.agentId,
873879
agentSessionKey: params.agentSessionKey,
880+
sandboxed: params.sandboxed,
874881
})
875882
: undefined;
876883
const memoryReferenceInstructions = renderCodexWorkspaceMemoryReference({
@@ -881,18 +888,20 @@ function renderCodexWorkspaceMemoryCollaborationInstructions(params: {
881888
return sections.length > 0 ? sections.join("\n\n") : undefined;
882889
}
883890

884-
function renderCodexMemoryRecallInstructions(params: {
891+
async function renderCodexMemoryRecallInstructions(params: {
885892
toolNames: readonly string[];
886893
citationsMode?: Parameters<typeof buildMemorySystemPromptAddition>[0]["citationsMode"];
887894
agentId?: string;
888895
agentSessionKey?: string;
889-
}): string | undefined {
896+
sandboxed?: boolean;
897+
}): Promise<string | undefined> {
890898
const availableTools = new Set(params.toolNames);
891-
const memoryPrompt = buildMemorySystemPromptAddition({
899+
const memoryPrompt = await prepareMemorySystemPromptAddition({
892900
availableTools,
893901
citationsMode: params.citationsMode,
894902
agentId: params.agentId,
895903
agentSessionKey: params.agentSessionKey,
904+
sandboxed: params.sandboxed,
896905
});
897906
if (!memoryPrompt) {
898907
// Memory recall policy belongs to the active memory plugin.

‎extensions/codex/src/app-server/run-attempt-context.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export async function prepareCodexAttemptContext(
5656
usesSupervisionConnection,
5757
resolvedWorkspace,
5858
initialInactiveThreadBootstrapBindingForcedFreshStart,
59+
sandbox,
5960
} = connection;
6061
const { toolBridge } = attemptTools;
6162
const activeTranscriptTarget = {
@@ -139,6 +140,7 @@ export async function prepareCodexAttemptContext(
139140
sessionKey: contextSessionKey,
140141
sessionAgentId,
141142
memoryToolNames,
143+
sandboxed: sandbox?.enabled === true,
142144
});
143145
const baseDeveloperInstructions = joinPresentSections(
144146
buildDeveloperInstructions(runtimeParams, { dynamicTools: toolBridge.availableSpecs }),

0 commit comments

Comments
 (0)