# Can my AI agent keep working on a schedule after I close the chat?

> Run the schedule on a runtime that does not depend on the agent session. The agent can write, run, and repair the job over MCP, while GearTrain keeps the schedule, files, secrets, and logs. Closing the chat does not stop the job.

## The problem

An agent session is temporary. The job is not.

People often ask an agent to keep checking a page, send a weekly report, or remember a value and alert them later. The request sounds reasonable. The agent may even say it will do it. But when the chat closes, the session ends, the machine sleeps, or the context is replaced, nothing is left to run the task.

The question is not whether the agent can write the automation. It usually can. The question is where the recurring work lives after the conversation ends.

You want something to happen again later. A job is the recurring task you asked for, such as "post last week's sales every Monday." An execution is one run of that job. A runtime is the service that starts executions on schedule, runs them, and keeps the job's files and logs after the chat closes. The runtime is separate from the chat session.

## The usual options

| Where the loop lives | What happens |
| --- | --- |
| Inside the agent session | The work stops when the session, tool call, or machine stops |
| In the agent's memory | The next session cannot see the previous state |
| In a job runtime | The schedule and state survive, and the agent reconnects to them |

The agent is useful in every version of the request. It is just not the right place to keep the schedule.

## How GearTrain solves it

GearTrain is the runtime that starts executions on schedule and keeps the job's files and logs. The agent connects to it over MCP and works with the same jobs, files, secrets, and run history that the web app and REST API use.

| Step | Agent | GearTrain | You |
| --- | --- | --- | --- |
| Connect | Requests scopes over MCP | Shows the approval page | Approves access |
| Inspect | Reads jobs, runs, and files | Supplies the current state | Decides what should change |
| Change | Writes or updates the script and job | Stores the script and settings | Reviews destructive changes |
| Test | Runs the job and reads the console | Executes the run and records logs | Confirms the outcome |
| Schedule | Adds the trigger | Keeps the schedule running | Owns the account and plan |
| Repair | Reconnects after a failure | Keeps the failed run and state | Asks for or approves the fix |

If your agent cannot connect over MCP, you can still use the web app or REST API. The agent can still help write the job even if it cannot operate the runtime.

The important part is this:

> The agent is not part of the runtime. It is an operator of the runtime.

Scheduled runs continue after the agent disconnects. The next session can inspect the same job, files, and history because the state lives in GearTrain, not in the conversation.

## What it looks like in practice

These are ordinary requests. The problem is not the task. It is assuming the agent is the runtime. Each scenario below uses the same request; only the runtime changes.

**A weekly revenue report**

**The request**

```text
Every Monday, check my Stripe account for last week's sales and post the total
to Slack.
```

**Without GearTrain**

The agent may write a script in the chat, but there is no schedule and no stored Stripe or Slack credentials. Next Monday, nothing runs.

**With GearTrain**

The agent creates a scheduled job, stores the keys as secrets, and runs it once. Next Monday, the runtime runs it without the agent. The agent can reconnect later and read the console.

**A rental listing watch**

**The request**

```text
Check this rental page every hour and text me when a new two-bedroom listing
under $2,200 appears.
```

**Without GearTrain**

The agent cannot watch the page after the chat closes, and a new session has no memory of which listings were already seen. The next check never happens.

**With GearTrain**

The agent creates an hourly job that uses a scraping service, stores seen listing IDs in a file, and posts only new matches to Slack. The runtime keeps checking after the agent disconnects.

**A supplier stock check**

**The request**

```text
Check this supplier page every morning and tell me if the price changes or the
item is back in stock.
```

**Without GearTrain**

The next session does not know the previous price or stock state. It cannot compare today's page with yesterday's.

**With GearTrain**

The agent creates a morning job that saves the last price and stock status to a file, compares each morning, and alerts only when something changes. The run log shows the saved value and the comparison.

The prompts are identical. The difference is the runtime behind the agent.

## When GearTrain is not the right fit

These are limits of the job or environment, not of your agent.

- The job needs npm packages, a full browser, heavy compute, or private networking.
- The job must stay running or hold a connection open.
- The job needs shell access to software or a machine outside the sandbox.
- The job must be self-hosted or on-premises.
- The work belongs inside a repository and should use its CI runner.

In those cases, the agent may still write the code. You need a different runtime for the schedule and execution.

## Related solutions

- [What is the easiest way to let an AI agent create and run a scheduled job?](https://geartrain.dev/solutions/let-an-ai-agent-create-and-run-a-scheduled-job)
- [How do I run a script on a schedule without running a server?](https://geartrain.dev/solutions/run-a-script-on-a-schedule-without-a-server)
- [How do I keep a scraper working when a page changes or goes down?](https://geartrain.dev/solutions/keep-scraper-working-when-page-changes)

## Documentation

- [Connect an AI Agent](https://docs.geartrain.dev/guide/mcp)
- [Writing Jobs](https://docs.geartrain.dev/guide/writing-jobs)
- [Running and Debugging](https://docs.geartrain.dev/guide/running-and-debugging)

## Start

- [Start free](https://app.geartrain.dev/signup)
