Reconcile corrected research drafts into one formatted answer

This commit is contained in:
pewdiepie-archdaemon
2026-09-17 22:25:39 +00:00
parent 1d8f73b9a0
commit 19fcb9ad01
4 changed files with 33 additions and 3 deletions
+4
View File
@@ -1321,6 +1321,10 @@ async def test_stream_retries_an_obviously_truncated_broad_web_answer(monkeypatc
# incomplete draft rather than persisting both as one answer.
final = [event['content'] for event in events if event.get('type') == 'final_response'][-1]
assert 'Current AI news includes reports about U.' not in final
replacement = next(event for event in events if event.get('type') == 'final_response')
assert replacement['replacement_scope'] == 'turn'
assert replacement['render_owner'] == 'streamed'
assert any(event.get('delta') and event.get('replacement_scope') == 'turn' for event in events)
def test_task_renderer_honors_few_and_filters_confirmed_morning_schedule():
+10
View File
@@ -262,6 +262,16 @@ test('explicit turn replacement resumes legitimate synthesis after an intermedia
assert.deepEqual(result, { resumed: true, appended: true, text: 'Synthesis continues', sameThread: true });
});
test('corrected research replaces earlier prose while preserving tools and markdown', async () => {
const result = await run('<div class="msg-ai"><div class="body">Unfinished news draft</div></div><div class="agent-thread">Search activity</div><div class="msg-ai"><div class="body" id="answer">Corrected answer</div></div>', () => {
const body = document.querySelector('#answer');
const thread = document.querySelector('.agent-thread');
owner.render({body, html: '<h3>Politics</h3><p><strong>Cabinet changes</strong>: supported details.</p><p><a href="https://example.org">Original report</a></p>', raw: '### Politics\n**Cabinet changes**: supported details.', render_owner: 'streamed', replacement_scope: 'turn'});
return {bubbles: document.querySelectorAll('.msg-ai').length, sameThread: thread === document.querySelector('.agent-thread'), heading: body.querySelector('h3')?.textContent, bold: body.querySelector('strong')?.textContent, link: body.querySelector('a')?.getAttribute('href'), oldDraft: document.body.textContent.includes('Unfinished news draft')};
});
assert.deepEqual(result, {bubbles: 1, sameThread: true, heading: 'Politics', bold: 'Cabinet changes', link: 'https://example.org', oldDraft: false});
});
test('a scoped streamed final can replace structured content but thinking cannot transfer ownership', async () => {
const result = await run('<div class="msg-ai"><div class="body"></div></div>', () => {
const body = document.querySelector('.body');