Skip to content

fix: suppress unrelated references for knowledge chat refusals - #6230

Open
xixi-box wants to merge 1 commit into
Tencent:mainfrom
xixi-box:fix/issue-6216-a330768-e062c3e1
Open

xixi-box wants to merge 1 commit into
Tencent:mainfrom
xixi-box:fix/issue-6216-a330768-e062c3e1

Conversation

@xixi-box

Copy link
Copy Markdown
Contributor

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

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

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...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable (for Go: golangci-lint run --new-from-rev=origin/main ./...)
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, website-docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

Not applicable: backend SSE behavior change.

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: knowledge_chat接口里问答回复为拒答时,仍返回无关引用

1 participant