This commit is contained in:
marbence101 2026-11-18 14:50:11 +01:00 • committed by GitHub
commit 6c69c40a2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 44 additions and 1 deletions

View file

@ -350,6 +350,47 @@ describe('assertResumeRuntimeContentAllowed', () => {
);
});
it('resolves earlier-turn checkpoint sources in a temporary chat', async () => {
const dependencies = createDependencies();
dependencies.getAgentCheckpointer.mockResolvedValue({
getTuple: jest.fn().mockResolvedValue({
checkpoint: {
channel_values: {
messages: [
{
role: 'human',
additional_kwargs: { sourceMessageId: 'earlier-turn' },
},
{
role: 'human',
additional_kwargs: { sourceMessageId: 'paused-turn' },
},
],
},
},
}),
});
dependencies.getMessages.mockResolvedValue([
{ messageId: 'earlier-turn', isCreatedByUser: true, role: 'user', text: 'hi' },
{ messageId: 'paused-turn', isCreatedByUser: true, role: 'user', text: 'ask me' },
]);
const input = {
...createInput({}),
isTemporary: true,
storedMessages: [{ messageId: 'paused-turn', isCreatedByUser: true, role: 'user' }],
};
await expect(assertResumeRuntimeContentAllowed(input, dependencies)).resolves.toEqual({
resolvedFiles: [],
checkpointFiles: [],
});
expect(dependencies.getMessages).toHaveBeenCalledWith({
conversationId: 'conversation-1',
user: 'user-1',
});
expect(dependencies.getFiles).not.toHaveBeenCalled();
});
it('preserves repeated steer file injections in checkpoint projection', async () => {
const dependencies = createDependencies();
dependencies.getAgentCheckpointer.mockResolvedValue({

View file

@ -1048,9 +1048,11 @@ export async function assertResumeRuntimeContentAllowed(
const missingSourceMessageIds = [...checkpointSourceMessageIds].filter(
(messageId) => !resolvedSourceMessageIds.has(messageId),
);
/** The preflight only carries the paused turn; earlier turns referenced by the
* checkpoint are read back for temporary chats too, whose messages stay
* persisted until `expiredAt`. */
if (
modelBoundProjection?.historyLoaded !== true &&
!input.isTemporary &&
missingSourceMessageIds.length > 0 &&
input.user?.id
) {