mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-30 01:32:25 +01:00
Complete required research before repairing final-answer presentation
This commit is contained in:
+13
-10
@@ -4313,8 +4313,17 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contrac
|
|||||||
history[-1]['content'] = content
|
history[-1]['content'] = content
|
||||||
yield event({'delta': content})
|
yield event({'delta': content})
|
||||||
break
|
break
|
||||||
|
research_expansion_due = (
|
||||||
|
broad_current_web_request(direct_user_text)
|
||||||
|
and successful_web_searches == 1
|
||||||
|
and web_search_attempts < 2
|
||||||
|
and not breadth_recovery_attempted
|
||||||
|
and not search_completion_attempted
|
||||||
|
and round_number < round_limit
|
||||||
|
)
|
||||||
if (
|
if (
|
||||||
requested_web_source_links(direct_user_text)
|
not research_expansion_due
|
||||||
|
and requested_web_source_links(direct_user_text)
|
||||||
and successful_web_searches
|
and successful_web_searches
|
||||||
and not re.search(r'https?://\S+', content or '')
|
and not re.search(r'https?://\S+', content or '')
|
||||||
and not citation_recovery_attempted
|
and not citation_recovery_attempted
|
||||||
@@ -4341,7 +4350,8 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contrac
|
|||||||
yield event({'type': 'completion_recovery', 'reason': 'requested_source_link_missing'})
|
yield event({'type': 'completion_recovery', 'reason': 'requested_source_link_missing'})
|
||||||
continue
|
continue
|
||||||
if (
|
if (
|
||||||
contentless_final_response(content)
|
not research_expansion_due
|
||||||
|
and contentless_final_response(content)
|
||||||
and answer_recovery_attempts == 0
|
and answer_recovery_attempts == 0
|
||||||
and round_number < round_limit
|
and round_number < round_limit
|
||||||
):
|
):
|
||||||
@@ -4359,14 +4369,7 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contrac
|
|||||||
})
|
})
|
||||||
yield event({'type': 'completion_recovery', 'reason': 'contentless_answer'})
|
yield event({'type': 'completion_recovery', 'reason': 'contentless_answer'})
|
||||||
continue
|
continue
|
||||||
if (
|
if research_expansion_due:
|
||||||
broad_current_web_request(direct_user_text)
|
|
||||||
and successful_web_searches == 1
|
|
||||||
and web_search_attempts < 2
|
|
||||||
and not breadth_recovery_attempted
|
|
||||||
and not search_completion_attempted
|
|
||||||
and round_number < round_limit
|
|
||||||
):
|
|
||||||
breadth_recovery_attempted = True
|
breadth_recovery_attempted = True
|
||||||
force_web_search_next_round = True
|
force_web_search_next_round = True
|
||||||
replace_streamed_draft_on_finish = True
|
replace_streamed_draft_on_finish = True
|
||||||
|
|||||||
@@ -1199,7 +1199,8 @@ async def test_stream_bounds_research_to_two_searches_fetch_then_synthesis(monke
|
|||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.parametrize('embedded_article', [False, True])
|
@pytest.mark.parametrize('embedded_article', [False, True])
|
||||||
@pytest.mark.parametrize('empty_second_search', [False, True])
|
@pytest.mark.parametrize('empty_second_search', [False, True])
|
||||||
async def test_stream_retries_an_obviously_truncated_broad_web_answer(monkeypatch, embedded_article, empty_second_search):
|
@pytest.mark.parametrize('sources_requested', [False, True])
|
||||||
|
async def test_stream_retries_an_obviously_truncated_broad_web_answer(monkeypatch, embedded_article, empty_second_search, sources_requested):
|
||||||
"""Broad current research expands, retrieves evidence, then synthesizes."""
|
"""Broad current research expands, retrieves evidence, then synthesizes."""
|
||||||
import src.clean_agent_preview as module
|
import src.clean_agent_preview as module
|
||||||
|
|
||||||
@@ -1286,7 +1287,7 @@ async def test_stream_retries_an_obviously_truncated_broad_web_answer(monkeypatc
|
|||||||
contract = resolve_full_inventory_contract(schemas=schemas, policy=ToolPolicy())
|
contract = resolve_full_inventory_contract(schemas=schemas, policy=ToolPolicy())
|
||||||
raw = [chunk async for chunk in stream_preview(
|
raw = [chunk async for chunk in stream_preview(
|
||||||
endpoint_url='http://test', model='test',
|
endpoint_url='http://test', model='test',
|
||||||
messages=[{'role': 'user', 'content': 'Latest news in AI?'}],
|
messages=[{'role': 'user', 'content': 'Latest news in AI?' + (' Include source links.' if sources_requested else '')}],
|
||||||
headers={}, turn_contract=contract, session_id='test', owner='test',
|
headers={}, turn_contract=contract, session_id='test', owner='test',
|
||||||
disabled_tools=set(), tool_policy=ToolPolicy(), max_rounds=5,
|
disabled_tools=set(), tool_policy=ToolPolicy(), max_rounds=5,
|
||||||
)]
|
)]
|
||||||
|
|||||||
Reference in New Issue
Block a user