Skip to content

fix(suggestion): avoid echoing the current query - #2582

Open
hjxccc wants to merge 1 commit into
Tencent:mainfrom
hjxccc:agent/fix-follow-up-query-echo
Open

fix(suggestion): avoid echoing the current query#2582
hjxccc wants to merge 1 commit into
Tencent:mainfrom
hjxccc:agent/fix-follow-up-query-echo

Conversation

@hjxccc

@hjxccc hjxccc commented Aug 7, 2026

Copy link
Copy Markdown

Description

Prevent follow-up suggestions from repeating the user's current question after normalization.

The knowledge path can mechanically turn an entity or summary Wiki page titled X into 介绍一下X. When that is also the current query, relevance ranking promotes the echo because its context starts with CurrentQuery, and the hybrid merge reserves a knowledge slot for it. The model path can also ignore the prompt-level instruction not to repeat prior questions.

This change:

  • filters normalized exact matches against CurrentQuery on both model and knowledge paths;
  • filters knowledge candidates inside the selection loop so later candidates can backfill the configured count;
  • deliberately avoids fuzzy similarity thresholds so valid deeper questions about the same entity remain available;
  • adds coverage for punctuation, whitespace, case, empty-query behavior, and hybrid slot preservation.

Type of Change

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

Related Issue

Fixes #2519

Testing

  • gofmt -l internal/application/service/message_suggestion.go internal/application/service/message_suggestion_test.go — no output
  • go test ./internal/application/service/ -run 'Suggestion|FollowUp|MergeHybrid' -count=1 — passed with Go 1.26
  • go vet ./internal/application/service/ — passed with Go 1.26
  • git diff --check upstream/main...HEAD — passed

The focused backend package was validated. Full-repository make test was not run because this change is isolated to follow-up suggestion generation and its unit tests.

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 (validated with go vet for the changed package)
  • 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 (not applicable; no user-facing contract or configuration change)
  • Breaking changes are clearly called out (none)

Screenshots / Recordings

Not applicable; this is a backend-only fix.

@hjxccc
hjxccc marked this pull request as ready for review August 15, 2026 02:20
@hjxccc

hjxccc commented Aug 18, 2026

Copy link
Copy Markdown
Author

友好 ping 一下 🙏 这个 PR 开了 11 天了,CI 全绿、无冲突。

修的是 #2519:知识路径会把标题为 X 的 Wiki 页机械地变成 介绍一下X,当它正好等于当前问题时,相关性排序反而会把这条回显推到前面。改动只过滤「归一化后与 CurrentQuery 完全相同」的候选,不做模糊相似度,所以同一实体的深入追问不受影响。

需要我 rebase 到最新 main、或者把改动拆得更小,随时说,我会立刻跟进。

@iuyo5678

Copy link
Copy Markdown
Collaborator

抱歉拖了这么久才回复,整个改动没有问题,不过我看PR 信息你是从实际数据库中导出的,这些信息会涉及你的一些个人身份信息,建议测试用例简单做个修改,换成一些通用的日常表达,即可merge了。🙏

Sorry for taking so long to reply,there are no problem with the changes overall,but I see from the PR information that you exported this from an actual knowledge database,and this information may involve some of your personal identifying information,I suggest making a simple change to the test cases,replacing it with some generic everyday expressions,then it can be merged。🙏

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]: Follow-up suggestions can echo the user's own question verbatim (no current-query dedupe anywhere in the pipeline)

2 participants