Skip to content

Tune Gemma 4 E4B tool-selection prompts for aichat-matrix Scenarios 5 and 6 #1640

Closed

Description

@malibio

Overview

Gemma 4 E4B (the locked native model per ADR-056) scored 10/12 on scripts/aichat-matrix.ts. Two scenarios failed. Investigation showed they have different root causes than "prompt tuning," so this issue is narrowed to the one it actually fixes:

Root cause of Scenario 5

"List all my invoices" expected search_nodes; E4B called execute_query. This was not an ambiguous tool description — it was an ambiguous tool boundary. The agent had two overlapping query tools: execute_query could list-by-type, filter by title/content, filter by property, and return properties, making it a near-superset of search_nodes. For "list all X" both tools were correct and execute_query returned more data, so no prompt prose gave the model a clean rule.

Fix: collapse the two agent tools into one

search_nodes is now the single agent query tool. It covers title/keyword lookup, listing all of a type, and typed property filtering (with operators + sorting), and always returns node properties. execute_query / Tool::ExecuteQuery are deleted. Internally search_nodes routes by capability: title/type listing via the title index (NodeService::query_nodes), property filters via QueryService SQL json_extract (query_ops::execute_query) — so property queries keep the correct SQL path. The backend query_ops::execute_query op, the daemon gRPC ExecuteQueryRequest, and the CLI query command are unchanged (separate layer). With one query tool the Scenario 5 ambiguity cannot occur.

Docs updated: architecture/data-layer.md (Query System section), architecture/prompt-skill-system.md (whitelist), ADR-056 (E4B-gaps consequence).

Acceptance Criteria

  • Root cause identified for Scenario 5's execute_query vs search_nodes choice (ambiguous tool boundary, not description)
  • Root cause identified for Scenario 6's incomplete update turn — moved to resolve_query must return a resolved node, not query fragments #1637 (malformed query + read-then-write turn completion; not prompt-fixable)
  • Tool-collapse change made; skills/guidance/tool-descriptions updated to the single search_nodes tool
  • scripts/aichat-matrix.ts re-run against gemma-4-e4b-q4km: Scenario 5 passes, no regression on the other passing scenarios. Scenario 6 remains the sole failure, tracked in resolve_query must return a resolved node, not query fragments #1637 (documented gap, per acceptance-criteria allowance)
  • Code passes bun run quality:fix; tests pass

Related Issues

Activity

  1. malibio commented on Jul 17, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline (worktree issue-1640-collapse-query-tool): 166 test files passed, 4104 tests passed. Duration 45.72s.

  2. self-assigned this
    on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions