agentscope-ai / agentscope-ai/QwenPaw

[Bug] Agent enters infinite 'Thinking' state after completing response (SSE stream not closing properly)

Abierto
#3,871 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
34.9k
Forks
3.1k
Merge medio
1 d 15 h
PR fusionados (30 d)
225

Descripción

## Bug Description

After the Agent has finished generating its response (the content is complete and displayed to the user), the UI shows an additional **"Thinking" bubble** that continues indefinitely, requiring the user to manually stop the session.

## Steps to Reproduce

1. Start a conversation with the Agent in the Console.
2. Ask a question that requires a multi-part response.
3. The Agent generates and displays the complete response.
4. **After the response is complete**, a new "Thinking" bubble appears and spins indefinitely.
5. The Agent does not produce further output, but the "Thinking" state never ends.
6. User must manually click "Stop" to terminate the session.

## Expected Behavior

After the Agent generates its final response, the SSE stream should close properly and the UI should return to an idle state. No additional "Thinking" bubble should appear after the response is complete.

## Actual Behavior

An extra "Thinking" bubble appears after the final response and spins forever. The underlying SSE stream or Agent state machine is not recognizing that the conversation turn has ended.

## Screenshots

![Infinite thinking after response](https://user-images.githubusercontent.com/39703217/3868-thinking-bug.png)

*(Note: Screenshot shows completed response followed by persistent "Thinking" bubble)*

## Environment

- **QwenPaw Version**: 1.1.4.post1
- **OS**: Windows 10 (AMD64)
- **Python**: 3.13
- **Channel**: Console
- **Model**: qwen3.6-plus (via aliyun-codingplan)

## Possible Root Causes

1. **SSE stream not closing**: The server-side SSE stream may not be emitting a proper `done` event after the Agent completes its response.
2. **ReAct loop not terminating**: The Agent's internal ReAct loop may not be recognizing that the current turn has reached a terminal state.
3. **Frontend state not resetting**: The Console UI may not be properly clearing the "Thinking" state after receiving the final message.

## Impact

- User experience is degraded as sessions appear to hang.
- Users must manually intervene to stop the Agent, disrupting the natural flow of conversation.
- This may also cause issues with subsequent messages in the same session.

## Suggested Investigation

1. Check the SSE stream lifecycle in `/console/chat` endpoint — verify that the stream properly closes after the Agent's final response.
2. Review the ReAct Agent's termination conditions in `react_agent.py` — ensure the loop exits cleanly when no further actions are needed.
3. Check the Console frontend's handling of the "Thinking" state — verify it resets after receiving a completed response.

## Related

This issue may be related to the SSE handling introduced in recent versions for the Console channel.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.