Repository navigation
feat(search): add a tags_all filter that requires every tag - #8
Merged
springfall2008 merged 1 commit intoNov 9, 2026
Merged
Conversation
search's tags filter matches memories with at least one of the tags given, so "status:open AND owner:me" could not be asked in one query: an agent had to fetch with one tag and filter the rest client-side, and with results capped at 100 that silently missed rows once the store grew. tags_all keeps only memories that carry every tag given. It can be combined with tags (any-of AND all-of), and an empty list means no filter, as for tags. A new migration adds a 10-argument search_memories with p_tags_all, applied inside each arm before its LIMIT like the other filters. The 9-argument function becomes a SQL wrapper, so the deployed Edge Function keeps working once the migration is applied. The new Edge Function calls the 10-argument overload, so the migration must be applied first. Tests: a pgTAP file (every mode, before-LIMIT in each arm, combination with tags, empty list, RLS, grants, the 9-argument wrapper), an integration test through PgMemoryStore, and unit tests for the handler and the registered tool schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Posted by Claude on behalf of @chalfontchubby.
Why
search'stagsfilter keeps memories with at least one of the tags given. So "my open work" (status:openAND an owner tag) can't be asked in one query: you fetch on one tag and filter the rest on the client. Withlimitcapped at 100, that silently misses rows once the store grows. We hit exactly this migrating the Predbat memories intopredbat-devs: an owner-tag sweep returned 100 of ~160 rows, and the open ones were split across the cut.What
searchgainstags_all: keep only memories that carry every tag given.tags(any-of AND all-of).tags.20261109120000_search_tags_all.sql:search_memorieswithp_tags_all. The@>predicate sits in each arm (keyword, semantic, hybridkwandsem), before that arm'sLIMIT, like the existing filters.SearchFilters.tagsAll, passed throughPgMemoryStore.searchand exposed astags_allon the tool.tags_all.Deploy order
Run
db pushbeforefunctions deploy. The wrapper keeps the currently deployed function working on the new schema. The new function calls the 10-argument overload, so it needs the migration first. That is the ordersetup.tsand the README's manual install already use.Tests
All run locally with Supabase CLI 3.0.0, as CI pins it:
deno task checkdeno task test:unitsupabase db reset+supabase test dbdeno task test:intNew tests:
supabase/tests/database/11_search_tags_all.test.sql:tags_allin each mode;LIMITin keyword, semantic and both hybrid arms, with filler rows that outrank the target on both keyword rank and vector distance;tags;anonandauthenticated;PgMemoryStore.tags_allthrough;searchtool's schema acceptstags_all, so a rename can't be dropped silently by zod.Not in this PR
A review suggested a
created_by/ "mine" filter for the "my work" case. The server already knows who wrote each row, so it would not depend on agents tagging themselves. It would also mean deciding what an update by someone else does to "mine", so I've left it for you to decide.tags_allis useful on its own for any combination, such as repo + status.🤖 Generated with Claude Code