OData Query Guide
List endpoints accept OData-style query parameters — $filter, $select — alongside sort_by,
sort_order, skip, and limit. Filtering is handled by the odata-query
library against the SQLAlchemy models (app/utils/odata.py).
Query parameters
| Parameter | Purpose | Example |
|---|---|---|
$filter | Filter rows with OData expressions | $filter=status/name eq 'Active' |
$select | Return only selected fields (id always included) | $select=name,score_type,threshold |
sort_by | Sort field | sort_by=created_at |
sort_order | Sort direction (asc or desc) | sort_order=desc |
skip | Pagination offset | skip=20 |
limit | Max rows returned | limit=50 |
Comparison operators
eq, ne, gt, lt, ge, le:
String functions
Function-style syntax: function(field, value).
Navigation properties
Traverse relationships with /: relationship/field. This resolves related data in a single
request instead of chaining calls.
Logical operators
Combine conditions with and, or, not, and group with parentheses:
Sorting and pagination
Field selection with $select
$select takes a comma-separated list of top-level fields and filters the serialized response
after the query runs. id is always included so entities stay addressable. It reduces payload
size but does not change which rows match $filter.
$select works on all standard list endpoints generated through the backend routers.
MCP server-managed pagination
When list operations are called through MCP tools rather than direct REST, some tools define a
server-managed page_size in mcp_tools.yaml. In those cases limit is hidden from the model, the
server applies a fixed page size with peek-ahead (limit = page_size + 1), and responses are
wrapped with _pagination metadata:
For direct REST calls, limit and skip remain client-controlled.
URL encoding
Encode filter values in query strings: space becomes %20, / becomes %2F, ' becomes %27.
Error responses
Invalid fields or unparseable expressions return 400 with a detail message:
Use function-style syntax for string operations — contains(behavior/name,'test'), not
behavior/name contains 'test'.
Endpoints supporting OData filtering
/tests, /behaviors, /topics, /categories, /test_sets, /test_runs, /test_results,
/prompts, /metrics, /projects, and related list routes. Each supports the navigation
properties defined by its model relationships.