Skip to content

Scheduled job sessions are not resumable — user cannot follow up on scheduled messages #149

@felixeu31

Description

@felixeu31

Problem

When a scheduled job fires and sends its output to a chat, the user cannot continue the conversation from that context. Replying to the scheduled message starts a completely new Claude session, losing all context.

Expected behavior

After a scheduled job delivers its message, the user should be able to reply and continue the conversation naturally — just like any other bot interaction.

Root cause

AgentHandler.handle_scheduled() calls ClaudeIntegration.run_command() without a session_id, creating a fresh isolated session. The resulting session ID is never stored, so it's impossible for subsequent user messages to resume from it.

Current flow:

ScheduledEvent → AgentHandler.handle_scheduled()
  → ClaudeIntegration.run_command(prompt, working_dir)  # no session_id
  → new Claude session created
  → response sent to chat via NotificationService
  → session_id discarded ← problem here

Proposed solution

  1. After run_command() completes, capture the returned session_id
  2. Store it in SessionManager for the target user (resolved from target_chat_ids + created_by)
  3. The user's next message will auto-resume from the scheduled job's context via the existing session resumption logic

Edge cases to consider

  • Multiple target_chat_ids: each target user needs their own session state saved
  • User mid-conversation: if the user had an active session, the scheduled job would overwrite it — may need a strategy (e.g., only update if user is idle, or notify the user)
  • created_by mapping: the created_by field in scheduled_jobs can help resolve the originating user for session assignment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions