mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:32:53 +00:00
* fix(codex): surface native compaction failures * docs: add changelog for codex compaction fix * test: align compaction failure fixtures
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createAgentAttemptLifecycleCallbacks } from "./attempt-callbacks.js";
|
|
|
|
describe("createAgentAttemptLifecycleCallbacks", () => {
|
|
it("tracks user-message persistence without closing over the agent command scope", () => {
|
|
const state = {
|
|
currentTurnUserMessagePersisted: false,
|
|
lifecycleFinishing: false,
|
|
lifecycleEnded: false,
|
|
};
|
|
const callbacks = createAgentAttemptLifecycleCallbacks(state);
|
|
|
|
callbacks.onUserMessagePersisted?.({
|
|
role: "user",
|
|
content: "hello",
|
|
timestamp: Date.now(),
|
|
});
|
|
|
|
expect(state.currentTurnUserMessagePersisted).toBe(true);
|
|
expect(state.lifecycleEnded).toBe(false);
|
|
});
|
|
|
|
it("tracks terminal lifecycle phases", () => {
|
|
const state = {
|
|
currentTurnUserMessagePersisted: false,
|
|
lifecycleFinishing: false,
|
|
lifecycleEnded: false,
|
|
};
|
|
const callbacks = createAgentAttemptLifecycleCallbacks(state);
|
|
|
|
callbacks.onAgentEvent({ stream: "lifecycle", data: { phase: "start" } });
|
|
expect(state.lifecycleEnded).toBe(false);
|
|
|
|
callbacks.onAgentEvent({ stream: "lifecycle", data: { phase: "end" } });
|
|
expect(state.lifecycleEnded).toBe(true);
|
|
});
|
|
});
|