fix(agent): suppress empty final content instead of sending literal "..."#1116
Open
nguyennguyenit wants to merge 1 commit intomainfrom
Open
fix(agent): suppress empty final content instead of sending literal "..."#1116nguyennguyenit wants to merge 1 commit intomainfrom
nguyennguyenit wants to merge 1 commit intomainfrom
Conversation
…..." When the agent's final content is empty after sanitization, both v2 loop_finalize.go and v3 finalize_stage.go used to substitute the literal string "..." and ship it to channels. Users saw stray "..." messages in group chats (Zalo/Telegram/Discord/etc.) when the LLM produced no usable visible text (provider parsing quirk, reasoning-only output, etc.). Treat empty FinalContent as silent (same delivery path as NO_REPLY) and emit a structured slog.Warn with session/iteration/thinking_len/tool_calls so the underlying cause stays visible for debugging without leaking "..." to end users. NO_REPLY semantics unchanged. Downstream suppression in cmd/gateway_consumer_normal.go and gateway_announce_queue.go already handles empty Content correctly; the "..." fallback was bypassing that check. Adds regression tests for empty / NO_REPLY / real-content paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"..."fallback ở v2 (internal/agent/loop_finalize.go) và v3 (internal/pipeline/finalize_stage.go) finalize.FinalContentnhư silent reply (suppress delivery, không leak"..."xuống channel).slog.Warnriêng cho case empty (kèm session/iteration/thinking_len/tool_calls/async_tool_calls) để root cause LLM trả rỗng không bị che bởi NO_REPLY.Why
Trace evidence (
019e01c2-b12d-7bf7-babc-29833b288f81, agenttra, model qwen3.6-plus qua bailian):traces.output_previewvàsessions.messages[].contentđều lưu literal"..."."..."2 lần liên tiếp trong group Zalo.Root cause proximate là fallback ở finalize:
if FinalContent == "" → "...". Bug ảnh hưởng tất cả channel (Telegram/Discord/Zalo/Feishu/WhatsApp/Slack), không Zalo-specific.Downstream consumer (
cmd/gateway_consumer_normal.go:468,cmd/gateway_announce_queue.go:137) đã có sẵn checkContent == "" || IsSilentReply(...)để suppress + cleanup placeholder. Fallback"..."đang bypass logic này. Fix này feed đúng empty xuống path đó.What changed
internal/pipeline/finalize_stage.goisSilentByTokenvsisEmptyOutput, gộp thànhisSilent; bỏ branch fallback"..."; log warn cho emptyinternal/agent/loop_finalize.gointernal/pipeline/stages_test.goTest plan
go build ./...cleango build -tags sqliteonly ./...clean (desktop edition)go vet ./...cleango test ./internal/pipeline/ ./internal/agent/passTestFinalizeStage_EmptyContent_SuppressesInsteadOfEllipsis,TestFinalizeStage_NoReplyToken_StillSuppresses,TestFinalizeStage_RealContent_PassesThrough)agent produced empty final content; suppressing deliveryxuất hiện và channel KHÔNG gửi"..."Unresolved
FinalContentrỗng dù LLM trả 596 output tokens) chưa giải - fix này chặn symptom rò ra user, không sửa nguyên nhân Content rỗng. Cần điều tra parser bailian/qwen3.6-plus (có thể đẩy text vàoreasoning_contentfield) qua log warn mới khi reproduce. Tracking riêng nếu confirm.Behavior change cho consumer
Sau fix:
→ channel nhận
Content=""→ không send tin nhắn"..."nữa. Placeholder cleanup vẫn chạy bình thường nếu channel có streaming/placeholder.