Self-hosted AI workspace.
Python
buffer rejected search drafts and cap interactive rounds
pewdiepie-archdaemonf27070c46937
diff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.pyindex 9372d1f80..ee2b418f1 100644--- a/src/clean_agent_preview.py+++ b/src/clean_agent_preview.py@@ -1307,11 +1307,11 @@ def native_execution_limits(max_rounds):def interactive_execution_limit(max_rounds):- """Honor the WebUI agent-step setting for the compact preview loop."""+ """Bound interactive turns independently of long-running native jobs."""if max_rounds is None:return INTERACTIVE_ROUND_LIMITtry:- return max(1, min(int(max_rounds), 200))+ return max(1, min(int(max_rounds), INTERACTIVE_ROUND_LIMIT))except (TypeError, ValueError):return INTERACTIVE_ROUND_LIMIT@@ -3891,6 +3891,7 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contracofficial_source_retry_attempted = Falsenote_search_recovery_attempted = Falsereplace_streamed_draft_on_finish = False+ buffer_completion_drafts = broad_current_web_request(direct_user_text)usage_in = usage_out = 0has_real_usage = Falsefirst_request_tokens = last_request_tokens = 0@@ -4108,7 +4109,11 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contracif text:first_token = first_token or time.monotonic()content += text- if not prior_summary_answer and not progressive_thinking:+ if (+ not prior_summary_answer+ and not progressive_thinking+ and not buffer_completion_drafts+ ):yield event({'delta': text})for fragment in delta.get('tool_calls') or []:call = pending.setdefault(fragment['index'], {'id': '', 'type': 'function', 'function': {'name': '', 'arguments': ''}})@@ -4118,7 +4123,7 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contraccall['function'][key] += (fragment.get('function') or {}).get(key) or ''if progressive_thinking:content = visible_content_after_qwen_thinking(content)- if content and not prior_summary_answer:+ if content and not prior_summary_answer and not buffer_completion_drafts:yield event({'delta': content})proposed = [pending[i] for i in sorted(pending)]proposed = serialize_required_email_attachment_chain(@@ -4377,7 +4382,7 @@ async def stream_preview(*, endpoint_url, model, messages, headers, turn_contracyield event({'delta': suffix})if not content:yield event({'delta': 'The test model returned no answer. No substitute answer was generated.'})- elif replace_streamed_draft_on_finish:+ elif replace_streamed_draft_on_finish or buffer_completion_drafts:yield event({'type': 'final_response', 'content': content})break# Treat a model-proposed call batch atomically for previewdiff --git a/tests/test_clean_agent_preview.py b/tests/test_clean_agent_preview.pyindex 30c096f69..27aa36455 100644--- a/tests/test_clean_agent_preview.py+++ b/tests/test_clean_agent_preview.py@@ -312,8 +312,8 @@ def test_native_execution_limits_allow_multi_artifact_work_without_unbounded_roudef test_compact_preview_honors_configured_interactive_round_limit():- assert interactive_execution_limit(100) == 100- assert interactive_execution_limit(1000) == 200+ assert interactive_execution_limit(100) == 8+ assert interactive_execution_limit(1000) == 8assert interactive_execution_limit(0) == 1assert interactive_execution_limit(None) == 8assert interactive_execution_limit("invalid") == 8@@ -1266,6 +1266,10 @@ async def test_stream_retries_an_obviously_truncated_broad_web_answer(monkeypatcand 'fuller evidence-based briefing' in event.get('content', '')for event in events)+ assert not any(+ event.get('delta') == 'Current AI news includes reports about U.'+ for event in events+ )def test_task_renderer_honors_few_and_filters_confirmed_morning_schedule():