Repository navigation
Conversation
Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #6216
Description
When knowledge chat explicitly said the retrieved material did not answer the question, it still returned unrelated references. The service published all merged results before the model started streaming.
The streaming completion stage now checks the completed answer for explicit no-evidence replies in Chinese and English. It omits references for those replies and sends references for other completed answers immediately before the terminal answer event, in time for both SSE clients and persistence. Answer text still streams as before, and references remain independent of the inline citation setting. Streams that end before producing a terminal answer no longer publish a reference list.
Type of Change
Related Issue
Fixes #6216
Testing
Tests:
go test ./internal/application/service -run '^TestKnowledgeQAReferencesFollowAnswer$' -count=1 -v.Result: Go 1.26.11 linux/amd64; go test fetched Go modules and compiled the checkout as needed. No separate build or dependency-file changes.
Result: Existing baseline: go test ./internal/application/service/chat_pipeline ./internal/handler/session ./internal/application/service -run "Test(KnowledgeQA|EmitKnowledgeReferences|QuickAnswer|ChatCompletionStream|.*StreamCompletion)" -count=1: passed in all three packages. An earlier broad baseline attempt timed out while warming dependencies.
Result: Base regression: go test ./internal/application/service -run '^TestKnowledgeQAReferencesFollowAnswer$' -count=1 -v: exit 1; both refusals emitted an unrelated reference and all four adjacent cases passed. Output: OSSCOUT_BASE.log.
Result: Patched regression: go test ./internal/application/service -run '^TestKnowledgeQAReferencesFollowAnswer$' -count=1 -v: exit 0; all six cases passed. Output: OSSCOUT_PATCHED.log.
Result: go test ./internal/application/service ./internal/application/service/chat_pipeline ./internal/handler/session ./internal/event -count=1: passed (107.984s, 1.486s, 11.117s, 1.023s respectively).
Result: go test ./internal/mcpserver -run 'Test.*Ask' -count=1: passed.
Result: go test ./internal/im -run 'Test(IMStreamLifecycle_quickQAPipeline|HandleMessageStreamWaitsForAsyncKnowledgeQA)$' -count=1: passed.
Result: Combined six-package attempt timed out during dependency downloads; reran the four core packages and focused MCP and IM checks separately as listed above.
Result: git diff --check and gofmt -l for the three changed Go files: clean. git diff --check origin/main...HEAD could not run because this checkout has no origin/main ref. golangci-lint run --new-from-rev=origin/main ./... could not run because golangci-lint is not installed.
Regression coverage:
internal/application/service/session_knowledge_qa_test.go.Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...)website-docs/, Swagger annotations, etc.)Screenshots / Recordings
Not applicable: backend SSE behavior change.