Skip to content

fix(query): strip a trailing question mark before capping the core subject - #1363

Merged
iliaal merged 2 commits into
mvanhorn:mainfrom
kevin9327:fix/core-subject-trailing-punctuation
Nov 3, 2026
Merged

iliaal merged 2 commits into
mvanhorn:mainfrom
kevin9327:fix/core-subject-trailing-punctuation

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Summary

query.extract_core_subject() only removed a trailing ?/!/. on the path without max_words, and only at the very end. So every caller that passes max_words (the X adapters bird_x and xquik, threads, planner, pipeline) kept the question mark, and the last word of a question never matched a noise word or a suffix:

extract_core_subject("What is Claude Code?", max_words=5)
# before: 'claude code?'   after: 'claude code'

extract_core_subject("Claude Code best practices?", max_words=5, strip_suffixes=True)
# before: 'claude code practices?'   after: 'claude code'

For X the core subject goes into a literal keyword search, so code? ends up as a search term. The fix strips the closing punctuation once, right after lowercasing and before the prefix/suffix/noise phases. The existing final rstrip is unchanged, and an input that is only punctuation still falls back to itself.

Testing

  • uv run pytest
  • Added or updated tests that would catch a regression, or explained why not below

Two tests in tests/test_query.py (TestMaxWords): test_max_words_strips_trailing_punctuation and test_trailing_punctuation_does_not_hide_last_noise_word. Both fail on main ('claude code?', 'claude code practices?') and pass with the fix. Full suite: uv run pytest -n 4 gives 6952 passed, 19 skipped.

Changelog

If this change should appear in the next release notes, add a fragment under changelog.d/ (see changelog.d/README.md and CONTRIBUTING.md). Do not edit CHANGELOG.md or bump version/manifest files in this PR.

  • Added changelog.d/<pr-or-issue>.<type>.md (types: added, changed, fixed, removed, deprecated, security)
  • Skip changelog — chore/internal only (also add the skip-changelog label)

Added changelog.d/+core-subject-trailing-punctuation.fixed.md.

Agent disclosure

I used an AI assistant while preparing this change; I reviewed the code and ran the tests above.

AI review

Checked that the change only touches trailing ?/!/. (inner punctuation such as next.js or c++ is untouched), that the existing test_query.py/test_query_v3.py expectations still hold (including the all-noise fallback and the "only the first prefix is stripped" case), and that a punctuation-only topic still returns non-empty text. Nothing else was flagged.

Security

N/A

Notes

None.

Relationship to this change

  • None
  • Yes — disclosure:

Related issues

N/A

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues were found.

Summary

extract_core_subject() now removes closing punctuation before filtering words and applying the word cap.

  • Capped search subjects drop closing punctuation before cleanup.
  • The deadline test replaces the probe's sleep without replacing the shared clock.

Reviews (2) · Last reviewed commit: "test: isolate doctor retry sleep from su..." · Reviewed by Greptile

@iliaal

iliaal commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@greptileai

@iliaal
iliaal merged commit 23e52c9 into mvanhorn:main Nov 3, 2026
12 checks passed
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.

2 participants