Documentation Index
Fetch the complete documentation index at: https://oxy.tech/docs/llms.txt
Use this file to discover all available pages before exploring further.
Building the Semantic Layer
Once you’ve defined your semantic layer with views, entities, dimensions, and measures, you need to build it before use:oxy build after creating or modifying semantic layer files to ensure your changes are picked up.
In Agents
Add thesemantic_query tool to your agent to enable it to query the semantic layer directly. The agent can then answer business questions using your defined metrics and dimensions.
Basic Setup
agents/analytics.agent.yml
Tool Configuration
Thesemantic_query tool has the following properties:
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the tool |
type | string | Yes | Must be semantic_query |
topic | string | Yes | Name of the semantic topic to query |
When querying a topic with default_filters, those filters are
automatically applied to all queries. User-provided filters are combined with
default filters using AND logic. For example, if a topic has a default filter
for
tenant_id = 'abc123', every query will be scoped to that tenant
regardless of additional filters specified by the user.Example Queries
Once configured, your agent can handle queries like:- “What’s the total revenue by customer segment?”
- “Show me the top 5 products by sales this month”
- “What’s the average order value for each acquisition channel?”
Multiple Topics
You can add multiplesemantic_query tools for different topics:
agents/multi_domain.agent.yml
In Workflows
Use thesemantic_query task type in workflows to execute structured queries against your semantic layer. This is ideal for automated reporting, data pipelines, and scheduled analytics.
Basic Workflow Task
workflows/sales_report.workflow.yml
Semantic Query Task Properties
| Property | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be semantic_query |
topic | string | Yes | Name of the semantic topic to query |
dimensions | array | No | List of dimensions to include (view.field format) |
measures | array | No | List of measures to calculate (view.field format) |
filters | array | No | Filters to apply to the query |
orders | array | No | Sort order for results |
limit | number | No | Maximum number of rows to return |
Field Referencing
Reference dimensions and measures using the formatview_name.field_name:
Filtering Data
Apply filters to narrow down your results. These filters are combined with any default_filters defined in the topic using AND logic:If the topic
ecommerce_analytics has default filters (e.g., tenant_id = 'xyz'), they are automatically applied along with the filters specified
above. All default filters and user filters must be satisfied.Ordering Results
Control the sort order of your results:Advanced Example
workflows/customer_analysis.workflow.yml
In Routing Agents
Routing agents can include semantic topics as routes, enabling intelligent task routing based on semantic understanding.Adding Topics to Routes
agents/_routing.agent.yml
Complete Routing Example
agents/_data_router.agent.yml
Best Practices
Agent Usage
- Provide clear system instructions on when to use semantic queries
- Include multiple topics for agents that span business domains
- Let the agent decide which dimensions and measures to use based on the question
Workflow Usage
- Use semantic queries for repeatable analysis patterns
- Leverage variables for dynamic filtering
- Chain semantic queries with agent tasks for insights generation
Routing Agent Usage
- Include semantic topics alongside specialized agents and workflows
- Use glob patterns to automatically include all topics
- Provide clear routing instructions in system_instructions
- Configure appropriate fallback routes
Performance
- Use
limitto constrain result set size when appropriate - Be selective with dimensions—only include what you need
- Consider adding indexes on frequently filtered columns
- Use default_filters in topics for common business rules
Error Handling
- Test your semantic queries before deploying to production
- Handle cases where queries return no results
- Provide meaningful error messages to users
- Monitor query performance and optimize as needed
Related Documentation
Topics
Organize views into topics
Agents
Learn more about agents
Workflows
Learn more about workflows
Overview
Back to semantic layer overview