Repository navigation
resolve_query: state JSON encoding per field type in decomposition prompt - #1945
Conversation
…ompt (closes #1915) The decomposition sub-prompt named a field's declared type (`name: type`) but never told the model how to encode a value it maps onto that field, so a small model reading digits or booleans out of prose could emit the wrong JSON type — the exact silent-mismatch failure #1908/#1910 patched per-type via coerce_filter_value_to_field_type. Per the issue's own "cheaper to try first" proposal, add an explicit JSON-encoding hint (number/boolean/text/enum) to each field line in exec_resolve_query's prompt, scoped locally rather than to the shared render_shape() renderer per the issue's scope decision. Live-model validation against the locked Gemma 4 E4B model confirms the reverse-direction case (a numeric-looking value identifying a text field) now resolves correctly. Co-Authored-By: Claude <[email protected]>
Code Review SummaryNet positive, tightly scoped, well-tested. This is a clean, minimal implementation of the "cheaper to try first" fix from #1915: a single new helper ( Build is clean ( FindingsCritical IssuesNone. Suggested ImprovementsNone blocking. One observation, not a change request: the Verification Notes
NitpicksNone. Requirements Validation
Verdict: Approve. |
malibio
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (self-approval blocked by GitHub — this account authored the PR). Full review posted as a PR comment above. Summary: scope discipline confirmed (only tools.rs changed, shared render_shape() untouched), build/clippy clean, full agent lib test suite passes (456 passed, 1 ignored, 0 failed) including both new tests and the pre-existing number/boolean coercion regression tests. No blocking issues found.
Summary
(JSON number, not string), etc.) to each field line inresolve_query's decomposition sub-prompt, alongside the existingname: typenotation.exec_resolve_queryvia a newrender_resolve_query_field_linehelper — deliberately not added to the sharedEntityFieldDescriptor::render_shape(), which also feeds thecreate_node/search_nodesguidance block, per the scope decision recorded on the issue.coerce_filter_value_to_field_type(from Fix resolve_query no_match against a node whose property does contain the value #1910) is kept as defense-in-depth; the prompt hint reduces how often the model needs it, but doesn't guarantee elimination.Why
resolve_query's decomposition call could silently fail to match a node when the model encoded a filter value with the wrong JSON type for its target field (e.g."2400"instead of2400for anumberfield). #1910 patched this per-type in Rust after the fact. This issue's "cheaper to try first" fix states the expected encoding directly in the prompt instead, closing the gap for field types not yet covered by the Rust-side coercion — most notably the reverse direction (a numeric-looking value landing on atext/enumfield).Test plan
cargo test -p nodespace-agent --lib resolve_query— 27 passed (includes newresolve_query_prompt_states_json_encoding_per_field_typeprompt-content test)E2E_MODEL=... cargo test ... live_resolve_query_phrasings_against_real_model -- --ignored --nocapture), including a new reverse-direction scenario (numeric-looking value →textfieldvendor_code) — all 4 phrasings resolved correctlybun run test:all— full frontend + skill + Rust suite green (pre-push hook)cargo clippy -p nodespace-agent --lib -- -D warnings— cleancargo fmt— clean on touched fileCloses #1915
🤖 Generated with Claude Code