Skip to main content
Every entity in the schema — core tables and dynamic context types alike — gets the same generated operation set. Learn the pattern once and you can operate on any type. This page uses the agent entity for worked examples; substitute any other singular/plural pair.

Naming

Operations are named from the entity’s singular and plural table names. For core entities these pairs are, for example, agent/agents, user/users, eval_run/eval_runs, prompt_library_item/prompt_library. Type names are lowercase singular (agent, eval_run); result wrapper types capitalize the first letter (AgentPaginationResult, FilterAgent).

Queries

For the agent entity, the generated fields are (verbatim from the core SDL):
agentById is the one special case in the schema: it accepts an optional project: ID argument so agent lookups can be scoped to a project. Every other entity’s ById takes only id.

Worked example: fetch and page

Pagination results wrap items with page metadata:
limit defaults to 10 and is capped at 10,000. page is 1-based: page 1 (or omitted) returns the first page, and the offset is (page - 1) * limit.

Worked example: statistics

{plural}Statistics counts records, optionally grouped by a field. Without groupBy it returns a single row with group: "total":

Mutations

For agents, verbatim from the core SDL:
Create, copy, and update mutations return a payload with the record plus an optional background-job ID (set when the write triggers processing, such as embedding generation on context items):
RemoveOne takes where: JSON! — a plain object of column/value pairs like { "session": "abc" }not the filter-operator syntax the other operations use. RemoveOneById and the two update mutations are usually the safer choice.

Worked example: create, update, delete

Filters

Every entity gets a Filter{Singular} input whose fields mirror the entity’s columns, each typed with a per-scalar operator input. The filters argument is an array; all entries (and all fields within an entry) are combined with AND. Use the or operator inside a field for alternatives. The operator inputs, verbatim from the core SDL:
Enum columns get their own operator input per enum. For example, the feedback entity’s status column (verbatim):

Worked example: AND and OR

Sorting

All list operations accept a single sort argument:

Access control

Two layers apply to every operation: Entity-type gates. For agents, workflow_templates, variables, users, test_cases, eval_sets, and eval_runs, your role must grant at least read on the matching permission (agents, workflows, variables, users, evals). Without it, queries fail with Access control error: no role found or no access to entity type. Writes additionally require the write level, enforced per record. Row-level RBAC. Tables with RBAC enabled carry a rights_mode column (private, public, users, roles, teams) and a created_by column. List and read operations silently filter to rows you can see: public rows, rows you created, and rows shared with you, your role, or your team. Super admins bypass row-level filtering everywhere except agent_sessions, which always enforces the session’s own sharing rules. RBAC-enabled types expose the resolved sharing state as a RBAC field, and accept sharing input on create/update:
Each entry pairs an id with a rights string ("read" or "write"):
For the full permission model see Users & access.

Computed fields

Some fields are resolved at query time rather than read from a column:
  • agentproviderName, modelName, streaming, capabilities, maxContextLength, authenticationInformation, systemInstructions, workflows, and slug are resolved from the agent’s provider and model configuration.
  • workflow_templatevariables: [String] lists the {variable} placeholders extracted from the template’s steps.
  • budget: JSON — present on user, role, team, project, agent, and workflow_template. Resolved from the model gateway at query time; null when the entity has no budget. See Budgets.
All entities also carry createdAt/updatedAt timestamps, plus last_processed_at and embeddings_updated_at processing markers.

Next steps

Dynamic types

Apply these patterns to your knowledge contexts.

Vector search

The retrieval operations context types add on top of CRUD.