Repository navigation
feat(search): bounded operator-intent query shaping for long prompts (#303 slice A) - #315
Merged
Merged
Conversation
This was referenced Mar 11, 2026
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.
What this does
Implements #303 slice A as a bounded retrieval-only improvement: long operator workflow prompts are query-shaped before retrieval to reduce answer-contract/transport boilerplate noise.
This slice is intentionally narrow and dependency-safe.
Problem / Context
Long workflow prompts (especially operator/heartbeat style prompts) often include high-noise boilerplate (
current time,reply HEARTBEAT_OK, session wrappers, etc.).That noise can dilute retrieval query quality and make top results less focused.
Issue: #303
How it works
Retrieval-only query shaping
In
search.Engine.Search:rawQueryintactretrievalQueryviashapeOperatorIntentQuery(rawQuery)only when prompt is long and operator-scaffold cues are presentretrievalQueryfor search + ranking filters onlyGuardrails (bounded behavior)
Shaping applies only when all are true:
Then it:
Debug/telemetry visibility
When
--explainis enabled, each result now includes:explain.query_shape.rawexplain.query_shape.shapedexplain.query_shape.appliedexplain.query_shape.removed_tokensexplain.query_shape.reasonThis provides explicit raw-vs-shaped comparison for operator debugging/evidence.
Files changed
internal/search/search.gointernal/search/query_shape_test.go(new)Testing done
Exact commands run:
go test ./internal/search -run 'QueryShape|SearchExplain_AttachesQueryShape|SearchExplain' -count=1go test ./...Screenshots / before-after
Terminal/JSON behavior change:
search --explain --jsonnow surfacesquery_shapewhen shaping is applied.Breaking changes / risks
Breaking changes: None.
Concise risk note:
Explicit out-of-scope (kept for later slices)
Merge notes