feat(trial): assemble completed Agent workspace updates
This commit is contained in:
1 parent
8289f27f3e
commit
7c51bb4a00
38 files changed
+2081
-276
No files matched your search
@@ -10,7 +10,7 @@ describe('personal Agent main-thread stream projection', () => {
|
||||
it('separates reasoning and answers in batched and single chunks with legacy fallback', () => {
|
||||
let state = consume(null, envelope([delta({ reasoning_content: '思考一', additional_reasoning_content: '不应重复', content: '回答一' })]));
|
||||
state = consume(state, { run_id: 'run-1', thread_id: 'thread-1', payload: { chunk: delta({ additional_reasoning_content: '思考二', content: '回答二' }) } }, '2-0');
|
||||
expect(state).toMatchObject({ reasoning: '思考一思考二', content: '回答一回答二', cursor: '2-0' });
|
||||
expect(state).toMatchObject({ messages: [{ reasoning_content: '思考一思考二', content: '回答一回答二' }], cursor: '2-0' });
|
||||
expect(JSON.stringify(state)).not.toContain('不应重复');
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('personal Agent main-thread stream projection', () => {
|
||||
{ stream_event: { type: 'tool_call', name: 'search', arguments: 'private tool args' } },
|
||||
delta({ message_id: 'message-2', reasoning_content: '核对资料', content: '第二段' }),
|
||||
]));
|
||||
expect(state).toMatchObject({ reasoning: '先看资料\n\n核对资料', content: '第一段\n\n第二段', toolName: 'search' });
|
||||
expect(state).toMatchObject({ messages: [{ reasoning_content: '先看资料', content: '第一段', tool_calls: [{ name: 'search' }] }, { reasoning_content: '核对资料', content: '第二段' }] });
|
||||
expect(JSON.stringify(state)).not.toContain('private tool args');
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('personal Agent main-thread stream projection', () => {
|
||||
expect(consume(state, envelope([delta({ reasoning_content: '另一个请求' })], { request_id: 'request-2' }), '2-0')).toBe(state);
|
||||
const child = consume(state, envelope([delta({ reasoning_content: '子线程' })], { thread_id: 'child-thread' }), '2-0');
|
||||
const missing = consume(child, envelope([delta({ content: '缺身份' })], { thread_id: undefined }), '3-0');
|
||||
expect(missing).toMatchObject({ reasoning: '父线程', content: '', cursor: '3-0', ended: false });
|
||||
expect(missing).toMatchObject({ messages: [{ reasoning_content: '父线程', content: '' }], cursor: '3-0', ended: false });
|
||||
expect(consume(missing, envelope([], { thread_id: 'child-thread' }), '4-0', 'end')).toMatchObject({ ended: false });
|
||||
});
|
||||
|
||||
@@ -39,16 +39,16 @@ describe('personal Agent main-thread stream projection', () => {
|
||||
expect(consume(state, envelope([delta({ reasoning_content: '重放' })]), '99999999999999999999-1')).toBe(state);
|
||||
expect(consume(state, envelope([delta({ reasoning_content: '迟到' })]), '99999999999999999998-99')).toBe(state);
|
||||
const next = consume(state, envelope([delta({ reasoning_content: '二次' })]), '99999999999999999999-2');
|
||||
expect(consume(next, envelope([]), '99999999999999999999-2', 'end')).toMatchObject({ reasoning: '一次二次', ended: true });
|
||||
expect(consume(next, envelope([]), '99999999999999999999-2', 'end')).toMatchObject({ messages: [{ reasoning_content: '一次二次' }], ended: true });
|
||||
});
|
||||
|
||||
it('keeps missing-ID compatibility and retains same-request reasoning over a resumed Run only', () => {
|
||||
const first = consume(null, envelope([delta({ reasoning_content: '之前', content: '旧预览' })]), '');
|
||||
const next = consumeCloudChatEvent(first, envelope([delta({ message_id: 'message-2', reasoning_content: '继续', content: '新预览' })], { run_id: 'run-2' }),
|
||||
const next = consumeCloudChatEvent(first, envelope([delta({ reasoning_content: '继续', content: '新预览' })], { run_id: 'run-2' }),
|
||||
'messages', '1-0', 'run-2', 'thread-1', 'request-1');
|
||||
expect(next).toMatchObject({ cursor: '1-0', reasoning: '之前\n\n继续', content: '新预览', ended: false });
|
||||
expect(next).toMatchObject({ cursor: '1-0', messages: [{ run_id: 'run-1', reasoning_content: '之前', content: '旧预览' }, { run_id: 'run-2', reasoning_content: '继续', content: '新预览' }], ended: false });
|
||||
const other = consumeCloudChatEvent(next, envelope([delta({ reasoning_content: '新问题' })], { run_id: 'run-3', request_id: 'request-3' }),
|
||||
'messages', '1-0', 'run-3', 'thread-1', 'request-3');
|
||||
expect(other).toMatchObject({ reasoning: '新问题', content: '' });
|
||||
expect(other).toMatchObject({ messages: [{ reasoning_content: '新问题', content: '' }] });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user