Skip to content

Let schema tools filter on whether a column is set - #718

Merged
TonsOfFun merged 3 commits into
mainfrom
feat/schema-tools-presence-filter
Nov 19, 2026
Merged

TonsOfFun merged 3 commits into
mainfrom
feat/schema-tools-presence-filter

Conversation

@TonsOfFun

Copy link
Copy Markdown
Contributor

Why

SchemaTools drops a null filter value as "no filter". That's right, because models send null for every optional parameter they leave out. But it also means a model can't ask for the records where a column is null: tickets with no assignee, requests not yet approved, posts never published. Host apps have been working around it in their instructions with sentinel ranges, such as telling the model that {"after": "2000-01-01"} on a timestamp means "is set". For "is not set" on a foreign key there is no workaround at all.

What

A filter can now take a present key in its object form:

TicketTools.call("count_tickets", actor: user, assignee_id: { "present" => false })          # IS NULL
TicketTools.call("find_tickets", actor: user, closed_at: { "present" => true, "after" => "2026-11-01" })
  • Accepted on any filterable column, alone or beside a range bound. An enum accepts it too, though it still rejects comparisons.
  • Offered in the schema inside the range object of nullable date, time and number columns, which covers foreign keys. The column description explains it. It is not wrapped around every nullable string or enum, to keep tool schemas small, and NOT NULL columns don't get it.
  • Only true/false (or "true"/"false"). Anything else comes back as { error: ... } rather than being guessed into one of the two, the same way an unknown comparison is already handled.
  • NULL semantics everywhere. On a string column, "" counts as present. That case is only reachable by calling the tool directly, since the schema never offers present on strings.

Not changed

Making null mean IS NULL would turn every omitted optional parameter into a filter, so null still means no filter. Existing filters and schemas are unchanged, except that nullable range columns gain one boolean property.

Tests

  • 7 new tests in test/schema_tools_test.rb: null, not null, with a bound and an equality filter, string operands, a rejected operand, a string column and an enum, and where it is offered. The advertised-operators test now includes present.
  • test/schema_tools_test.rb: 64 runs, 0 failures. The engine and generator schema-tools tests (MCP, registration, roster, project): 64 runs, 0 failures.
  • RuboCop is clean.
  • Full suite: 4623 runs, 0 failures, 5 errors. The errors are the live-network RubyLLMIntegrationTest cases, which fail locally with placeholder keys; CI runs them with real keys.

Docs: docs/actions/tools.md, CHANGELOG.md under [Unreleased], and docs/work/schema-tools-presence-filter/.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PCEJHpsHnAd9GSQRbkvYDH

TonsOfFun and others added 3 commits November 17, 2026 10:15
A nil filter value is dropped as "no filter", which is right: models send
null for every optional parameter they leave out. It also left no way to
ask for the records where a column is null (tickets with no assignee,
requests not yet approved), so hosts taught their models sentinel ranges
such as {"after": "2000-01-01"} to mean "is set", with nothing at all for
"is not set" on a foreign key.

A filter now takes {"present": false} (IS NULL) or {"present": true}
(IS NOT NULL), alone or beside a range bound, on any filterable column.
An enum accepts it though it takes no comparison. The schema offers it in
the range object of nullable date, time and number columns, which covers
foreign keys, rather than wrapping every nullable string and enum in an
object form. Anything but true or false is rejected, not guessed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PCEJHpsHnAd9GSQRbkvYDH
CHANGELOG: keep the presence filter under Added and the 1.9.9 fixes under
Fixed in one Unreleased section.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PCEJHngWphRQ7ArmDnYMmf
@TonsOfFun TonsOfFun added this to the 1.9.9 milestone Nov 19, 2026
@TonsOfFun
TonsOfFun merged commit c177d44 into main Nov 19, 2026
18 checks passed
@TonsOfFun TonsOfFun mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant