Self-hosted AI workspace.
Python
count artifact handoff once per response batch
pewdiepie-archdaemona453b716513d
diff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.pyindex 73fe39b15..1d5b466a5 100644--- a/src/clean_agent_preview.py+++ b/src/clean_agent_preview.py@@ -5471,6 +5471,7 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contracif (repeated_handoff_targetand artifact_body_handoff_attempts < 2+ and not artifact_body_handoff_target):artifact_body_handoff_attempts += 1artifact_body_handoff_target = repeated_handoff_targetdiff --git a/tests/test_clean_agent_preview.py b/tests/test_clean_agent_preview.pyindex d99de2213..5dd85663b 100644--- a/tests/test_clean_agent_preview.py+++ b/tests/test_clean_agent_preview.py@@ -547,6 +547,11 @@ async def test_repeated_off_contract_calls_recover_via_required_artifact_body(mo'function': {'name': 'python', 'arguments': json.dumps({'code': 'print("nope")',})},+ }, {+ 'index': 1, 'id': 'bad-inspect-sibling',+ 'function': {'name': 'inspect_media', 'arguments': json.dumps({+ 'path': '/workspace/input.png',+ })},}]}}]},{'choices': [{'delta': {'content': ''}}]},{'choices': [{'delta': {'content': '<html><body>Recovered</body></html>'}}]},@@ -605,7 +610,7 @@ async def test_repeated_off_contract_calls_recover_via_required_artifact_body(moevent.get('type') == 'tool_output'and event.get('execution_attempted') is Falsefor event in events- ) == 2+ ) == 3assert any(event.get('type') == 'artifact_body_handoff'and event.get('path') == '/workspace/output.html'