diff --git a/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts b/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts index 08b4267c194..3905606244f 100644 --- a/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts +++ b/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts @@ -145,6 +145,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => { contextEngine: createContextEngineBootstrapAndAssemble(), sessionKey, tempPaths, + trajectory: true, attemptOverrides: { prompt: [ "visible ask", @@ -389,6 +390,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => { }, }, } as OpenClawConfig, + disableTools: false, prompt: "visible ask", transcriptPrompt: "visible ask", trigger: "user", @@ -471,6 +473,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => { contextEngine: createContextEngineBootstrapAndAssemble(), sessionKey, tempPaths, + trajectory: true, attemptOverrides: { prompt: [ "what does this mean?", @@ -565,6 +568,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => { contextEngine: createContextEngineBootstrapAndAssemble(), sessionKey, tempPaths, + trajectory: true, attemptOverrides: { prompt: "internal heartbeat event", transcriptPrompt: "", @@ -608,6 +612,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => { contextEngine: createContextEngineBootstrapAndAssemble(), sessionKey, tempPaths, + trajectory: true, attemptOverrides: { prompt: " \n\t ", }, diff --git a/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.test-support.ts b/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.test-support.ts index c9d4d6e0cb7..4c38126520a 100644 --- a/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.test-support.ts +++ b/src/agents/pi-embedded-runner/run/attempt.spawn-workspace.test-support.ts @@ -1027,6 +1027,7 @@ export async function createContextEngineAttemptRunner(params: { sessionPrompt?: SessionPromptOverride; sessionKey: string; tempPaths: string[]; + trajectory?: boolean; }) { const { maintain: rawMaintain, ...contextEngineRest } = params.contextEngine; const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-ctx-engine-workspace-")); @@ -1062,50 +1063,63 @@ export async function createContextEngineAttemptRunner(params: { }), })); - return await ( - await loadRunEmbeddedAttempt() - )({ - sessionId: "embedded-session", - sessionKey: params.sessionKey, - sessionFile, - workspaceDir, - agentDir, - config: {}, - prompt: "hello", - timeoutMs: 10_000, - runId: "run-context-engine-forwarding", - provider: "openai", - modelId: "gpt-test", - model: testModel, - authStorage: testAuthStorage as never, - authProfileStore: { version: 1, profiles: {} }, - modelRegistry: {} as never, - thinkLevel: "off", - senderIsOwner: true, - disableMessageTool: true, - contextTokenBudget: 2048, - contextEngine: { - ...contextEngineRest, - ingest: - params.contextEngine.ingest ?? - (async () => ({ - ingested: true, - })), - compact: - params.contextEngine.compact ?? - (async () => ({ - ok: false, - compacted: false, - reason: "not used in this test", - })), - ...(maintain ? { maintain } : {}), - info: { - ...params.contextEngine.info, - id: infoId, - name: infoName, - version: infoVersion, + const previousTrajectoryEnv = process.env.OPENCLAW_TRAJECTORY; + if (params.trajectory !== true) { + process.env.OPENCLAW_TRAJECTORY = "0"; + } + try { + return await ( + await loadRunEmbeddedAttempt() + )({ + sessionId: "embedded-session", + sessionKey: params.sessionKey, + sessionFile, + workspaceDir, + agentDir, + config: {}, + prompt: "hello", + timeoutMs: 10_000, + runId: "run-context-engine-forwarding", + provider: "openai", + modelId: "gpt-test", + model: testModel, + authStorage: testAuthStorage as never, + authProfileStore: { version: 1, profiles: {} }, + modelRegistry: {} as never, + thinkLevel: "off", + senderIsOwner: true, + disableTools: true, + disableMessageTool: true, + contextTokenBudget: 2048, + contextEngine: { + ...contextEngineRest, + ingest: + params.contextEngine.ingest ?? + (async () => ({ + ingested: true, + })), + compact: + params.contextEngine.compact ?? + (async () => ({ + ok: false, + compacted: false, + reason: "not used in this test", + })), + ...(maintain ? { maintain } : {}), + info: { + ...params.contextEngine.info, + id: infoId, + name: infoName, + version: infoVersion, + }, }, - }, - ...params.attemptOverrides, - }); + ...params.attemptOverrides, + }); + } finally { + if (previousTrajectoryEnv === undefined) { + delete process.env.OPENCLAW_TRAJECTORY; + } else { + process.env.OPENCLAW_TRAJECTORY = previousTrajectoryEnv; + } + } } diff --git a/src/gateway/server.cron.test.ts b/src/gateway/server.cron.test.ts index e8cd6fb5972..482d1621181 100644 --- a/src/gateway/server.cron.test.ts +++ b/src/gateway/server.cron.test.ts @@ -906,7 +906,7 @@ describe("gateway server cron", () => { const autoRes = await rpcReq(ws, "cron.add", { name: "auto run test", enabled: true, - schedule: { kind: "at", at: new Date(Date.now() + 200).toISOString() }, + schedule: { kind: "at", at: new Date(Date.now() - 1).toISOString() }, sessionTarget: "main", wakeMode: "next-heartbeat", payload: { kind: "systemEvent", text: "auto" },