feat: add filter to session metadata - #577
Closed
sr07asthana wants to merge 8 commits into
Closed
Conversation
sr07asthana
requested review from
bhaveshpatel640,
chiragjn,
debajyoti-truefoundry,
heerambavi1998 and
thesujai
as code owners
September 3, 2026 10:02
🦋 Changeset detectedLatest commit: 781659c The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 32a1d3d. Configure here.
sr07asthana
force-pushed
the
sr-add-metadata-filter-sessions
branch
from
September 3, 2026 14:04
55a50ee to
08e1ff1
Compare
| { | ||
| "description": "JSON object string. Matches sessions containing all pairs. Keep constant when paging.", | ||
| "in": "query", | ||
| "name": "metadata", |
Contributor
There was a problem hiding this comment.
metadata.abc = ? & metadata.xyz = ?
metadata.abc = ? || metadata.xyz = ?
Resolve listSessions conflicts by keeping created_by_subject_id from main and the metadata filter from this branch. Co-authored-by: Cursor <cursoragent@cursor.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.

Summary
Closes #
Changes
How was this tested?
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Low Risk
Additive read-path filtering with validated query input and a new Postgres GIN index; no changes to auth or session mutation behavior.
Overview
Adds an optional
metadataquery parameter onGET /api/v1/sessions(and the SDKsessions.listrequest) so callers can list only sessions whose stored metadata contains every supplied key/value pair (exact string match; extra session keys are allowed). The value is a JSON object string, validated with the same rules as session metadata; invalid JSON or oversize objects return 400.The list handler passes the parsed filter into
sessionStore.listSessions, which now accepts optionalmetadataonListSessionsInput. In-memory, Postgres (metadata @>), and SQLite (json_eachfor literal key names) all implement the same containment semantics, including keys with dots,$, or brackets.Postgres gets a new GIN index on
session.metadatavia migration20260903_000002_session_metadata_gin. OpenAPI/SDK docs are updated, and store contract plus HTTP tests cover filtering, pagination with a fixed metadata filter, and query validation.Reviewed by Cursor Bugbot for commit 781659c. Bugbot is set up for automated code reviews on this repo. Configure here.