Sidecars & Scheduled Tasks: /schedule, /automation & sidecar.json
Use Antigravity for daily engineering work long enough and you will run into two distinct time-based needs:
- 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.
- 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.

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 withTimerConditionfor event-driven wakeups: it defaults tonever(wait out the full duration), or you can set it toany(cancel early and wake up on any incoming message) or a specificsender 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 tofalse, adding slight jitter to avoid top-of-the-hour load spikes; set totrueonly when exact wall-clock firing is strictly required.IsDaemon: Cron-only. By default, the schedule stops once the current main task finishes; set totrueonly 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:
- Built-in scheduler (
"builtin": "schedule"): Scaffolded via/automationand always paired with"restart_policy": "always". - 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". - UI sidebar & plugin companion services: As noted in Part 09 on plugin validation,
agy plugin validateexplicitly reports asidecarscount—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 | ~/.gemini/config/sidecars/ |

Here is a production-ready template you can adapt directly:
1 | { |
Break any one of these five hard rules and the automation will silently fail or behave unexpectedly:
- Use
snake_casefor every top-level and nested key
This coversrestart_policy,display_name,agent_permissions,access_grants, andworkspace_uris. If you just finished editingplugin.jsonfrom Part 09 and accidentally type camelCase likedisplayName, the field will not match. args[0]must be a full 5-field Cron string withCRON_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 asCRON_TZ=Asia/ShanghaiorCRON_TZ=America/New_York), never abbreviations likePST/CSTor offsets like+08:00. If a custom Cron expression already starts withCRON_TZ=orTZ=, leave it as-is instead of stacking duplicate prefixes.- Separate the prompt with
--, and point local scripts only at stable absolute paths
Insideargs("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 pointsidecar.json, helper scripts, or symlinks inside~/.gemini/config/to/tmpor ephemeral workspaces that may be cleaned up. - 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". - 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:
flowchart TD
T1["Turns 1-2: Confirm frequency, time & IANA timezone"] --> T3["Turn 3: Write a 100% self-contained task prompt"]
T3 --> T4["Turn 4: Write sidecars/sidecar-id/sidecar.json"]
T4 --> SAFE{"Security red line: Agent must NEVER self-enable"}
SAFE -->|"Output display_name & sidecar://dashboard"| T5["Turn 5: Execute a live Test Run in current session"]
T5 --> CHECK["Verify commands / file I/O / URLs / MCP availability"]
CHECK --> GRANT["Backfill minimal real dependencies into agent_permissions"]
GRANT --> ENABLE["User manually reviews & enables in Automations Dashboard"]
ENABLE --> CRON["Cron fires on CRON_TZ via agentapi new-conversation"]
CRON --> RUN["Unattended run: allowlist passes, everything else auto-denied"]
Walking through all five turns takes a couple of minutes and prevents silent overnight failures:
- Turn 1 · Confirm frequency: Choose
Hourly,Daily,Weekly, orCustom cron schedule. - 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.
- Turn 3 · Refine a self-contained prompt: Pin down exact inputs, selection rules, and output formatting up front.
- 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": trueintouser_config.json, nor call any command or RPC to silently start the Sidecar. Instead, it gives you the exactdisplay_nameand[Open Automations Dashboard](sidecar://dashboard)so you review and flip the switch yourself. - 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 insideargs.
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 | { |
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 | { |
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.
Scenario B: Weekday 9:00 AM PR & Blog Broken-Link Digest (Use sidecar.json)
For a recurring daily audit that must run even with every terminal closed, write ~/.gemini/config/sidecars/weekday-pr-blog-digest/sidecar.json:
1 | { |
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
- 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 fromagent_permissions.access_grantsgets auto-denied. Make Turn 5’s Test Run non-negotiable before enabling any/automation. - 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 forAsia/Shanghai. Another frequent mistake is writingCRON_TZ=+08:00orCRON_TZ=CST; always use standard IANA names likeCRON_TZ=Asia/Shanghai. - Pointing scripts or symlinks at temporary directories
Dropping a helper script into/tmpor 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. - 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. Eachagentapi new-conversationrun starts completely blank; if you need historical diffs, put the exact absolute path and read step directly in the prompt. - Polling with shell
sleeploops insiderun_command
Runningsleep 60viarun_commandties 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/schedulewithTimerConditionorCronExpression, and clean up withmanage_task.


















