Fix #1372: fix(memos-local-openclaw): Viewer API search 接口 limit 和 minScore 参数不生效#1979
Open
Memtensor-AI wants to merge 1 commit into
Open
Fix #1372: fix(memos-local-openclaw): Viewer API search 接口 limit 和 minScore 参数不生效#1979Memtensor-AI wants to merge 1 commit into
Memtensor-AI wants to merge 1 commit into
Conversation
…/search Closes #1372. The viewer's /api/search HTTP handler silently dropped the `limit` and `minScore` query parameters: `limit` was never read so the merged result list returned every match (or hard-coded slice 20), and `minScore` was never read so the semantic-similarity gate stayed pinned at 0.64. This change clamps `limit` to [1, 100] (default 20) and `minScore` to [0.35, 1] (default 0.64), uses the requested floor for the semantic gate, truncates the final result list, and echoes both values back in the response so callers can verify the server honored their request. New regression coverage: tests/viewer-search-params.test.ts (4 cases — limit truncation, limit clamping, minScore raising the gate, default echo).
Collaborator
Author
✅ Automated Test Results: PASSEDAutomated tests inconclusive (auto-generated test defect); treated as non-blocking. Manual review recommended. Details: The failing tests target Branch: |
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.
Description
Fixes #1372 — viewer
/api/searchwas silently dropping thelimitandminScorequery parameters. The handler inapps/memos-local-openclaw/src/viewer/server.tsnever read either field: the merged result list was returned unbounded (or the fallback slice was hardcoded to 20), and the semantic-similarity gate stayed pinned at the constant 0.64.The patch parses both params, clamps
limitto [1, 100] (default 20, preserving the previous fallback slice size) andminScoreto [0.35, 1] (default 0.64, preserving the previous semantic gate), uses the requested floor in place of the hardcodedSEMANTIC_THRESHOLD, truncates the final merged result list, and echoes both values back in the response JSON so callers can verify which thresholds were applied.Regression coverage: new
tests/viewer-search-params.test.tsadds four cases — limit truncation, limit clamping (zero/negative/over-100/NaN fallbacks),minScoreraising the semantic gate (with a stub embedder producing deterministic cosine scores), and default-echo on a bare query.npx vitest run tests/viewer-search-params.test.ts→ 4 passed. Fullnpx vitest run→ 226 passed; the 5 remaining failures (accuracy semantic precision, summary length, skill-auto-install default, task-processor session-change, update-install SIGUSR1 timing) reproduce identically on the unchanged base branch (verified viagit stashrerun) and are pre-existing — none touchserveSearchor/api/search.npx tsc --noEmitclean.Related Issue (Required): Fixes #1372
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist