Use Antigravity for daily engineering work long enough and you will run into two distinct time-based needs:

  1. You just pushed a slow CI build or kicked off a background subtask in the current session, and you want the agent to check progress every 5 minutes—or ping you if nothing comes back after 3 minutes.
  2. You want the agent to wake up on its own at 9:00 AM every weekday, compile failing-CI GitHub PRs and blog health checks into a local Markdown digest, and save it to disk—even when no terminal session is open.

New users routinely conflate the two: either they drop a sleep 60 loop into Bash and block the command channel, or they type /schedule in the current terminal expecting it to fire at 9:00 AM tomorrow—only for the job to vanish the moment they close the session.

Antigravity separates scheduling into two distinct mechanisms: session-bound /schedule (backed by the schedule tool) and persistent background /automation (backed by sidecar.json). Once you understand the boundary between them—and pair background jobs with pre-authorized agent_permissions—scheduled runs become reliable.

Comparison of Antigravity /schedule in-session timers and /automation persistent Sidecar architecture


1. Draw the Line Clearly: /schedule vs /automation

Both mechanisms handle scheduling, but their runtime, lifecycle, and use cases are completely different. Use this comparison to pick the right one immediately:

Dimension /schedule (In-Session Tool) /automation (Persistent Sidecar)
Underlying runtime Background schedule task inside the active session Sidecar process with "builtin": "schedule"
Persistent config None on disk; created dynamically per session ~/.gemini/config/sidecars/<sidecar-id>/sidecar.json
Lifecycle Bound to the current session and process; stops on exit or restart Managed as a persistent background service; runs without an open terminal
Trigger & context Injects a high-priority prompt into the current session with full context Runs agentapi new-conversation -- <prompt>, starting a fresh stateless session each time
Permission model Inherits interactive approvals from the active session Unattended mode: inherits only global permissions and presets; all other unapproved actions are auto-denied
Typical use cases Waiting on CI, monitoring background subtasks, short-lived polling (replaces shell sleep) Daily inbox digests, weekday 9:00 AM PR audits, weekly task rollups

1. /schedule: Async Alarm & Poller for the Active Session

/schedule maps to the built-in schedule tool. It exists to handle in-session waiting and periodic checks—completely replacing shell sleep loops. It supports two mutually exclusive modes:

  • One-shot countdown (DurationSeconds): Starts a background timer for the specified number of seconds and returns control immediately. Pair it with TimerCondition for event-driven wakeups: it defaults to never (wait out the full duration), or you can set it to any (cancel early and wake up on any incoming message) or a specific sender ID (cancel the timer the instant that subagent or background task reports back, avoiding wasted wait time).
  • 5-field Cron recurrence (CronExpression): Accepts standard expressions like */5 * * * *, paired with three fine-grained controls:
    • MaxIterations: Caps total triggers so a forgotten poller never spams forever (unlimited if omitted).
    • ExactTiming: Defaults to false, adding slight jitter to avoid top-of-the-hour load spikes; set to true only when exact wall-clock firing is strictly required.
    • IsDaemon: Cron-only. By default, the schedule stops once the current main task finishes; set to true only for an independent standing job that should keep firing.

All active /schedule tasks are controlled via manage_task: run list to inspect active timers and kill to cancel one at any time.

2. /automation: Persistent Background Jobs Without an Open Terminal

Whenever a task must survive across days, restarts, and unattended hours, use /automation. It writes a declarative config file to ~/.gemini/config/sidecars/<sidecar-id>/sidecar.json and delegates execution to Antigravity’s background Sidecar manager.

Each time the Cron expression fires, the manager invokes agentapi new-conversation -- <prompt>, launching a clean, isolated session to complete the job.

3. The Broader Sidecars System: More Than Cron Jobs

Scheduled automations are only one specialization of Antigravity’s Sidecars architecture. Inspect ~/.gemini/config/ locally and you will see sidecars/ already initialized by default. It supports three categories of companion services:

  1. Built-in scheduler ("builtin": "schedule"): Scaffolded via /automation and always paired with "restart_policy": "always".
  2. Custom background commands ("command" Sidecar): Runs your own long-lived daemon script or one-shot background utility. Daemons also use "restart_policy": "always", while one-shot jobs use "on-failure" or "never".
  3. UI sidebar & plugin companion services: As noted in Part 09 on plugin validation, agy plugin validate explicitly reports a sidecars count—plugins can bundle local proxies or companion services that start and stop alongside the plugin.

The built-in automation skill has an explicit scope boundary: /automation is strictly for creating Cron-based scheduled automations. Do not use it to scaffold generic "command" daemons, UI sidebar Sidecars, or short-lived in-session timers.


2. The sidecar.json Spec & 5 Non-Negotiable Rules

Locally, ~/.gemini/config/sidecars/ is already in place. Each automation lives in its own kebab-case subdirectory (such as daily-pr-check) containing a single sidecar.json:

1
2
3
~/.gemini/config/sidecars/
└── daily-pr-check/
└── sidecar.json

Quick reference for sidecar.json structure, CRON_TZ timezones, and least-privilege access_grants

Here is a production-ready template you can adapt directly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"builtin": "schedule",
"args": [
"CRON_TZ=Asia/Shanghai 0 9 * * 1-5",
"agentapi",
"new-conversation",
"--",
"Check open pull requests in /home/user/work/app using gh CLI. List any PR with failing CI checks or unresolved review comments, and save a Markdown digest to /home/user/digests/pr-daily.md."
],
"restart_policy": "always",
"display_name": "Daily PR Status Check",
"description": "Every weekday at 9:00 AM (Asia/Shanghai), checks open pull requests and writes a summary of failing checks or review comments.",
"agent_permissions": {
"workspace_uris": [
"file:///home/user/work/app"
],
"access_grants": [
"command(gh pr list)",
"command(gh pr view)",
"write_file(/home/user/digests)"
]
}
}

Break any one of these five hard rules and the automation will silently fail or behave unexpectedly:

  1. Use snake_case for every top-level and nested key
    This covers restart_policy, display_name, agent_permissions, access_grants, and workspace_uris. If you just finished editing plugin.json from Part 09 and accidentally type camelCase like displayName, the field will not match.
  2. args[0] must be a full 5-field Cron string with CRON_TZ
    When "builtin": "schedule" is set, args[0] is reserved for the schedule expression—never omit it or shift the executable to index 0. Always use standard IANA timezone names (such as CRON_TZ=Asia/Shanghai or CRON_TZ=America/New_York), never abbreviations like PST/CST or offsets like +08:00. If a custom Cron expression already starts with CRON_TZ= or TZ=, leave it as-is instead of stacking duplicate prefixes.
  3. Separate the prompt with --, and point local scripts only at stable absolute paths
    Inside args ("agentapi", "new-conversation", "--", "<prompt>"), "--" cleanly separates CLI flags from the prompt so a leading hyphen in your prompt is never misparsed as a flag. If the task invokes local scripts, place them at permanent absolute paths—never point sidecar.json, helper scripts, or symlinks inside ~/.gemini/config/ to /tmp or ephemeral workspaces that may be cleaned up.
  4. Use lowercase literals only for restart_policy
    Set "always" for "builtin": "schedule" and persistent daemons; reserve "on-failure" and "never" for one-shot "command" Sidecars. Never write proto enum names like "SIDECAR_RESTART_POLICY_ALWAYS" or Docker habits like "unless-stopped".
  5. Make the prompt 100% self-contained
    Every scheduled run spawns a blank conversation with zero memory of prior runs. Spell out the data sources, tools to invoke, filter criteria, output format, and destination file path in full.

Watch out for a subtle naming clash across config files: plugin.json uses camelCase (displayName), whereas every key in sidecar.json is strictly snake_case (display_name). It is one of the easiest typos to introduce when copying snippets by hand.


3. The #1 Unattended Pitfall: agent_permissions & Test Run First

Most people set up their first sidecar.json, flip the toggle on, expect a morning digest the next day, and instead open the new conversation transcript to see every tool call rejected.

Cron isn’t broken—unattended permissions are. When a background job triggers at 9:00 AM, nobody is sitting at the screen to click “Allow.” The session inherits only global permissions and presets; every other unapproved command, file read/write, network request, or MCP call is auto-denied.

That is why the official /automation workflow enforces a 5-turn creation flow that embeds a live Test Run before you ever turn the schedule on:

Walking through all five turns takes a couple of minutes and prevents silent overnight failures:

  1. Turn 1 · Confirm frequency: Choose Hourly, Daily, Weekly, or Custom cron schedule.
  2. Turn 2 · Confirm time and timezone: Lock down the exact hour or weekday. If you omit a timezone, the agent detects the host timezone and maps it to a standard IANA name.
  3. Turn 3 · Refine a self-contained prompt: Pin down exact inputs, selection rules, and output formatting up front.
  4. Turn 4 · Write config without enabling: Generate ~/.gemini/config/sidecars/<sidecar-id>/sidecar.json. A strict security red line applies here: the agent must never enable an automation on its own—it must not write "enabled": true into user_config.json, nor call any command or RPC to silently start the Sidecar. Instead, it gives you the exact display_name and [Open Automations Dashboard](sidecar://dashboard) so you review and flip the switch yourself.
  5. Turn 5 · Run a Test Run immediately: Execute the prompt once inside your current interactive session. This pays off three ways: missing CLIs or expired credentials surface immediately; every command, path, domain, and MCP tool actually invoked gets recorded cleanly into agent_permissions; and any better CLI flags or skill paths discovered during the run can be folded straight back into the prompt inside args.

agent_permissions Fine-Grained Grant Syntax

After the Test Run completes, lock down the exact permissions required using this least-privilege syntax:

Field / Grant Syntax Valid Minimal Example Scope & Formatting Rules
workspace_uris ["file:///home/user/work/app"] Grants read/write access to a stable workspace directory; requires an absolute file:// URI
command(<prefix>) command(gh pr list) Allowlists only verified binary + subcommand prefixes rather than exposing an entire CLI
read_file(<path>) / write_file(<path>) read_file(/home/user/notes) Scoped to exact absolute directories or files; narrow write permissions to the output directory only
mcp(<server>/<tool>) mcp(github/list_issues) Limited strictly to MCP servers and tool names verified present in the current environment
read_url(<domain>) / execute_url(<domain>) read_url(github.com) Grants read-only fetch or execution access per target domain

Two absolute red lines apply to agent_permissions. First, never use broad wildcards—including command(*), read_file(*), read_file(/), write_file(*), write_file(/), mcp(*), read_url(*), or the nonexistent allow(*) wrapper. Second, never invent MCP servers or command prefixes that are not installed and configured locally; only grant tools verified during your Test Run.


4. Two Real-World Configurations Side by Side

Here is how /schedule and sidecar.json map onto two everyday engineering workflows.

Scenario A: Waiting on a CI Build or Background Subtask (Use /schedule)

Suppose you just pushed a branch to trigger GitHub Actions, or dispatched a subagent to run the full regression suite. Never have the model run sleep 180 in the terminal.

Pattern 1: Event-driven wakeup with a countdown fallback
Attach a 180-second one-shot timer to the schedule tool and set TimerCondition to the background task or subagent sender ID (or any):

1
2
3
4
5
{
"DurationSeconds": 180,
"TimerCondition": "<background-task-or-subagent-id>",
"Prompt": "The backend regression task has been running for over 3 minutes without returning. Inspect its latest logs and report where it is blocked."
}

If the task finishes in 45 seconds, the completion message immediately cancels the 180-second timer and wakes the agent. Only if the job genuinely hangs past 3 minutes does the timeout prompt fire.

Pattern 2: Bounded periodic polling for external CI
When waiting on an external system that sends no internal message back to the session, switch to Cron polling with an explicit iteration cap:

1
2
3
4
5
6
7
{
"CronExpression": "*/5 * * * *",
"MaxIterations": 6,
"ExactTiming": false,
"IsDaemon": false,
"Prompt": "Check the latest GitHub Actions status on the current branch: if it has passed or failed, report the result and cancel this poll via manage_task; if still running, wait for the next check."
}

It caps out automatically after 6 checks (30 minutes), adds jitter by default to avoid top-of-the-hour spikes, and cancels early via manage_task kill as soon as the build finishes.

For a recurring daily audit that must run even with every terminal closed, write ~/.gemini/config/sidecars/weekday-pr-blog-digest/sidecar.json:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"builtin": "schedule",
"args": [
"CRON_TZ=Asia/Shanghai 0 9 * * 1-5",
"agentapi",
"new-conversation",
"--",
"Run two morning checks: (1) Use gh CLI in /home/user/work/app to list open pull requests with failing CI checks or pending review comments; (2) Check recent Markdown posts under /home/user/hippo/blog/hippo0913.github.io/source/_posts for broken external links or missing cover paths. Write a concise Chinese Markdown report named YYYY-MM-DD-morning-digest.md to /home/user/digests/."
],
"restart_policy": "always",
"display_name": "Weekday PR & Blog Morning Digest",
"description": "Every weekday at 9:00 AM (Asia/Shanghai), inspects failing PRs and recent blog post links, then writes a daily Markdown report.",
"agent_permissions": {
"workspace_uris": [
"file:///home/user/work/app"
],
"access_grants": [
"command(gh pr list)",
"command(gh pr view)",
"read_file(/home/user/hippo/blog/hippo0913.github.io/source/_posts)",
"write_file(/home/user/digests)",
"read_url(github.com)"
]
}
}

Once written, run a Test Run in your current session: verify gh auth status is valid, /home/user/digests is writable, and check whether any extra subcommands were invoked (for example, if the run also needed gh pr checks, add command(gh pr checks) right away). After it passes cleanly, open [Open Automations Dashboard](sidecar://dashboard), locate Weekday PR & Blog Morning Digest, and toggle it on manually.


5. Five Common Pitfalls in Practice

  1. Missing permission allowlist entries—works interactively by day, auto-denied overnight
    During daytime testing, you casually click “Allow” on permission prompts and assume the job is ready. Overnight, the unattended session has no prompt UI and no one clicking “Allow,” so every command or write path missing from agent_permissions.access_grants gets auto-denied. Make Turn 5’s Test Run non-negotiable before enabling any /automation.
  2. Omitting CRON_TZ—your 9:00 AM digest fires at 5:00 PM
    Without an explicit timezone prefix, Cron often falls back to UTC—an 8-hour shift for Asia/Shanghai. Another frequent mistake is writing CRON_TZ=+08:00 or CRON_TZ=CST; always use standard IANA names like CRON_TZ=Asia/Shanghai.
  3. Pointing scripts or symlinks at temporary directories
    Dropping a helper script into /tmp or a short-lived feature-branch clone—or symlinking into an ephemeral workspace from ~/.gemini/config/—looks fine on day one, then silently breaks the next time temp directories are purged.
  4. Writing prompts that assume cross-day memory
    Writing “pick up from yesterday’s list and only report new failures” without specifying the directory and filename convention fails every time. Each agentapi new-conversation run starts completely blank; if you need historical diffs, put the exact absolute path and read step directly in the prompt.
  5. Polling with shell sleep loops inside run_command
    Running sleep 60 via run_command ties up the command channel, risks hitting command timeouts, and misses early wakeups when a subtask finishes ahead of schedule. Always hand in-session waits to /schedule with TimerCondition or CronExpression, and clean up with manage_task.

Series Navigation