Repository navigation
fix(research): accept object-shaped exploration queries (#515) - #532
Merged
HananKavitzAmat merged 2 commits intoNov 18, 2026
Merged
HananKavitzAmat merged 2 commits into
HananKavitzAmat merged 2 commits into
Conversation
Some models return each exploration query as {query, aspect} instead of
a string; the schema rejected the payload and the swallowed exception
dropped every query for the file. Accept a string or a {query, aspect}
object, normalize to strings with one debug line per coerced item, and
keep rejecting items with no query string, unknown keys or a non-string
aspect (also for providers that don't validate the response).
A failed call now propagates to _generate_all_exploration_queries, which
logs it with the file and counts it in query_generation_failures; the
"no queries generated" early return now includes that counter too.
test_returns_empty_on_llm_failure codified the silent [] and is replaced.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 tasks
Collaborator
|
@munjikesh The rust-checks issue is resolved in main. Please pull the fix. |
Picks up the rust-checks fix (chunkhound#534). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Thanks, merged main in (16905a8). |
This was referenced Nov 21, 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.
Closes #515.
Note: #531 also targets this issue. It was opened after my claim on the issue, and the two are close. This one also rejects unknown keys in the object form (
additionalProperties: false, plus a key check for Anthropic and Gemini, which don't validate the response), per the issue's "Never: accept a payload silently by dropping unknown keys". Either is fine with me. Close whichever you don't want.What
Exploration query generation now accepts the
{query, aspect}objects some models return, instead of dropping the whole expansion. A failed call is no longer a silent[]: it shows up in the stats._generate_exploration_queries):queries.itemsisanyOfa string or an object with a requiredquerystring and an optionalaspectstring, withadditionalProperties: false. Onlyqueriesis relaxed.Coerced object-shaped exploration query 0 for AGENTS.md (aspect='Component architecture').querystring, unknown keys, or a non-stringaspect. Schema validation rejects these for the providers that validate. The normalization loop rejects them too, because Anthropic and Gemini onlyjson.loadsthe response.try/exceptthat returned[]is gone. The error goes to_generate_all_exploration_queries, which already logs a warning with the file and the reason and records it inFailureMetrics. The early return for "no queries generated" now includesquery_generation_failuresas well. Without it, the case this issue describes, where every file fails, still had no failure entry in the stats.depth_exploration_max_completion_tokens.Why
test_returns_empty_on_llm_failurechangedIt asserted that a failed LLM call returns
[], which is the silent behaviour this issue removes. It is nowtest_llm_failure_is_raised_not_returned_as_empty. Two other tests check where the failure goes now:test_failed_generation_is_counted_and_loggedchecks the warning andFailureMetrics, andtest_stats_count_failures_when_every_file_failschecksexplore_coverage_depth's stats.Tests
In
tests/unit/research/shared/test_depth_exploration.py:[{query, aspect}, "plain string"]yields both queries. The payload goes throughparse_and_validate_structured_jsonwith the schema the service sends, as a structured completion would. One coercion debug line names the file.query, a non-stringquery, or an extra key fails validation and raises. A payload from a provider that doesn't validate (noquery, an extra key, a non-stringaspect) raises too.stats["query_generation_failures"]has a count of 3.With main's
depth_exploration.py, 10 of these fail. With this change, the file has 43 passed. The cases that reject bad items guard requirement 3 under the new schema. The schema change itself is covered by the object-shaped test.Checks run (Windows 11, Python 3.12)
uv run pytest tests/unit/research/shared/test_depth_exploration.py -q: 43 passed.tests/unit/research: 265 passed.uv run pytest tests/test_smoke.py -v -n auto: 14 passed. One earlier cold run had 5 CLI-help failures that didn't come back in later runs.uv run pytest tests/ -n auto: the failures are the same as main's on this machine. These includetests/site(needs the site build), some realtime and MCP tests, and a flakytests/mcp/test_smoke.py::TestMCPStartupImports::test_mcp_stdio_server_starts, which passed 1 run in 3 on both main and this branch.ruff formatonly touches lines that were already there. mypy on the module is clean.Note for strict-mode providers
OpenAI's strict structured outputs want every property in
requiredandadditionalProperties: falseon every object. This schema's root object didn't meet that on main either, so the optionalaspectdoesn't make an already non-strict schema worse. I keptaspectoptional as the issue asks. A required, nullableaspectwould fail models that return{query}alone on endpoints that don't enforce the schema, which is where this drift comes from.AI disclosure: Claude Code (an AI coding agent) wrote this change and its tests and ran the checks above, operating my account, in line with CONTRIBUTING's AI-generated workflow. A separate AI review pass checked it, and its findings were applied. I haven't reviewed the diff line by line myself.
🤖 Generated with Claude Code