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 committed 2026-04-11 16:25:19 +08:00
1 parent 5c53854000
commit fae8c72fcf
3 files changed
+4 -3

No files matched your search

+1
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())