Scheduled Runs allow you to can schedule any Prompt Studio agent to run at specific intervals.
You can schedule as many schedules as you want per agent. Each agent can have multiple schedules, allowing you to run it at multiple intervals or for each one of your users.
Each Scheduled Run creates an Agent Run, so you can expect them to work similarly. In fact, the difference between Scheduled Runs and Agent Runs is that Agent Runs run once immediately, while Scheduled Runs run at a cadence. Just like Agent Runs, you can optionally specify a bundle to further tailor the functionality of your agent, as well as a Toolhouse ID metadata.
Agent tokens are free
All Scheduled Runs use a premium LLM model. For a limited time, LLM tokens are free, meaning you will not need to worry about cost per token. Your account will only be charged for Toolhouse Execs.
Getting started with Scheduled Runs
The minimum cadence for a Scheduled Run is every 10 minutes. If you specify a shorter cadence, the your agent will run at the minimum cadence.
Make sure you have your API Key ready. You can see or create an API key in the API Keys page.
Specifying a cadence
You'll need to specify how often you want to agent to run. The minimum cadence is every 10 minutes. To specify a cadence, simply provide a cron expression or a plain text description of the cadence. Scheduled Runs has a dedicated endpoint to translate plain text to cron:
import requests
import json
def send_request(toolhouse_api_key, cadence):
params = { "cron": cadence }
url = "https://api.toolhouse.ai/v1/text-to-cron"
headers = {
"Authorization": f"Bearer {toolhouse_api_key}",
}
response = requests.get(url, params=params, headers=headers, json=payload)
return response
# Example usage
if __name__ == "__main__":
toolhouse_api_key = "YOUR_TOOLHOUSE_API_KEY"
cadence = "sundays at 5pm UTC"
response = send_request(toolhouse_api_key, cadence)
# Check if the request was successful
if response.status_code == 200:
print("Request successful. Response:")
print(response.json())
else:
print("Request failed with status code", response.status_code)
When you pause a Scheduled Run, you interrupt its scheduled cadence without deleting it by setting its activefield to false. This is useful to keep the configuration of your Scheduled Run without deleting it completely. You can resume its execution at any time by changing its activefield back to true.
Any currently active Runs will pause at the end of their execution.
import requests
import json
def send_request(toolhouse_api_key, schedule_id, is_active):
url = f"https://api.toolhouse.ai/v1/agent-runs/{schedule_id}"
headers = {
"Authorization": f"Bearer {toolhouse_api_key}",
"Content-Type": "application/json"
}
payload = {
"active": is_active
}
response = requests.put(url, headers=headers, json=payload)
return response
# Example usage
if __name__ == "__main__":
toolhouse_api_key = "YOUR_TOOLHOUSE_API_KEY"
schedule_id = "YOUR_SCHEDULE_ID"
is_active = False
response = send_request(toolhouse_api_key, schedule_id, is_active)
# Check if the request was successful
if response.status_code == 200:
print("Request successful. Response:")
print(response.json())
else:
print("Request failed with status code", response.status_code)