Skip to content

Bug: partialArgs JSON duplication in agentTurn cron jobs with isolated sessionTarget #53852

@ohall

Description

@ohall

Bug Description

When running cron jobs with payload.kind: "agentTurn" and sessionTarget: "isolated", the tool call partialArgs field contains malformed JSON due to duplicate content concatenation.

Error Message

Unexpected non-whitespace character after JSON at position X (line 1 column Y)

Actual vs Expected Behavior

Expected (valid JSON):

"partialArgs": "{\"path\": \"/some/file.md\"}"

Actual (malformed JSON):

"partialArgs": "{\"path\": \"/some/file.md\"}{\"path\": \"/some/file.md\"}"

The same JSON object is being concatenated twice, creating invalid JSON.

Affected Versions

  • 2026.1.30 (confirmed)
  • 2026.3.23-2 (confirmed - latest stable)

Reproduction Steps

  1. Create a cron job with:

    • sessionTarget: "isolated"
    • payload.kind: "agentTurn"
    • Any tool call (e.g., read, exec, sessions_history)
  2. Wait for cron to trigger

  3. Observe the error in the response

Example Cron Job That Triggers This

{
  "name": "Example research job",
  "schedule": {"kind": "cron", "expr": "0 9 * * *", "tz": "America/New_York"},
  "sessionTarget": "isolated",
  "payload": {
    "kind": "agentTurn",
    "message": "Read a file: read({\"path\": \"/some/file.md\"})",
    "model": "openrouter/moonshotai/kimi-k2.5",
    "timeoutSeconds": 120
  }
}

Observed Patterns

  • Only affects agentTurn cron jobs with sessionTarget: "isolated"
  • Does NOT affect systemEvent jobs or main session interactions
  • Happens consistently across different tool types (read, exec, sessions_history)
  • The duplication is identical - exact same JSON object appended to itself

Suspected Code Location

Based on error traces, likely in the gateway's tool call serialization for isolated sessions:

  • File: gateway-cli-Dsd9gHBa.js (minified)
  • Around line 12020 where partialJson is handled
  • Possibly in RPC adapter or session isolation code path

Impact

  • Cron jobs fail to execute tools properly
  • Repeated error messages every time cron triggers
  • Requires disabling affected cron jobs as workaround

Workaround

Disable agentTurn cron jobs with sessionTarget: "isolated" until fixed, or convert to systemEvent type jobs if they don't require isolated execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions