Repository navigation
query: show the expansion state of hits and the content-budget cut (#52, #53) - #54
Merged
Merged
Conversation
…x outside 1-1000 (#52, #53) #52: semctx (napbat/semctx#94, commit 1cb9e81) sets `expanded` on each hit of a Symbol search, and `expansionReason` when the hit keeps its chunk snippet. semctl did not read the fields, so an agent could not tell a chunk from the whole symbol. SearchHit now reads both fields, and the hit renderer ends the header line of each such hit with `[expanded]` or `[not expanded: <reason> — <next step>]`. The MCP result of search_codebase and `semctl search --expand` both use this renderer. The server limits the snippet text of a search to 32 KiB (Search:ContentBudgetBytes). The client budget of 30,000 characters from #39 was a stand-in for that budget. It could show a hit that the server expanded as a 4-line snippet. The client budget is removed, and an expanded search prints each snippet in full. #53: semctx (napbat/semctx#93) answers 400 to a topK or grep max outside 1 to 1000 instead of clamping it. query::search and query::grep now refuse such a value with an invalid-argument error before a request. The prompt hook does not search when SEMCTX_HOOK_TOP_K is above 1000. The tool docs, the argument schema, the CLI help, and the skill describe the limits, the server budgets, and the expansion markers. Fixes #52. Fixes #53.
…tent budget (#52) semctx sends `X-Semctx-Result-Truncated: content-budget` on POST /v1/search and GET /v1/codebases/{id}/grep when its content budget cut a snippet or line, left a Symbol hit unexpanded, or dropped later results (SearchResponseHeaders in semctx 1cb9e81 and feat/docstore-cutover). The status stays 200, and semctl did not read the header, so an agent took a shortened result as complete. Client::post_read_budgeted and Client::get_budgeted return the result with the ResultTruncation that the header reports. query::search and query::grep start the result with one note line that names the budget (32 KiB of snippet text, or 32 KiB of path and line text with 512 bytes for each line, by default) and a next step: a narrower query, a lower top_k, or no expand for a search; a narrower path or pattern, or a lower max for a grep. A value other than content-budget is reported as the server sent it. The MCP tools and `semctl search` use the same functions. Refs #52.
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.
Part of the semctx docstore cutover (napbat/semctx#103). Closes #52 and #53.
[expanded], or[not expanded: <reason> — <next step>].top_kand grepmaxoutside 1 to 1000 are refused in the client.X-Semctx-Result-Truncated: content-budget), the result starts with one note line that names the budget and a next step.semctx
feat/docstore-cutoversends these fields and the header. Merge this PR with the semctx cutover PR (see the cutover runbook in napbat/docstore#36).