Skip to content

/loop slash command cron task lost after session resume #346

@xiaolinsq

Description

@xiaolinsq

Summary

When a user creates a cron task using the /loop slash command via query(), the task works as expected during the live session. However, after the session is closed and subsequently resumed — either via query({ resume: sessionId }), the background cron task is completely lost and fails to persist. SDK consumers have no way to recover or re-register the active loop from the resumed session history.

Environment

  • @anthropic-ai/claude-agent-sdk : 0.3.168

  • Node.js: 22.x

  • Consumer: TypeScript backend utilizing session resume capabilities

Reproduction

  1. Start a session with query({ prompt, options: { ... } }).

  2. Send /loop <interval> <command> (or any cron-based slash command) to successfully register a background task.

  3. Verify that the task triggers successfully at least once during the active stream.

  4. End the current process / close the connection to terminate the live session.

  5. In a fresh process, resume the session using query({ resume: sessionId }).

  6. Query the AI or SDK state to check active background tasks (e.g., inspecting the active cron list).

Actual behaviour

The session history resumes successfully, but the background cron task created by /loop disappears completely.

  • No background triggers occur after the resume.

  • The SDK does not automatically re-register or re-schedule the cron tasks found in the persisted transcript.

  • When querying the AI or SDK for active loops after resumption, the returned CronList result is completely empty, leaving consumers with no way to manually inspect or revive the tasks.

Expected behaviour

The SDK should natively parse the persisted session history upon resume and automatically re-register any active background cron tasks (/loop) associated with that session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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