Skip to content

Fix Codex continuation after workspace archive - #4512

Merged
boudra merged 2 commits into
mainfrom
qa-codex-archive-continuation
Sep 9, 2026
Merged

Fix Codex continuation after workspace archive#4512
boudra merged 2 commits into
mainfrom
qa-codex-archive-continuation

Conversation

@boudra

@boudra boudra commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Linked issue

Observed during hosted continuation QA in getpaseo/hub#123. Related to #4353 and #4473; this focused archive fix does not replace the provider history refactor.

Type of change

  • Bug fix

Reasoning

After a GitHub follow-up restored an archived workspace, the same Codex agent failed with thread … already has an active writer. Paseo called native archive before closing its runtime, so Codex rejected archive. Loading that archived conversation then acquired a writer before native unarchive.

Close the runtime before native archive. Before native unarchive, release any runtime loaded for archived history. This also repairs continuation of existing records left native-active by older daemons; no stored data or protocol migration is required.

Goals

  • Continue the same agent and native conversation after workspace archive and restore.
  • Support already archived records created by previous daemons.

Non-goals

  • Change provider history APIs, Hub trigger policy, RPCs, or restart recovery.

QA

  • Reproduced through real Codex and ordinary workspace recovery/send RPCs in an isolated daemon: unmodified source failed with the same active-writer error as hosted Hub.
  • Fixed source: two real Codex cases pass, covering native-archived and legacy native-active records. Each creates an owned worktree, remembers a token, archives/removes the worktree, restores it, reads history, and sends a follow-up without the token. The same agent/session replies RECALLED=ARCHIVE_CEDAR_7429.
  • PASEO_NATIVE_ARCHIVE_QA=1 npx vitest run src/server/daemon-e2e/agent-archive.native.real.e2e.test.ts --bail=1: 2 passed.
  • npx vitest run src/server/agent/agent-manager.test.ts --bail=1: 180 passed, including native writer ownership regression.
  • Server build, repository typecheck, lint, and format check pass.
  • Hosted Hub QA against the built isolated daemon PASSED: first reply, then memory recall after archive/restore. Same agent 2ec6e916-2419-449b-b988-a7b1c0b92e68 and session ce8d11ac-b9ea-5fcc-abe5-672dfc6e1276; executions 046aee71-1034-5bd8-b6a0-19f3f50dbd47d272d06e-9703-5de8-8f38-cabb2251f2c8. Both replied, finished, and archived. The main development daemon was not restarted and still requires this update.

Checklist

  • One focused change
  • npm run typecheck passes
  • npm run lint passes
  • npm run format passes
  • QA evidence
  • Tests added or updated where it made sense

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes Codex continuation after workspace archive and restore by releasing the loaded runtime before synchronizing native archive state.

  • Closes the agent runtime before native archive so the provider no longer sees an active writer.
  • Releases runtimes loaded from archived history before native unarchive.
  • Adds regression coverage for writer ownership and opt-in real Codex coverage for native-archived and legacy native-active records.

Confidence Score: 5/5

The PR appears safe to merge; no outstanding correctness, security, or repository-rule finding remains.

Runtime shutdown now precedes both native archive and native restore synchronization, with regression coverage for current and legacy records. The prior test-shape finding was manually resolved without explanation and is not outstanding.

Important Files Changed

Filename Overview
packages/server/src/server/agent/agent-manager.ts Reorders archive and restore lifecycle operations so native synchronization occurs only after the runtime releases its writer.
packages/server/src/server/agent/agent-manager.test.ts Adds focused regression coverage proving native archive and restore release loaded session writers.
packages/server/src/server/daemon-e2e/agent-archive.native.real.e2e.test.ts Adds opt-in real Codex coverage for continuation across ordinary and legacy archive states and extracts the scenario mechanics from the test body.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Manager as AgentManager
    participant Runtime
    participant Codex as Native Codex Session
    participant Store as Agent Storage

    Client->>Manager: Archive workspace
    Manager->>Store: Mark record archived
    Manager->>Runtime: Close runtime / release writer
    Manager->>Codex: Archive native session

    Client->>Manager: Restore workspace
    Client->>Manager: Load archived history
    Manager->>Runtime: Close any loaded archived runtime
    Manager->>Codex: Unarchive native session
    Manager->>Store: Clear archived state
    Client->>Manager: Send follow-up
    Manager->>Codex: Resume same native session
Loading

Reviews (2): Last reviewed commit: "Keep archive QA mechanics in a scenario ..." | Re-trigger Greptile

Comment thread packages/server/src/server/daemon-e2e/agent-archive.native.real.e2e.test.ts Outdated
@boudra
boudra merged commit 613cbbe into main Sep 9, 2026
24 checks passed
@boudra
boudra deleted the qa-codex-archive-continuation branch September 9, 2026 06:51
dwyanewang added a commit to dwyanewang/paseo that referenced this pull request Sep 9, 2026
Review main da8c1b5..c172076 against all six overlays. Keep each overlay; provider-history was rebased and updated through 310d340 to preserve read-only archived history alongside getpaseo#4512.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant