fix: restore stop signal detection broken by render_segments cache optimization

- stapp.py: add st.empty() after render_segments to force Streamlit StopException check on every iteration (incl. heartbeat)
- agentmain.py: fix nround type check, fix timeout comment
This commit is contained in:
Liang Jiaqing
2026-04-11 16:25:19 +08:00
parent de8adf76a9
commit 3531146792
3 changed files with 4 additions and 3 deletions

View File

@@ -139,6 +139,7 @@ if prompt := st.chat_input("请输入指令"):
turns = []; cache = []; response = ''
for response in agent_backend_stream(prompt):
render_segments(fold_turns(response), placeholders=turns, rendered_cache=cache, suffix='<span style="animation: blink 1s step-start infinite; color: #0066cc;">▌</span><style>@keyframes blink { 50% { opacity: 0; } }</style>')
st.empty() # force Streamlit to check StopException on every iteration (incl. heartbeat)
render_segments(fold_turns(response), placeholders=turns, rendered_cache=cache, force_text=True)
st.session_state.messages.append({"role": "assistant", "content": response})
st.session_state.last_reply_time = int(time.time())