Schedule and automate agents

Once you’ve created agents to analyze your data, you’ll often want them to update automatically to reflect the latest information. This guide explains how to schedule and automate your agents to keep their outputs fresh.

Enabling automatic updates

To keep your agent’s outputs fresh with the latest data, you can enable automation.

1import requests
2
3BASE_URL = "https://alfa.boosted.ai/client"
4API_KEY = "YOUR_API_KEY_HERE"
5
6headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}
7
8def enable_agent_automation(agent_id):
9 """Set an agent to automatically update on a schedule."""
10 url = f"{BASE_URL}/agent/enable-automation"
11 payload = {"agent_id": agent_id}
12
13 response = requests.post(url, headers=headers, json=payload)
14
15 if response.status_code == 200:
16 data = response.json()
17 next_run = data.get("next_run", "Unknown")
18 print(f"Automation enabled. Next run scheduled for: {next_run}")
19 return True
20 else:
21 print(f"Error: {response.status_code}, {response.text}")
22 return False
23
24# Enable automatic updates for our agent
25enable_agent_automation("your-agent-id")

By default, agents are scheduled to run daily at 8AM in the US/Eastern timezone. You can customize this schedule using the set-schedule endpoint.

Example: Enable automation for a stock analysis agent

1

Create your agent

First, create an agent to analyze stock market data

2

Enable automation

Enable automation to keep the analysis updated daily:

1# Enable updates for a market analysis agent
2agent_id = "a1b2c3d4-5678-90ef-ghij-klmnopqrstuv"
3success = enable_agent_automation(agent_id)
4
5if success:
6 print("Your market analysis will now update automatically!")
3

Check status

Verify the agent’s status after enabling automation

Customizing the schedule

You can customize when your agent runs using natural language schedules.

1def set_agent_schedule(agent_id, schedule_description, timezone=None):
2 """Set a custom schedule for an agent using natural language."""
3 url = f"{BASE_URL}/agent/set-schedule"
4 payload = {
5 "agent_id": agent_id,
6 "user_schedule_description": schedule_description
7 }
8
9 if timezone:
10 payload["agent_timezone"] = timezone
11
12 response = requests.post(url, headers=headers, json=payload)
13
14 if response.status_code == 200:
15 data = response.json()
16 print(f"Schedule updated: {data['schedule']['generated_schedule_description']}")
17 print(f"Next run will use timezone: {data['schedule']['timezone']}")
18 return data
19 else:
20 print(f"Error: {response.status_code}, {response.text}")
21 return None
22
23# Set a custom schedule
24set_agent_schedule("your-agent-id", "Weekly on Friday at 3pm", "US/Pacific")

The schedule is interpreted by our backend and converted to the appropriate cron expression. You can use natural language to describe when you want your agent to run.

Example schedule descriptions

Here are some examples of schedule descriptions you can use:

  • “Daily at 9:30am”: Every day at 9:30 AM
  • “Weekly on Monday at 7am”: Every Monday at 7:00 AM
  • “Every weekday at 4pm”: Monday through Friday at 4:00 PM
  • “Monthly on the 1st at 12pm”: First day of each month at 12:00 PM

Example: Schedule an earnings report agent to run weekly

1

Identify the agent

Select the earnings report agent you want to schedule

2

Set the schedule

Configure it to run weekly before market open:

1# Schedule weekly earnings report before market open
2agent_id = "earnings-report-123456"
3schedule = "Weekly on Monday at 8:30am"
4timezone = "US/Eastern"
5
6result = set_agent_schedule(agent_id, schedule, timezone)
7print(f"Your earnings report will run every Monday at 8:30am Eastern Time")

Disabling automation

If you no longer want an agent to run automatically, you can disable its automation.

1def disable_agent_automation(agent_id):
2 """Disable automatic updates for an agent."""
3 url = f"{BASE_URL}/agent/disable-automation"
4 payload = {"agent_id": agent_id}
5
6 response = requests.post(url, headers=headers, json=payload)
7
8 if response.status_code == 200:
9 data = response.json()
10 if data.get("success"):
11 print("Automation successfully disabled")
12 return data.get("success", False)
13 else:
14 print(f"Error: {response.status_code}, {response.text}")
15 return False
16
17# Disable automation for an agent
18disable_agent_automation("your-agent-id")

When you disable automation, the agent will retain its schedule configuration but won’t run automatically. You can re-enable it later with the same schedule.

Manually triggering updates

If you need updated results immediately, you can manually trigger a rerun.

1def rerun_agent(agent_id):
2 """Manually trigger an agent to run again."""
3 url = f"{BASE_URL}/agent/rerun-agent"
4 payload = {"agent_id": agent_id}
5
6 response = requests.post(url, headers=headers, json=payload)
7
8 if response.status_code == 200:
9 data = response.json()
10 success = data.get("success", False)
11 if success:
12 print("Agent rerun successfully initiated")
13 return success
14 else:
15 print(f"Error: {response.status_code}, {response.text}")
16 return False
17
18# Rerun our agent to get fresh data
19rerun_agent("your-agent-id")

After triggering a rerun, you’ll need to check the agent’s status again and retrieve the new outputs once it completes.

Example: Rerun after breaking news

1

Breaking news happens

A significant event occurs that impacts your analysis

2

Trigger immediate update

Don’t wait for the next scheduled run:

1# Trigger immediate update after breaking news
2agent_id = "breaking-news-analyzer-123"
3
4# Trigger the rerun
5rerun_success = rerun_agent(agent_id)
6
7if rerun_success:
8 print("Breaking news analysis has been initiated!")