Skip to content

feat(codemode): durable Code Mode execution (suspend on shutdown, resume on boot) #66478

Backlog

Description

@hearnadam

Follow-up to #66278 (agent() and llm() in Code Mode scripts).

Current state

What's needed

  1. Persist psychoscript VM snapshots for running CodeModeJobs on graceful shutdown and resume them in packages/core/src/session/execution/restart.ts.
  2. Add Extension.durable / Extension.idempotent (with stable <runId>:<callId> keys) or route agent()/llm() through Tool.durable/Tool.idempotent:
    • agent(): durable — start creates and prompts the child session and returns { childSessionID }; wait resumes/awaits the child and reads its result from history; cancel interrupts the child on real cancel (never on suspend).
    • llm(): idempotent — safe to interrupt on suspend and re-run on resume.
  3. Move per-script limits (started counts and the rate/quota circuit breaker) from the in-memory WeakMap into run.metadata so they survive suspend/resume.
  4. Remove the temporary orphan-release bypass in restart.ts once scripts themselves resume on boot.

Activity

  1. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    Thanks for writing this up. This is a feature request, not a bug report, so there was nothing to reproduce. The restart path in packages/core/src/session/execution/restart.ts reports background work it can't continue as lost, and that matches the current state you describe. In other words, today's behaviour is working as designed, and the durable suspend/resume work listed here is new functionality. I'm leaving this for the team to track as a feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions