[Bug Report] Scheduled automations (builtin: "schedule") silently truncate multi-line prompts at the first newline character (\n) in agentapi new-conversation

[Bug Report] Scheduled automations (builtin: "schedule") silently truncate multi-line prompts at the first newline character (\n) in agentapi new-conversation

Summary

When configuring scheduled background tasks via Antigravity Sidecars (builtin: "schedule" in <configDir>/sidecars/<id>/sidecar.json), passing a multi-line string in args after -- causes agentapi new-conversation to silently truncate the prompt at the very first \n character.

Only line 1 is delivered to the newly created session’s <USER_REQUEST>. The remainder of the prompt is completely dropped without any warning or error, causing scheduled agents to execute with only their title line and missing up to 99% of their actual task instructions.


Environment

  • Platform: Google Antigravity (AGY) / Windows 11 (pwsh)
  • Component: Sidecar Daemon (builtin: "schedule") & CLI Runner (agentapi new-conversation)
  • Config file: ~/.gemini/config/sidecars/<sidecar-id>/sidecar.json
  • Sidecar log path: ~/.gemini/antigravity/sidecar_data/<sidecar-id>/logs/sidecar.log

Steps to Reproduce (Minimal Reproducible Example)

  1. Create a scheduled sidecar at ~/.gemini/config/sidecars/test-cron/sidecar.json:
    {
      "builtin": "schedule",
      "restart_policy": "always",
      "args": [
        "CRON_TZ=Europe/Berlin 0 12 * * *",
        "agentapi",
        "new-conversation",
        "--",
        "[Daily Status Report]\nStep 1: Inspect repository git status.\nStep 2: Generate summary artifact in brain directory.\nStep 3: Deliver final response."
      ],
      "display_name": "Test Cron Truncation",
      "agent_permissions": {
        "workspace_uris": [
          "file:///path/to/workspace"
        ]
      }
    }
    
  2. Enable the automation and let it trigger (or trigger it manually).
  3. Inspect ~/.gemini/antigravity/sidecar_data/test-cron/logs/sidecar.log.
  4. Inspect the resulting conversation transcript at <brainDir>/<conversation-id>/.system_generated/logs/transcript_full.jsonl (line 1, step_index: 0).

Expected Behavior

The agent in the newly spawned conversation should receive the entire multi-line string in <USER_REQUEST>:

[Daily Status Report]
Step 1: Inspect repository git status.
Step 2: Generate summary artifact in brain directory.
Step 3: Deliver final response.

Actual Behavior

The agent receives only the first line:

[Daily Status Report]

Everything after the first \n character is silently discarded.


Empirical Log & Transcript Evidence

In our live production environment across three distinct scheduled automations, we observed this behavior 100% consistently:

1. sidecar.log output

{"level":"info","time":"...","msg":"Running command","args":["agentapi","new-conversation","--","[Daily Status Report]"]}

2. transcript_full.jsonl (step_index: 0)

{
  "step_index": 0,
  "type": "USER_INPUT",
  "content": "[Daily Status Report]"
}

3. Consequences

  • In our daily 15:00 maintenance cycle, a 2,538-character prompt (48 lines) was reduced to 62 characters (97.6% lost).
  • In our 16:15 triage cycle, a 3,412-character prompt (55 lines) was reduced to 41 characters (98.8% lost). The agent was forced to run rg over the disk to guess what its purpose was.
  • In our 18:00 financial audit, a 2,845-character prompt (45 lines) was reduced to 46 characters (98.4% lost).

Root Cause Analysis

In sidecar.json, args is passed as an array of CLI arguments to the background scheduler process:

"args": [
  "CRON_TZ=...",
  "agentapi",
  "new-conversation",
  "--",
  "<prompt>"
]

When agentapi processes the CLI arguments on Windows (or when the internal sidecar runner parses the process invocation flags), either:

  1. The argument string containing raw newlines (\n) is passed without proper shell escaping / quotes to agentapi, causing the sub-process argument parser to treat the first newline as the end of the argument or command.
  2. Or agentapi new-conversation internally reads from stdin / positional arguments using a single-line scanner (e.g., readLine() or similar) rather than capturing the full remaining argument string.

Workaround for Users

Until this is patched upstream, all multi-line prompts in sidecar.json must be flattened into a single continuous line with zero \n characters (using inline separators such as | or ;):

"args": [
  "CRON_TZ=Europe/Berlin 0 12 * * *",
  "agentapi",
  "new-conversation",
  "--",
  "[Daily Status Report] Step 1: Inspect repository git status. | Step 2: Generate summary artifact in brain directory. | Step 3: Deliver final response."
]

Suggested Fixes for the Antigravity Team

  1. Preserve multi-line string arguments: Ensure the sidecar process executor properly quotes and passes strings with \n across OS process boundaries (especially on Windows).
  2. Support --prompt-file <path> or stdin: Allow agentapi new-conversation to accept --prompt-file <path> so complex automation workflows can point directly to Markdown prompt files without JSON string escaping hazards.
  3. Update /automation Skill Documentation: Until resolved, update the built-in skill documentation at skills/automation/SKILL.md to explicitly warn against using unescaped newlines in the prompt argument.