Introducing Vercel Schedules

Vercel News · 软件开发

Cron jobs are useful for work that needs to happen regularly. You can use them to do things such as back up your database on a schedule, or keep data in sync between two systems. You define them once in code and then can update them by editing their config and redeploying. But today, agents interact with users as work evolves, and schedules need to be updated in real time. We built Vercel Schedules to allow agents and applications to create, change, or cancel one-time and recurring schedules through code, without redeploying. What are Vercel Schedules? Schedules builds on the static approach used by Vercel Cron Jobs , but are designed to let users and agents decide when work should happen while your application is still running. A schedule tells Vercel when to trigger a task and where to send it. Your application provides the code that carries out the work. You can use schedules for both static and dynamic jobs: Static schedules keep the timing in vercel.json or Build Output API configuration and sync when you deploy. You can use them to call private functions or HTTP paths, or send messages to Queue topics . Dynamic schedules let your app create and manage schedules through the JS SDK , CLI , or API as it runs. They support one-time and recurring work through Queue topics. You can also test scheduled work on Preview deployments and in custom environments before running it in Production. How Schedules works Take this example: A user could ask an agent with web access, “Tomorrow morning, summarize the top five stories on Hacker News.” The traditional solution would be storing the request and its schedule time in a database, then using a cron job to check for work that is due. With Schedules, an agent can create a schedule that records the request and when to run it, without a separate database and polling job. The example below defines an AI SDK tool that gives an agent this capability. When the task is due, Vercel uses Queues to deliver the saved request to your app

查看原文