Repository navigation
Description
Summary
When a reasoning model occasionally emits its entire final answer in the reasoning_content channel with empty content (finish_reason=stop, no tool calls), ReActAgent judges the run as finished. The final message contains only a ThinkingBlock and no TextBlock, so AG-UI emits zero TEXT_MESSAGE_* events and the persisted assistant turn has no text. No error, no warning - a silent empty reply.
Observed in production with kimi-k2.6 (DashScope OpenAI-compatible endpoint); intermittent - the same session's previous identical round produced normal text.
Root Cause (verified on main @ 49cffeb, 2.0.3-SNAPSHOT)
| Link | Location | Behavior |
|---|---|---|
| Response parsing | OpenAIResponseParser.java:431-466 |
reasoning_content -> ThinkingBlock; empty content -> no TextBlock (faithful parsing, correct) |
| Event emission | ReActAgent.java:2550-2562 (emitBlockEvents) |
TextBlock -> TextBlock*Event; nothing emitted for text when absent |
| Finish check | ReActAgent.java:3682-3693 (isFinished) |
return toolCalls.isEmpty(); - never checks that the final response contains user-visible content |
| AG-UI conversion | TextBlockEventConverter.java:33-40 |
TextMessage* events sourced exclusively from TextBlock* events |
A final assistant message consisting solely of a ThinkingBlock therefore passes isFinished() and terminates the ReAct loop with an empty visible reply.
Impact
- User gets no answer and no error (run finishes "successfully"); nothing at WARN/ERROR level to alert on
- Assistant turn persisted without text (reasoning only), degrading subsequent multi-turn context
- Affects any reasoning model on the OpenAI-compatible path using
reasoning_content(kimi-k2 confirmed; DeepSeek-R1-class models share the same risk) - Intermittent and model-dependent - hard to detect from logs
Production Evidence
One run: 6 model calls, 5 tool calls all successful; final generation produced 170 output tokens entirely in reasoning parts, finish_reason=stop; trace output parts were [{"type":"reasoning", ...}] with no text part. Full AG-UI event stream for the run: TEXT_MESSAGE* count = 0 (thinking stream normal), then RunFinished. Framework-level WARN/ERROR in the window: 0 - excluding retries/degradation/HTTP errors; purely a response-structure issue.
Proposed Fix (either or both)
- Built-in empty-final-response retry: in the postReasoning pipeline, when the final response has no
ToolUseBlockand noTextBlock(thinking-only), trigger the existinggotoReasoningmechanism with a nudge message (e.g. "your previous reply had empty content; write the final answer in the content channel"), with a retry cap. The machinery already exists (ReActAgent.java:2416-2422) - it is just not used for this case. - Stricter finish check:
isFinished()additionally requires a non-empty user-visible block. Riskier as a hard rule - may break legitimate non-text finals (structured output etc.), so direction 1 is safer.
At minimum, a WARN log on "final response has no visible content" would make this detectable.
Workaround (application layer)
A PostReasoning middleware performing the check + gotoReasoning described in direction 1 - works on 2.0.1 without framework changes.
Environment
- AgentScope Java: 2.0.1 (production); verified still present in main 2.0.3-SNAPSHOT @ 49cffeb
- Model: kimi-k2.6 via DashScope OpenAI-compatible endpoint
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(core): retry empty final responses instead of finishing silently (a…