Skip to content

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

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:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions