fix: scope observation to current turn
Require assistant natural language after the latest user message so a completed prompt cannot reuse historical replies when queuing the observation snapshot.
This commit is contained in:
@@ -220,6 +220,45 @@ describe('local Agent session sync', () => {
|
||||
expect(pushSessionDataMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not reuse an older assistant reply when the current turn has no reply', async () => {
|
||||
const base = createProductSnapshot('conversation-1');
|
||||
queueCodingConversationSessionSync({
|
||||
...base,
|
||||
nodes: [
|
||||
{
|
||||
kind: 'message',
|
||||
id: 'old-user',
|
||||
role: 'user',
|
||||
status: 'complete',
|
||||
blocks: [{ kind: 'text', id: 'old-question', text: '旧问题', status: 'complete' }],
|
||||
},
|
||||
{
|
||||
kind: 'message',
|
||||
id: 'old-assistant',
|
||||
role: 'assistant',
|
||||
status: 'complete',
|
||||
blocks: [{ kind: 'text', id: 'old-answer', text: '旧回答', status: 'complete' }],
|
||||
},
|
||||
{
|
||||
kind: 'message',
|
||||
id: 'current-user',
|
||||
role: 'user',
|
||||
status: 'complete',
|
||||
blocks: [{ kind: 'text', id: 'current-question', text: '新问题', status: 'complete' }],
|
||||
},
|
||||
],
|
||||
run: {
|
||||
status: 'idle',
|
||||
runId: 'run-2',
|
||||
settledAt: Date.parse('2026-08-24T08:01:00.000Z'),
|
||||
terminalReason: 'completed',
|
||||
},
|
||||
});
|
||||
await flushPendingAgentSessionSync();
|
||||
|
||||
expect(pushSessionDataMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('never uploads a pending snapshot under a different authenticated account', async () => {
|
||||
queueAgentSessionSync('prj_1', 'ses_1', [
|
||||
{ id: 'user-1', role: 'user', content: '账号 A 的问题' },
|
||||
|
||||
Reference in New Issue
Block a user