@@ -2168,8 +2168,9 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
21682168 expect ( hoisted . sessionManager . branch ) . toHaveBeenCalledWith ( "parent-leaf" ) ;
21692169 } ) ;
21702170
2171- it ( "keeps current inbound context visible on runtime-only turns" , async ( ) => {
2171+ it ( "keeps current inbound context available as runtime system context on runtime-only turns" , async ( ) => {
21722172 let seenPrompt : string | undefined ;
2173+ let seenSystemPrompt : string | undefined ;
21732174
21742175 const result = await createContextEngineAttemptRunner ( {
21752176 contextEngine : createContextEngineBootstrapAndAssemble ( ) ,
@@ -2194,27 +2195,31 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
21942195 } ,
21952196 sessionPrompt : async ( session , prompt ) => {
21962197 seenPrompt = prompt ;
2198+ seenSystemPrompt = session . agent . state . systemPrompt ;
21972199 session . messages = [
21982200 ...session . messages ,
21992201 { role : "assistant" , content : "done" , timestamp : 2 } ,
22002202 ] ;
22012203 } ,
22022204 } ) ;
22032205
2204- expect ( seenPrompt ) . toContain ( "Reply target of current user message (untrusted, for context):" ) ;
2205- expect ( seenPrompt ) . toContain ( "Hello from the replied message" ) ;
2206- expect ( seenPrompt ) . toContain ( "Continue the OpenClaw runtime event." ) ;
2206+ expect ( seenPrompt ) . toBe ( "Continue the OpenClaw runtime event." ) ;
2207+ expect ( seenSystemPrompt ) . toContain (
2208+ "Reply target of current user message (untrusted, for context):" ,
2209+ ) ;
2210+ expect ( seenSystemPrompt ) . toContain ( "Hello from the replied message" ) ;
22072211 expect ( result . finalPromptText ) . toBe ( seenPrompt ) ;
22082212 const trajectoryEvents = await readTrajectoryEvents ( tempPaths ) ;
22092213 const contextCompiled = trajectoryEvents . find ( ( event ) => event . type === "context.compiled" ) ;
2210- expect ( contextCompiled ?. data ?. prompt ) . toContain ( "Hello from the replied message ") ;
2214+ expect ( contextCompiled ?. data ?. prompt ) . toBe ( "Continue the OpenClaw runtime event. ") ;
22112215 expect ( contextCompiled ?. data ?. systemPrompt ) . toContain ( "runtime bare mention event" ) ;
2216+ expect ( contextCompiled ?. data ?. systemPrompt ) . toContain ( "Hello from the replied message" ) ;
22122217 } ) ;
22132218
2214- it ( "submits suppressed room event context as the model prompt " , async ( ) => {
2219+ it ( "submits suppressed room event context as runtime context " , async ( ) => {
22152220 let seenPrompt : string | undefined ;
2216- let seenModelMessages : unknown [ ] | undefined ;
22172221 let seenMessages : unknown [ ] | undefined ;
2222+ let seenModelMessages : unknown [ ] | undefined ;
22182223 const runBeforePromptBuild = vi . fn ( async ( ) => ( {
22192224 prependContext : "dynamic hook context" ,
22202225 appendContext : "dynamic hook tail" ,
@@ -2268,17 +2273,19 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
22682273 // routed into the runtime-context carrier instead of the user text.
22692274 expect ( seenPrompt ) . toBe ( "[OpenClaw room event]" ) ;
22702275 expect ( seenPrompt ) . not . toContain ( "inbound_event_kind: room_event" ) ;
2276+ expect ( seenPrompt ) . not . toContain ( "visible_reply_contract: message_tool_only" ) ;
2277+ expect ( seenPrompt ) . not . toContain ( "Current event:\n#2003 Bob: hey claw summarize the plan" ) ;
22712278 expect ( seenPrompt ) . not . toBe ( "Continue the OpenClaw runtime event." ) ;
22722279 expect ( seenPrompt ) . not . toContain ( "dynamic hook context" ) ;
22732280 expect ( seenPrompt ) . not . toContain ( "dynamic hook tail" ) ;
2274- const roomRuntimeContext = findRecord (
2281+ const runtimeContext = findRecord (
22752282 requireRecords ( seenMessages , "seen messages" ) ,
22762283 ( message ) => message . customType === "openclaw.runtime-context" ,
22772284 "runtime context message" ,
22782285 ) ;
2279- expect ( roomRuntimeContext . content ) . toContain ( "inbound_event_kind: room_event" ) ;
2280- expect ( roomRuntimeContext . content ) . toContain ( "visible_reply_contract: message_tool_only" ) ;
2281- expect ( roomRuntimeContext . content ) . toContain (
2286+ expect ( runtimeContext . content ) . toContain ( "inbound_event_kind: room_event" ) ;
2287+ expect ( runtimeContext . content ) . toContain ( "visible_reply_contract: message_tool_only" ) ;
2288+ expect ( runtimeContext . content ) . toContain (
22822289 "Current event:\n#2003 Bob: hey claw summarize the plan" ,
22832290 ) ;
22842291 expect ( JSON . stringify ( seenModelMessages ) ) . toContain ( "dynamic hook context" ) ;
@@ -2291,6 +2298,9 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
22912298 "visible_reply_contract: message_tool_only" ,
22922299 ) ;
22932300 expect ( contextCompiled ?. data ?. prompt ) . toContain ( "[OpenClaw room event]" ) ;
2301+ expect ( contextCompiled ?. data ?. prompt ) . not . toContain (
2302+ "visible_reply_contract: message_tool_only" ,
2303+ ) ;
22942304 } ) ;
22952305
22962306 it ( "skips blank visible prompts with replay history before provider submission" , async ( ) => {
0 commit comments