From d6403d97839d9daa22b42c87d7e171c162cc8652 Mon Sep 17 00:00:00 2001 From: Liang Jiaqing Date: Thu, 20 Aug 2026 12:30:42 +0800 Subject: [PATCH] ui: idle fragment tick 5s + streamlit>=1.62; fix !!!Error tail check --- frontends/stapp.py | 6 +++--- ga.py | 2 +- pyproject.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontends/stapp.py b/frontends/stapp.py index 62659bab..f43bb15f 100644 --- a/frontends/stapp.py +++ b/frontends/stapp.py @@ -437,7 +437,7 @@ if prompt: _start_main_task(prompt) # Stream hosts only when this session owns the queue. -# Single always-on 1s tick below (stream / detached / hub / idle) — never unregistered. +# Poll quickly while active; reduce idle renderer churn. _stream_fh = _stream_ls = None if st.session_state.get('display_queue') is not None: with st.chat_message("assistant"): @@ -448,9 +448,9 @@ if st.session_state.get('display_queue') is not None: elif agent.is_running: st.chat_message("assistant").markdown(T("detached_running")) -@st.fragment(run_every=timedelta(seconds=1)) +@st.fragment(run_every=timedelta(seconds=1 if (_stream_fh is not None or agent.is_running or st.session_state.get('loop_enabled')) else 5)) def _tick(): - """One heartbeat: if-dispatch stream / detached / hub / idle. Always registered.""" + """Poll every second while active and every five seconds while idle.""" # 1) Own stream: drain done, paint all_outputs if _stream_fh is not None: done = _poll_main_task() diff --git a/ga.py b/ga.py index a3818a5a..de0dc224 100644 --- a/ga.py +++ b/ga.py @@ -483,7 +483,7 @@ class GenericAgentHandler(BaseHandler): if not response or (not content.strip() and not thinking.strip()): yield "[Warn] LLM returned an empty response. Retrying...\n" return self._retry_or_exit("[ERROR] Blank response, regenerate and tooluse") - if '[!!! 流异常中断' in content[-100:] or '!!!Error:' in content[-100:] or (content.endswith('') and len(content) < 100): + if '[!!! 流异常中断' in content[-100:] or '!!!Error:' in content[50:][-100:] or (content.endswith('') and len(content) < 100): return self._retry_or_exit("[ERROR] Incomplete response. Regenerate and tooluse.") if 'max_tokens !!!]' in content[-100:]: return self._retry_or_exit("[ERROR] max_tokens limit reached. Use multi small steps to do it.") diff --git a/pyproject.toml b/pyproject.toml index cf243449..f60aea4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ # select extras, not all. match current task/env. # examples: .[ui] for GUI, bot deps only if bot needed. ui = [ - "streamlit>=1.28", + "streamlit>=1.62", "pywebview>=4.0", "textual>=0.70", # tui_v3 (scrollback-first TUI) — prompt_toolkit replaces textual; rich is