Repository navigation
AIML-361: Support multiple session metadata filters with JSON parameter - #66
Merged
Merged
Conversation
Add new validation spec for parsing JSON filter parameters with: - String and string array value support - Number to string conversion (integers formatted without decimals) - Rejection of complex/nested objects - Clear error messages for invalid JSON Also add mutuallyExclusive() method to ToolValidationContext for validating exclusive parameter combinations.
BREAKING CHANGE: sessionMetadataName and sessionMetadataValue parameters removed.
Use sessionMetadataFilters JSON parameter instead.
The new parameter supports:
- Single filter: {"branch":"main"}
- Multiple filters (AND logic): {"developer":"Ellen","commit":"100"}
- Multiple values (OR logic): {"developer":["Ellen","Sam"]}
Implementation changes:
- SearchAppVulnerabilitiesParams: Replace old params with sessionMetadataFilters
- ExtendedTraceFilterBody: Replace fromWithSession with withSessionFilters
- SearchAppVulnerabilitiesTool: Update to build List<TraceMetadataFilter>
- Integration tests: Update to use new JSON format
Resolves AIML-361
Prevents NullPointerException if caller passes null source.
ChrisEdwards
force-pushed
the
AIML-361-multiple-session-metadata-filters
branch
from
January 9, 2026 17:23
8469a7f to
c50eab2
Compare
ChrisEdwards
requested review from
JacobMagesHaskinsContrast,
dougj-contrast and
seschis
January 9, 2026 18:04
ChrisEdwards
commented
Jan 9, 2026
ChrisEdwards
marked this pull request as ready for review
January 9, 2026 18:16
Remove needsSessionFiltering() and merge executeWithServerSidePagination into unified doExecute(). The in-memory filtering methods remain but are now unreachable (to be deleted next commit).
Remove all in-memory session filtering infrastructure: - executeWithInMemorySessionFiltering() method - SessionFilteringResult record - fetchTracesWithEarlyTermination() method - buildSessionFilterPredicate() method - maxTracesForSessionFiltering config field Keep normalizeFilterValue(), resolveSessionMetadataFilters(), and buildFieldNameToIdMapping() which are still used for server-side filtering.
Remove outdated notes about multi-page fetching and partial results since session filtering now uses server-side API exclusively.
- Remove integration test that used empty string for "any value" filtering
(this behavior no longer works with new JSON format)
- Handle empty JSON object {} explicitly by returning null
- Clarify in tool description that field values are case-sensitive
(while field names remain case-insensitive)
JacobMagesHaskinsContrast
approved these changes
Jan 9, 2026
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
sessionMetadataFiltersJSON parameter tosearch_app_vulnerabilitiestoolsessionMetadataName/sessionMetadataValueparameters with flexible JSON-based filteringWhy
AI agents need to filter vulnerabilities by multiple session metadata criteria simultaneously. The previous API supported only single field filtering (
sessionMetadataName+sessionMetadataValue), which was insufficient for real-world use cases like:This is a breaking change that removes the old parameters in favor of a more powerful JSON-based approach.
What
New parameter:
sessionMetadataFilters- JSON object mapping field names to values{"branch":"main"}{"developer":["Ellen","Sam"]}{"branch":"main","developer":"Ellen"}{"developer":["Ellen","Sam"],"branch":"main"}Removed parameters:
sessionMetadataNamesessionMetadataValueRemoved code (~275 lines):
executeWithInMemorySessionFiltering)fetchTracesWithEarlyTermination)buildSessionFilterPredicate)SessionFilteringResultrecord and related pagination logicmaxTracesForSessionFilteringconfiguration propertySupporting changes:
/ng/orgId/traces/appId/filterendpointExtendedTraceFilterBodyfor session metadata filtering supportMetadataJsonFilterSpecfor JSON validation with helpful error messagesHow
Architecture
JSON Parsing & Validation (
MetadataJsonFilterSpec.java):Map<String, Object>where values areStringorList<String>{}Field Name Resolution (
SearchAppVulnerabilitiesTool.java):TraceMetadataFilter Construction (
ExtendedTraceFilterBody.java):TraceMetadataFilterobjects for each fieldPOST Endpoint Migration:
SearchVulnerabilitiesToolandSearchAppVulnerabilitiesToolnow use POSTKey Implementation Decisions
Step-by-Step Walkthrough
Core changes:
SearchAppVulnerabilitiesParams.java(lines 64, 81-82, 136-146):sessionMetadataName/sessionMetadataValuewithsessionMetadataFiltersmapuseLatestSessionMetadataJsonFilterSpec.java(new file):SearchAppVulnerabilitiesTool.java(lines 196-260):resolveSessionMetadataFilters(): Translates field names to numeric IDsbuildMetadataFilters(): ConstructsTraceMetadataFilterlist for APIExtendedTraceFilterBody.java(new file):TraceFilterBodyto add session metadata filter supportwithMetadataFilters()method for fluent constructionRefactoring (non-functional):
SDKExtension.getTraces()/getTracesInOrg()toTraceFilterForm()methodsTraceExpandValueenum instead of magic stringsTest infrastructure:
TracesJsonFixture.java(new file): Shared test fixtures for API responsesAnonymousTraceBuilderpattern used for clean test setupTesting
Unit tests: 597 tests passing
SearchAppVulnerabilitiesToolTest.java: 35 tests covering JSON parsing, field resolution, filtering logicMetadataJsonFilterSpecTest.java: 13 tests for JSON validation edge casesSearchAppVulnerabilitiesParamsTest.java: Parameter validation testsExtendedTraceFilterBodyTest.java: Filter body construction testsIntegration tests: Require credentials
SearchAppVulnerabilitiesToolIT.java: Tests for:Manual testing:
useLatestSession