Skip to content

[Feature Request] Unfinished work must survive any interruption — durable Job state, safe resume, and workspace revalidation #55485

Open

Description

@NoxArs

Request

@tibo-openai — during the 28 Days of Shipping, could the Codex team prioritize durable unfinished work as a first-class product guarantee, and clarify whether there is a roadmap for it?

I use Codex for long-running engineering work that includes code edits, delegated agents, builds, and tests. Recent Selected model is at capacity failures exposed a deeper problem than the absence of an automatic retry button: after an execution turn dies, typing "continue" can start a new turn that tries to reconstruct and take over the unfinished work. That is not equivalent to resuming the original job.

The central invariant I want is:

An unfinished user-authorized objective remains an unfinished Job, regardless of whether its current model inference, turn, process, or client is still running. A model turn ending is not evidence that the work is complete.

This is not just a request for more retries, transcript restoration, or uninterrupted inference. Model instances may be disposable; the work identity, authorized objective, verification criteria, and committed progress should not be.

Proposed behavior

  • Separate Job identity from Thread/Turn. Persist the original objective, acceptance criteria, status, outstanding work, checkpoints, and parent/child assignments. Threads/models can detach and reattach to the same unfinished Job.
  • Allow interruption at any time. User pause, capacity failures, quota boundaries, connection loss, compaction, application/process restart, and model replacement should preserve the unfinished Job. A deliberate Cancel must be distinct from Pause. Unrecoverable/unsafe cases should be shown as blocked with a reason, not silently marked completed.
  • Resume the same work rather than issue a fresh "continue" prompt. Recovery may invoke new model inference, but it should be a continuation owned by the same Job, anchored to its persisted task state, not a new conversation guessing what the previous agent intended.
  • Revalidate reality before acting. The repository, working tree, files, runtime processes, and test results may have changed during suspension. Compare current workspace state to the evidence/versions on which the checkpoint relied; invalidate stale assumptions and replan affected steps. Do not overwrite external edits just to replay the old plan.
  • Preserve effects and approvals. Record completed tool effects separately from pending/uncertain actions. Never blindly replay a write, start duplicate processes, or bypass consent on recovery. For uncertain external effects, reconcile the environment or ask.
  • Keep multi-agent continuity. A suspended coordinator and its children should have recoverable ownership and completion states. If children cannot be resumed, expose that explicitly and let the same Job safely reassign their remaining work.
  • Make the status visible. running, suspended, recovering, blocked, unfinished, completed, and cancelled should not be conflated with the last chat turn's status. Provide a Resume action targeting the actual Job ID.

I am deliberately leaving the concrete data model to the Codex engineers. This could build on Goals, or on a separate durable Work/Job primitive; the invariant and observable behavior matter more than the specific implementation.

Suggested acceptance test

  1. Start one long-running Job, with a coordinator and child agents. Complete a file edit and a verified build; leave a later test unfinished.
  2. Interrupt the model turn (including an overload without Retry-After), then kill/restart the Codex process.
  3. While suspended, externally modify a file the next step depends on.
  4. Reopen Codex. The same Job ID must still exist and be marked unfinished; its goal, completed work, pending tests, and child states must be identifiable without interpreting a handoff summary as authoritative.
  5. Resume that Job. It must detect the changed file, revise stale assumptions, avoid replaying the completed edit/build or duplicating external effects, and continue pending verification.
  6. Mark the Job completed only after its acceptance criteria have actually been checked, or mark it blocked with a specific reason when safe continuation is impossible.

Recent progress and why this is still needed

I appreciate that Codex has already shipped pieces of this:

Those are valuable incremental fixes. They do not by themselves establish the general unfinished Job survives arbitrary interruption with workspace-aware revalidation contract above. This matters just as much when I choose to pause intentionally as when servers are busy.

Related: #48596 (intent-preserving continuity), #48144 (work identity independent of thread), #50238 (capacity queue), #41798 (Goal state not restored after retry), and #8573 (deterministic checkpoints / stale facts).

Could you please confirm whether the team plans to make this a supported end-to-end capability, and, if so, what milestone we should track? As models become better at multi-hour autonomous engineering, losing the identity and continuity of unfinished work is a more fundamental limitation than inference speed or a fresh usage reset.

Activity

  1. added
    enhancement
    session
    subagent
    on Oct 20, 2026
  2. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. bluehorizon8848-ai commented on Oct 21, 2026

    @bluehorizon8848-ai

    I’ve been working on a similar problem with Codex/OpenCode. Keeping task state and checkpoints outside the agent session helps, but recovery needs more than restoring context. The tricky part is checking what actually completed before retrying, especially when a tool call may have succeeded but its result was lost.

  4. crornia commented on Nov 16, 2026

    @crornia

    Adding a specific macOS desktop use case to this request:

    When I need to close my MacBook, go offline, or temporarily interrupt a long Codex run, the current prominent Stop action feels too final. I would like an explicit Pause for later action for ordinary in-progress tasks, not only for tasks configured as Goals.

    Desired UX:

    • Click Pause (ideally at a safe checkpoint), so Codex stops execution and repeated reconnect attempts and clearly labels the task Paused, not Stopped, Failed, or Completed.
    • Persist the task's objective, conversation/instructions, current plan, completed changes, outstanding steps, tool outcomes, and any outstanding approvals. Keep the existing thread and workspace association after app restart or Mac sleep.
    • When I reopen the laptop, click Resume on that same task. Codex should recheck files/processes and continue pending work without blindly replaying commands or undoing changes made while it was paused.
    • Make it clear what is and is not recoverable if a command was interrupted mid-execution; provide a safe handoff or recovery prompt instead of quietly discarding work.
    • Ideally support multiple concurrent Codex tasks independently and offer an optional auto-pause on disconnect / system sleep.

    The most important distinction is Pause ≠ Cancel/Stop. I want to intentionally leave and return without worrying that the agent will forget the work, silently end the task, or burn effort repeatedly reconnecting. I realize model inference itself may not be literally frozen; durable task-state continuity and a truthful resume status would solve the user problem.

    Related functionality in Goal mode is helpful, but this needs to be a discoverable, reliable interaction for any running desktop task.

  5. liuhh666233 commented on Nov 23, 2026

    @liuhh666233

    Adding a same-thread case from the Codex TUI on Linux x86_64 with GPT-6.2 Sol. The session was created with CLI 0.170.0, and the installed CLI at diagnosis was 0.171.0.

    1. I asked Codex to prepare a release that needed both a code change and a related configuration update (task A).
    2. I interrupted the running turn to investigate one configuration setting (task B) in the same thread.
    3. After I confirmed the setting, Codex completed the configuration update and ended the new turn. It picked up the pending code change after I reminded it that both changes were part of the same release.

    The local rollout marked A as interrupted and recorded the confirmation as a new turn. The sequence stayed within the same context window. The client recorded 451 items in the request history, which matched a local reconstruction that included the original request for A.

    I'd like to keep A visible as paused while I work through B in the same thread, then resume A with its original scope, completed steps, and next pending step. That would let me investigate a prerequisite and return to the release without having to restate the plan.

  6. dijarvrella commented on Nov 24, 2026

    @dijarvrella

    WorkLedger gives the unfinished work a task ID outside the Codex thread. The objective, acceptance checks, decisions, open steps and recorded delivery evidence stay with that task. A Codex turn can end while the task remains open; a connected successor session can read the same record and pick up the remaining work.

    We build WorkLedger at Digital Disruptors. It addresses the durable work-identity part of your request through a separate shared work record. It does not suspend or restore the Codex process, and the next agent still needs to check the current files and reconcile uncertain external actions before continuing.

    If that separation would help with your long-running engineering work, you can try it with one task and a fresh supported coding session:
    https://workledger-ai.com/early-access?plan=starter&utm_source=github&utm_medium=referral&utm_campaign=wl-durable-work-20261124

  7. jsibitoye commented on Dec 1, 2026

    @jsibitoye

    Adding a runnable synthetic acceptance fixture for the uncertain external-effect part of this request, based on my independent continuity/checkpoint work.

    The failure window is: a destination commits an operation, the worker exits before recording the result, and the original local journal is subsequently unavailable. The retained checkpoint still identifies the intended action. Recovery needs evidence about the destination before it can decide what happens next.

    Connection to current Codex behavior

    At 9a8b299471fb645d2c2b6d6191d465bdfe4642e3, history normalization supplies an aborted result for certain restored calls whose output is missing. The interruption guidance already warns that commands may have partially executed or still be running. The proposal here is a durable outcome record that makes that uncertainty actionable during recovery. I have not reproduced a duplicate effect in Codex.

    The general external-effect boundary is also explained in the Agents SDK crash-recovery guidance. The additional acceptance cases below cover loss of the local journal and matching the recovered evidence to the exact operation, account, destination and payload.

    Suggested contract

    • Retain a stable logical operation ID, intended account/destination, exact payload digest and checkpoint identity before dispatch. A transport call ID or narrative summary alone is insufficient.
    • Confirm completion only from a trusted provider response or authoritative readback bound to that intent. Preserve the provider's resource/version identity; for an artifact, retrieve and verify that exact version's bytes.
    • Keep an unknown outcome visible when readback fails, is incomplete or conflicts. Missing local state and an empty listing alone must not authorize another dispatch. Provider-enforced idempotency can allow safe retries under that provider's contract, including its retention limits.
    • Preserve current authorization checks. A stored operation receipt records evidence; it does not grant permission to act.

    Executable cases

    The fixture below uses a separate SQLite file as a simulated destination. A child process commits one effect and exits with os._exit(86) before returning a completion result. The test removes the entire original local-state directory, then recovers the intent from a separately retained file. The simulated destination deliberately allows duplicate effects, so the control detects an unsafe replay.

    Recovery input Observed result
    One matching destination record after the local journal is lost Confirmed; effect count remains 1.
    Empty listing or failed read, while an effect actually exists Unknown; effect count remains 1.
    Wrong logical action, account, destination or payload digest Unknown; no additional effect.
    Malformed simulator resource ID or version Unknown; no additional effect.
    Blind retry control, followed by multiple matching records Effect count becomes 2; reconciliation then remains unknown and adds no third effect.

    Observed locally: 5 tests passed, 0 failures, on Linux with Python 3.12.14. Save the code below as continuation_acceptance.py and run python continuation_acceptance.py -v. It uses the standard library, disposable files and no network access or credentials.

    This is a small contract model, not a Codex implementation or end-to-end regression test. It models abrupt process exit after a committed write, not power loss, concurrent dispatchers or all possible network failures. The fake provider supplies durable, trustworthy records; a real integration must establish its own authentication, evidence completeness, identity/version rules, atomicity and retention. This simulator uses positive integer IDs/versions; other providers may use different valid representations. The fixture does not supply a production persistence format or a universal exactly-once guarantee. Unknown outcomes can remain blocked when the destination cannot resolve them.

    Two further acceptance boundaries from the checkpoint work belong alongside these cases: restoring an older source snapshot must preserve later requirements/action confirmations, and a backup's later successful-transfer receipt must be stored separately with the backup's identity, digest and explicit state/event cutoff. The five tests below do not exercise those additional boundaries.

    Would this operation-outcome contract and these acceptance cases fit the recovery work tracked here?

    — Josh

    Standalone synthetic fixture (Python 3.12+)
    """Synthetic recovery contract, not a Codex test or production adapter.
    
    Run: python continuation_acceptance.py -v
    Uses only the standard library and disposable files. No network or credentials.
    The SQLite database models a destination with durable, readable effect records;
    it deliberately does not deduplicate writes. The intent survives separately.
    """
    
    import hashlib
    import json
    import os
    from pathlib import Path
    import shutil
    import sqlite3
    import subprocess
    import sys
    import tempfile
    import unittest
    
    
    IDENTITY_FIELDS = ("operation_id", "account", "destination", "payload_sha256")
    CRASH_AFTER_COMMIT = 86
    
    
    def provider_write(root, intent):
        """Each invocation produces another effect, even for the same operation ID."""
        with sqlite3.connect(root / "provider.sqlite3", autocommit=False) as db:
            db.execute("CREATE TABLE IF NOT EXISTS effects "
                       "(id INTEGER PRIMARY KEY, record TEXT NOT NULL)")
            db.execute("INSERT INTO effects(record) VALUES (?)",
                       (json.dumps(intent, sort_keys=True),))
            db.commit()
        db.close()
    
    
    def provider_read(root):
        """Authoritative simulator read; real integrations need their own contract."""
        with sqlite3.connect(root / "provider.sqlite3", autocommit=False) as db:
            records = [{**json.loads(body), "resource_id": row_id, "version": 1}
                       for row_id, body in db.execute(
                           "SELECT id, record FROM effects ORDER BY id")]
        db.close()
        return records
    
    
    def reconcile(intent, observations):
        """Read-only decision. Unknown does not authorize a new dispatch."""
        if observations is None or len(observations) != 1:
            return "unknown"
        record = observations[0]
        if any(record.get(field) != intent[field] for field in IDENTITY_FIELDS):
            return "unknown"
        if any(type(record.get(field)) is not int or record[field] < 1
               for field in ("resource_id", "version")):
            return "unknown"
        return "confirmed"
    
    
    def producer(root):
        intent = json.loads((root / "portable-intent.json").read_text())
        local = root / "original-local-state"
        local.mkdir()
        (local / "journal.json").write_text('{"status":"dispatched"}')
        provider_write(root, intent)
        os._exit(CRASH_AFTER_COMMIT)  # No completion receipt reaches the caller.
    
    
    class RecoveryContract(unittest.TestCase):
        def setUp(self):
            temporary = tempfile.TemporaryDirectory(prefix="continuity-contract-")
            self.addCleanup(temporary.cleanup)
            self.root = Path(temporary.name)
            self.intent = {
                "operation_id": "publish-batch-1",
                "account": "synthetic-account-a",
                "destination": "synthetic-repository/artifact-a",
                "payload_sha256": hashlib.sha256(b"synthetic artifact\n").hexdigest(),
            }
            (self.root / "portable-intent.json").write_text(json.dumps(self.intent))
            process = subprocess.run(
                [sys.executable, str(Path(__file__).resolve()), "--producer", str(self.root)],
                capture_output=True, text=True, timeout=15,
            )
            self.assertEqual(process.returncode, CRASH_AFTER_COMMIT, process.stderr)
            self.assertEqual(len(provider_read(self.root)), 1)
            shutil.rmtree(self.root / "original-local-state")
            self.assertFalse((self.root / "original-local-state").exists())
            self.intent = json.loads((self.root / "portable-intent.json").read_text())
    
        def assert_read_only_decision(self, observations, expected):
            before = provider_read(self.root)
            self.assertEqual(reconcile(self.intent, observations), expected)
            self.assertEqual(provider_read(self.root), before)
    
        def test_missing_local_state_exact_readback_confirms_one_effect(self):
            self.assert_read_only_decision(provider_read(self.root), "confirmed")
            self.assertEqual(len(provider_read(self.root)), 1)
    
        def test_empty_search_and_read_failure_stay_unknown(self):
            for observation in ([], None):
                with self.subTest(observation=observation):
                    self.assert_read_only_decision(observation, "unknown")
            self.assertEqual(len(provider_read(self.root)), 1)
    
        def test_wrong_action_account_destination_or_payload_is_not_completion(self):
            record = provider_read(self.root)[0]
            for field in IDENTITY_FIELDS:
                with self.subTest(field=field):
                    self.assert_read_only_decision([{**record, field: "different"}], "unknown")
    
        def test_invalid_resource_identity_or_version_stays_unknown(self):
            record = provider_read(self.root)[0]
            for field in ("resource_id", "version"):
                for value in (None, True, 0, -1, "", "1", 1.5):
                    with self.subTest(field=field, value=value):
                        self.assert_read_only_decision([{**record, field: value}], "unknown")
    
        def test_blind_replay_control_duplicates_then_ambiguous_readback_blocks(self):
            provider_write(self.root, self.intent)
            self.assertEqual(len(provider_read(self.root)), 2)
            self.assert_read_only_decision(provider_read(self.root), "unknown")
            self.assertEqual(len(provider_read(self.root)), 2)
    
    
    if __name__ == "__main__":
        if len(sys.argv) == 3 and sys.argv[1] == "--producer":
            producer(Path(sys.argv[2]))
        else:
            unittest.main()
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

    enhancementsessionsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions