diff --git a/src/context-engine.ts b/src/context-engine.ts index 98bc9f2..e5a2b20 100644 --- a/src/context-engine.ts +++ b/src/context-engine.ts @@ -711,7 +711,6 @@ export function buildContextEngineFactory( sessionKey: args.sessionKey, userId: args.userId, messages, - prePromptMessageCount: args.prePromptMessageCount, isHeartbeat: args.isHeartbeat, }); await performAfterTurnPredictiveCompaction({ @@ -723,8 +722,11 @@ export function buildContextEngineFactory( } const rpc = await runtime.getRpc(); const result = await rpc.call("after_turn_kernel", { - ...args, + sessionId: args.sessionId, + sessionKey: args.sessionKey, + userId: args.userId, messages, + isHeartbeat: args.isHeartbeat, }); await performAfterTurnPredictiveCompaction({ sessionId: args.sessionId, diff --git a/test/integration/host-flow.test.ts b/test/integration/host-flow.test.ts index c13df1f..c9a3c93 100644 --- a/test/integration/host-flow.test.ts +++ b/test/integration/host-flow.test.ts @@ -445,7 +445,7 @@ test("compact omits invalid currentTokenCount values from the wire request", asy assert.equal("currentTokenCount" in params, false); }); -test("afterTurn forwards message arrays and pre-prompt counts correctly", async () => { +test("afterTurn forwards only daemon-relevant fields, strips prePromptMessageCount", async () => { const rpc = new StaticContractRpc(); const recallCache = createRecallCache(); const cfg: PluginConfig = { rpcTimeoutMs: 1000 }; @@ -469,7 +469,7 @@ test("afterTurn forwards message arrays and pre-prompt counts correctly", async assert.ok(params, "Expected after_turn_kernel to be called"); assert.equal(params.sessionId, "test-session"); assert.equal(params.userId, "test-user"); - assert.equal(params.prePromptMessageCount, 2); + assert.equal("prePromptMessageCount" in params, false, "prePromptMessageCount must not leak to daemon — daemon defaults to 0 and uses content-hash dedup"); assert.equal(params.isHeartbeat, false); assert.deepEqual(params.messages, mockMessages); });