mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:10:44 +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(),
|
||||
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 ",
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" },
|
||||
|
||||
Reference in New Issue
Block a user