mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-22 23:02:23 +02:00
trace artifact phase provider contract
This commit is contained in:
@@ -4436,6 +4436,17 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contrac
|
|||||||
streamed_round_text = False
|
streamed_round_text = False
|
||||||
request = search_tool_choice_request(request)
|
request = search_tool_choice_request(request)
|
||||||
request = provider_compatible_tool_choice_request(request, model)
|
request = provider_compatible_tool_choice_request(request, model)
|
||||||
|
if artifact_write_phase and not successful_artifact_write:
|
||||||
|
yield event({
|
||||||
|
'type': 'provider_request_contract',
|
||||||
|
'round': round_number,
|
||||||
|
'artifact_write_phase': True,
|
||||||
|
'offered_tools': [
|
||||||
|
schema.get('function', {}).get('name')
|
||||||
|
for schema in request.get('tools', [])
|
||||||
|
],
|
||||||
|
'tool_choice': request.get('tool_choice'),
|
||||||
|
})
|
||||||
async with preview_model_response(client, endpoint_url, headers, request, context_recovery) as response:
|
async with preview_model_response(client, endpoint_url, headers, request, context_recovery) as response:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
async for line in response.aiter_lines():
|
async for line in response.aiter_lines():
|
||||||
|
|||||||
@@ -4703,6 +4703,16 @@ async def test_native_stream_reserves_remaining_budget_for_required_artifact(mon
|
|||||||
and event.get("reason") == "artifact_write_budget_reserved"
|
and event.get("reason") == "artifact_write_budget_reserved"
|
||||||
)
|
)
|
||||||
assert recovery["calls_used"] == module.NATIVE_ARTIFACT_RESEARCH_LIMIT
|
assert recovery["calls_used"] == module.NATIVE_ARTIFACT_RESEARCH_LIMIT
|
||||||
|
request_contract = next(
|
||||||
|
event for event in events
|
||||||
|
if event.get("type") == "provider_request_contract"
|
||||||
|
and event.get("artifact_write_phase") is True
|
||||||
|
)
|
||||||
|
assert "write_file" in request_contract["offered_tools"]
|
||||||
|
assert "web_search" not in request_contract["offered_tools"]
|
||||||
|
assert request_contract["tool_choice"] == {
|
||||||
|
"type": "function", "function": {"name": "write_file"},
|
||||||
|
}
|
||||||
reserved_names = [tool["function"]["name"] for tool in requests[12]["tools"]]
|
reserved_names = [tool["function"]["name"] for tool in requests[12]["tools"]]
|
||||||
assert "write_file" in reserved_names
|
assert "write_file" in reserved_names
|
||||||
assert "web_search" not in reserved_names
|
assert "web_search" not in reserved_names
|
||||||
|
|||||||
Reference in New Issue
Block a user