mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:10:51 +00:00
test: trim cron and context-engine waits
This commit is contained in:
@@ -145,6 +145,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
|
|||||||
contextEngine: createContextEngineBootstrapAndAssemble(),
|
contextEngine: createContextEngineBootstrapAndAssemble(),
|
||||||
sessionKey,
|
sessionKey,
|
||||||
tempPaths,
|
tempPaths,
|
||||||
|
trajectory: true,
|
||||||
attemptOverrides: {
|
attemptOverrides: {
|
||||||
prompt: [
|
prompt: [
|
||||||
"visible ask",
|
"visible ask",
|
||||||
@@ -389,6 +390,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as OpenClawConfig,
|
} as OpenClawConfig,
|
||||||
|
disableTools: false,
|
||||||
prompt: "visible ask",
|
prompt: "visible ask",
|
||||||
transcriptPrompt: "visible ask",
|
transcriptPrompt: "visible ask",
|
||||||
trigger: "user",
|
trigger: "user",
|
||||||
@@ -471,6 +473,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
|
|||||||
contextEngine: createContextEngineBootstrapAndAssemble(),
|
contextEngine: createContextEngineBootstrapAndAssemble(),
|
||||||
sessionKey,
|
sessionKey,
|
||||||
tempPaths,
|
tempPaths,
|
||||||
|
trajectory: true,
|
||||||
attemptOverrides: {
|
attemptOverrides: {
|
||||||
prompt: [
|
prompt: [
|
||||||
"what does this mean?",
|
"what does this mean?",
|
||||||
@@ -565,6 +568,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
|
|||||||
contextEngine: createContextEngineBootstrapAndAssemble(),
|
contextEngine: createContextEngineBootstrapAndAssemble(),
|
||||||
sessionKey,
|
sessionKey,
|
||||||
tempPaths,
|
tempPaths,
|
||||||
|
trajectory: true,
|
||||||
attemptOverrides: {
|
attemptOverrides: {
|
||||||
prompt: "internal heartbeat event",
|
prompt: "internal heartbeat event",
|
||||||
transcriptPrompt: "",
|
transcriptPrompt: "",
|
||||||
@@ -608,6 +612,7 @@ describe("runEmbeddedAttempt context engine sessionKey forwarding", () => {
|
|||||||
contextEngine: createContextEngineBootstrapAndAssemble(),
|
contextEngine: createContextEngineBootstrapAndAssemble(),
|
||||||
sessionKey,
|
sessionKey,
|
||||||
tempPaths,
|
tempPaths,
|
||||||
|
trajectory: true,
|
||||||
attemptOverrides: {
|
attemptOverrides: {
|
||||||
prompt: " \n\t ",
|
prompt: " \n\t ",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1027,6 +1027,7 @@ export async function createContextEngineAttemptRunner(params: {
|
|||||||
sessionPrompt?: SessionPromptOverride;
|
sessionPrompt?: SessionPromptOverride;
|
||||||
sessionKey: string;
|
sessionKey: string;
|
||||||
tempPaths: string[];
|
tempPaths: string[];
|
||||||
|
trajectory?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { maintain: rawMaintain, ...contextEngineRest } = params.contextEngine;
|
const { maintain: rawMaintain, ...contextEngineRest } = params.contextEngine;
|
||||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-ctx-engine-workspace-"));
|
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-ctx-engine-workspace-"));
|
||||||
@@ -1062,50 +1063,63 @@ export async function createContextEngineAttemptRunner(params: {
|
|||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return await (
|
const previousTrajectoryEnv = process.env.OPENCLAW_TRAJECTORY;
|
||||||
await loadRunEmbeddedAttempt()
|
if (params.trajectory !== true) {
|
||||||
)({
|
process.env.OPENCLAW_TRAJECTORY = "0";
|
||||||
sessionId: "embedded-session",
|
}
|
||||||
sessionKey: params.sessionKey,
|
try {
|
||||||
sessionFile,
|
return await (
|
||||||
workspaceDir,
|
await loadRunEmbeddedAttempt()
|
||||||
agentDir,
|
)({
|
||||||
config: {},
|
sessionId: "embedded-session",
|
||||||
prompt: "hello",
|
sessionKey: params.sessionKey,
|
||||||
timeoutMs: 10_000,
|
sessionFile,
|
||||||
runId: "run-context-engine-forwarding",
|
workspaceDir,
|
||||||
provider: "openai",
|
agentDir,
|
||||||
modelId: "gpt-test",
|
config: {},
|
||||||
model: testModel,
|
prompt: "hello",
|
||||||
authStorage: testAuthStorage as never,
|
timeoutMs: 10_000,
|
||||||
authProfileStore: { version: 1, profiles: {} },
|
runId: "run-context-engine-forwarding",
|
||||||
modelRegistry: {} as never,
|
provider: "openai",
|
||||||
thinkLevel: "off",
|
modelId: "gpt-test",
|
||||||
senderIsOwner: true,
|
model: testModel,
|
||||||
disableMessageTool: true,
|
authStorage: testAuthStorage as never,
|
||||||
contextTokenBudget: 2048,
|
authProfileStore: { version: 1, profiles: {} },
|
||||||
contextEngine: {
|
modelRegistry: {} as never,
|
||||||
...contextEngineRest,
|
thinkLevel: "off",
|
||||||
ingest:
|
senderIsOwner: true,
|
||||||
params.contextEngine.ingest ??
|
disableTools: true,
|
||||||
(async () => ({
|
disableMessageTool: true,
|
||||||
ingested: true,
|
contextTokenBudget: 2048,
|
||||||
})),
|
contextEngine: {
|
||||||
compact:
|
...contextEngineRest,
|
||||||
params.contextEngine.compact ??
|
ingest:
|
||||||
(async () => ({
|
params.contextEngine.ingest ??
|
||||||
ok: false,
|
(async () => ({
|
||||||
compacted: false,
|
ingested: true,
|
||||||
reason: "not used in this test",
|
})),
|
||||||
})),
|
compact:
|
||||||
...(maintain ? { maintain } : {}),
|
params.contextEngine.compact ??
|
||||||
info: {
|
(async () => ({
|
||||||
...params.contextEngine.info,
|
ok: false,
|
||||||
id: infoId,
|
compacted: false,
|
||||||
name: infoName,
|
reason: "not used in this test",
|
||||||
version: infoVersion,
|
})),
|
||||||
|
...(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -906,7 +906,7 @@ describe("gateway server cron", () => {
|
|||||||
const autoRes = await rpcReq(ws, "cron.add", {
|
const autoRes = await rpcReq(ws, "cron.add", {
|
||||||
name: "auto run test",
|
name: "auto run test",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
schedule: { kind: "at", at: new Date(Date.now() + 200).toISOString() },
|
schedule: { kind: "at", at: new Date(Date.now() - 1).toISOString() },
|
||||||
sessionTarget: "main",
|
sessionTarget: "main",
|
||||||
wakeMode: "next-heartbeat",
|
wakeMode: "next-heartbeat",
|
||||||
payload: { kind: "systemEvent", text: "auto" },
|
payload: { kind: "systemEvent", text: "auto" },
|
||||||
|
|||||||
Reference in New Issue
Block a user