Build agents with the th file
You can build agents as code using the Toolhouse Agent File, or th file for short. The th file is a YAML file that defines the configuration of an agent deployed on the Toolhouse platform. This file contains essential information about the agent, such as its ID, behavior, and interactions. In this documentation, we will walk you through the different sections of the configuration file, explaining the purpose and usage of each entry.
File Structure
The configuration file is a YAML file that consists of several key-value pairs. The file is divided into sections, each defining a specific aspect of the agent.
Agent ID
The first section of the file defines the agent's ID.
id
id
Type: String
Description: The unique identifier of the agent. This value is automatically generated when creating a new agent. Do not change this value unless you know what you're doing, as it may cause issues with the agent's functionality.
title
title
Type: String
Description: The name of the agent. This value is used for display purposes and can be changed at any time.
Agent Behavior
The next section defines the agent's behavior.
prompt
prompt
Type: String
Description: The prompt that the agent will use to generate responses. You can use variables in the prompt by wrapping them in curly braces (e.g.,
{variable_name}
). The variables will be replaced with their corresponding values when the agent is executed.
vars
vars
Type: Dictionary
Description: A dictionary of variables used in the
prompt
. You can define default values for these variables. Ensure that the variable names match those used in theprompt
.
Example:
In this example, the prompt
is "Write a short story about {topic} featuring {name}"
, which means the vars
section must contain topic
and name
. When running the agent, Toolhouse will compile the prompt by replacing the variables with these values:
You can overwrite the value of one or more of your variables by passing values when making an API request to your agent:
system_prompt
system_prompt
Type: String
Description: The system prompt that sets the context for the agent. Variables are not allowed in the
system_prompt
. This value is used to provide additional context to the agent.
Agent Configuration
The next section defines additional configuration options for the agent.
bundle
bundle
Type: String
Example:
public
public
Type: Boolean
Default:
true
Description: A flag indicating whether the agent is public or private. Public agents are visible to all users and can be used by anyone. Private agents are only visible to the owner and can only be used when called with the owner's API key. Toolhouse Pro users can create private agents that are not visible to other users.
toolhouse_id
toolhouse_id
Type: String
Description: The end-user ID that provides context about the user interacting with the agent.
Scheduling
The final section defines the scheduling configuration for the agent.
schedule
schedule
Type: String (Cron format)
Description: A cron expression that specifies when the agent should run. For example,
"0 0 * * *"
would run the agent every day at midnight.
Examples
Here are a few examples of how you can use the Toolhouse Agent Configuration file.
Last updated