To learn more about agents, check out our dedicated agents section.
.agent.yml
files, and anything with that extension within your oxy
repository will be recognized as an agent.
1
Creating an .agent.yml file
Create a new file in your oxy repository called
my-agent.agent.yml
. You
can do so by running the following command from within your oxy repository:2
Specifying the model to use
Now you need to specify which model you want this agent to use. If you’ve
been following our guide thus far, you should have a model named
openai-4.1
, named during our setup.Open your my-agent.agent.yml
file in a text editor, and add the following line:3
Adding system instructions
Now we need to give the LLM some instructions. Typically, large language
models accept two components to a prompt: (1) the prompt itself and (2) a
series of system instructions indicating how the LLM should behave.We’ll be using the latter (the
system_instructions
) to give our LLM
general instructions as well as context on our data.The
oxy run
command takes agent files or workflow files as arguments.
Therefore, if you’re not in the same directory as your agent file, you need
to specify the relative path to the agent, with e.g. oxy run path/to/my-agent.agent.yml
.4
Giving your agent the ability to execute SQL
To make this agent suitable for analytics purposes, you’ll need to give it
the ability to execute the SQL it writes. To do this, you can add a
tools
section to your .agent.yml
file, as follows:5
Creating a file with schema information
The final step in getting your agent running is to give it some context to
get started. To do this, we’ll need to create a file with some schema
information. Let’s create a new `schema.txt“ file in the root of your
oxy directory.In this file, we’ll include some details about your data. We’ve found that
supplying a list of csv files, each with a list of columns and a sample row
works reasonably well. You can simply copy the first two lines of your csv,
then preface the header row with This whole thing will be slurped up into your system instructions, so feel
free to add any additional context about your data here as well.
columns:
and the row of data with
sample row:
, as follows. You should also add in a sample query so the LLM
gets a sense of how to query this.To test any queries you write, you can run
oxy run <filename>.sql
.If your agent is having trouble parsing the schema information, it may make
sense to instead inject it as json, or specify the sample values within a
semantic model.
6
Giving this context to your agent
Now you can add this file to a Then, reference this object with Jinja in your system instructions:
context
section within your .agent.yml
file, as follows:Note that
file
-type context
objects take an array (whereas
semantic_model
type src
entries will take a single value, because they
are parsed).