Skip to content

Commit 138ca82

Browse files
committed
fix(context-engine): project commit turn host params
1 parent ec8458c commit 138ca82

3 files changed

Lines changed: 66 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Docs: https://docs.openclaw.ai
66

77
### Changes
88

9-
- **Context-engine turn ownership:** share one context-engine lease across each logical turn and its model fallbacks, advance only the accepted durable winner across chat, CLI, Codex, Copilot, and cron runs, and degrade a failing plugin engine to legacy for that turn before retrying it on the next turn.
10-
- **Telegram model picker:** route callback selections through the canonical atomic session model transaction while keeping picker changes session-only.
119
- **Developer workflow:** remove the obsolete scoped-commit helper and use standard Git commands in isolated worktrees.
1210
- **Plugin uninstall cleanup:** remove exact recorded install paths from `plugins.load.paths` for marketplace, npm, and other managed installs while preserving parent, child, prefix, and unrelated paths.
1311
- Fixed Crabbox hydration on unprivileged cloud sandboxes by falling back to a user-writable pnpm store when the shared `/var/cache/crabbox` cache is unavailable, preserving the hardlink import mode after hydration, and making Docker an explicit routed capability instead of an implicit install requirement.
@@ -67,7 +65,6 @@ Docs: https://docs.openclaw.ai
6765

6866
### Fixes
6967

70-
- **Context-engine transcript fencing:** keep the admitted user turn out of pre-turn transcript reads across embedded and Codex runs, preserve exact same-text messages, advance engine state only for the accepted model-fallback candidate, and use turn-local legacy degradation for engines that cannot honor the fence without changing their configured slot.
7168
- **Control UI read-only preferences:** keep personal preference edits browser-local without attempting unauthorized config writes or claiming server sync, preserve offline intent for a later authorized reconnect, and restore the current server value on local reset. Thanks @shakkernerd.
7269
- **Control UI owner handoff:** give browsers opened by host-issued dashboard and graphical onboarding links durable administrator access, including same-browser recovery from a limited credential, while keeping generic, Telegram, mobile, and ordinary scope-upgrade paths bounded. Thanks @shakkernerd.
7370
- **Control UI agent and skill permissions:** gate Agents, Skills, Skill Workshop, and delayed mutation dispatches by the current Gateway method catalog and operator scopes while preserving read-only browsing and legacy Gateway compatibility. Fixes #119176. Thanks @shakkernerd.

‎src/context-engine/host-param-projection.test.ts‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function registerProbeEngine(params: {
2121
acceptedHostParams?: string[];
2222
assembleCalls: Array<Record<string, unknown>>;
2323
compactCalls: Array<Record<string, unknown>>;
24+
commitTurnCalls?: Array<Record<string, unknown>>;
2425
rejectAssemble?: boolean;
2526
}): string {
2627
const engineId = `host-param-probe-${++engineCounter}`;
@@ -47,6 +48,10 @@ function registerProbeEngine(params: {
4748
params.compactCalls.push({ ...callParams });
4849
return { ok: true, compacted: false };
4950
},
51+
async commitTurn(callParams) {
52+
params.commitTurnCalls?.push({ ...callParams });
53+
return { status: "committed" };
54+
},
5055
}) satisfies ContextEngine,
5156
`test:${engineId}`,
5257
);
@@ -170,6 +175,66 @@ describe("context-engine host parameter projection", () => {
170175
]);
171176
});
172177

178+
it("projects declared host parameters for commitTurn", async () => {
179+
const commitTurnCalls: Array<Record<string, unknown>> = [];
180+
const engineId = registerProbeEngine({
181+
acceptedHostParams: ["runtimeSettings"],
182+
assembleCalls: [],
183+
compactCalls: [],
184+
commitTurnCalls,
185+
});
186+
const resolution = await resolveLogicalTurnContextEngines({
187+
plugins: { slots: { contextEngine: engineId } },
188+
});
189+
const admission = {
190+
agentId: "main",
191+
sessionId: "session-1",
192+
sessionKey: "agent:main:session-1",
193+
storePath: "/tmp/openclaw-agent.sqlite",
194+
generation: "generation-1",
195+
entryId: "user-1",
196+
rawSeq: 1,
197+
effectiveParentId: null,
198+
activeMessagePosition: 0,
199+
logicalTurnId: "turn-1",
200+
role: "user" as const,
201+
};
202+
203+
await resolution.configured.engine.commitTurn?.({
204+
advancementKey: "turn-1",
205+
admission,
206+
terminal: {
207+
...admission,
208+
entryId: "assistant-1",
209+
rawSeq: 2,
210+
effectiveParentId: "user-1",
211+
activeMessagePosition: 1,
212+
},
213+
messages: [message],
214+
prePromptMessageCount: 1,
215+
sessionId: "session-1",
216+
sessionKey: "agent:main:session-1",
217+
sessionTarget: { agentId: "main", sessionId: "session-1" },
218+
runtimeSettings,
219+
runtimeContext: { tokenBudget: 1000 },
220+
});
221+
222+
expect(commitTurnCalls).toEqual([
223+
expect.objectContaining({
224+
advancementKey: "turn-1",
225+
sessionId: "session-1",
226+
runtimeSettings,
227+
}),
228+
]);
229+
expect(commitTurnCalls[0]).not.toHaveProperty("sessionKey");
230+
expect(commitTurnCalls[0]).not.toHaveProperty("sessionTarget");
231+
expect(commitTurnCalls[0]).not.toHaveProperty("runtimeContext");
232+
await Promise.allSettled([
233+
resolution.configured.engine.dispose?.(),
234+
resolution.fallback.engine.dispose?.(),
235+
]);
236+
});
237+
173238
it("passes every host parameter to fresh undeclared engines after the window", async () => {
174239
vi.useFakeTimers();
175240
vi.setSystemTime(new Date("2026-08-13T00:00:00Z"));

‎src/context-engine/registry.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type RegisterContextEngineForOwnerOptions = {
4242

4343
type GuardedContextEngineMethodName = Exclude<keyof ContextEngine, "info" | "dispose">;
4444
const GUARDED_CONTEXT_ENGINE_METHODS = new Set<PropertyKey>(
45-
"bootstrap maintain ingest ingestBatch afterTurn assemble compact prepareSubagentSpawn onSubagentEnded".split(
45+
"bootstrap maintain ingest ingestBatch afterTurn commitTurn assemble compact prepareSubagentSpawn onSubagentEnded".split(
4646
" ",
4747
),
4848
);

0 commit comments

Comments
 (0)