mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:24:33 +00:00
fix: preserve inter-session input provenance (thanks @anbecker)
This commit is contained in:
@@ -112,6 +112,36 @@ describe("sanitizeSessionHistory", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("annotates inter-session user messages before context sanitization", async () => {
|
||||
vi.mocked(helpers.isGoogleModelApi).mockReturnValue(false);
|
||||
|
||||
const messages: AgentMessage[] = [
|
||||
{
|
||||
role: "user",
|
||||
content: "forwarded instruction",
|
||||
provenance: {
|
||||
kind: "inter_session",
|
||||
sourceSessionKey: "agent:main:req",
|
||||
sourceTool: "sessions_send",
|
||||
},
|
||||
} as unknown as AgentMessage,
|
||||
];
|
||||
|
||||
const result = await sanitizeSessionHistory({
|
||||
messages,
|
||||
modelApi: "openai-responses",
|
||||
provider: "openai",
|
||||
sessionManager: mockSessionManager,
|
||||
sessionId: "test-session",
|
||||
});
|
||||
|
||||
const first = result[0] as Extract<AgentMessage, { role: "user" }>;
|
||||
expect(first.role).toBe("user");
|
||||
expect(typeof first.content).toBe("string");
|
||||
expect(first.content as string).toContain("[Inter-session message]");
|
||||
expect(first.content as string).toContain("sourceSession=agent:main:req");
|
||||
});
|
||||
|
||||
it("keeps reasoning-only assistant messages for openai-responses", async () => {
|
||||
vi.mocked(helpers.isGoogleModelApi).mockReturnValue(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user