Skip to content

Persist subagent relationships before creating child storage - #58129

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/6e2e3f32d9558091312651ab47aa845d7d13b4ca
Oct 29, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/6e2e3f32d9558091312651ab47aa845d7d13b4ca

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Persist subagent relationships before creating child storage

Why

Creating child history before persisting its parent-child relationship can leave history that parent subtree deletion cannot discover, especially when fork startup copies history. A relationship write failure must reject the spawn before child storage is created.

What changed

  • Reserve the child thread ID and persist its spawn edge before starting the child. Propagate persistence failures to the caller.
  • Keep pending relationship writes owned through caller cancellation, and wait for them to finish before closing the edge during cleanup, including when a write commits but reports an error.
  • Skip edge cleanup when publication was skipped, and reject IDs belonging to running threads before publication.

Testing

Add regression coverage for cancellation before commit or acknowledgement, errors after commit, skipped publication, and duplicate child IDs. Integration tests cover fresh children and full-history forks, verifying that failed publication leaves no child history, execution, or creation notification and preserves unrelated history during parent deletion.

## Why

Creating child history before persisting its parent-child relationship can leave history that parent subtree deletion cannot discover, especially when fork startup copies history. A relationship write failure must reject the spawn before child storage is created.

## What changed

- Reserve the child thread ID and persist its spawn edge before starting the child. Propagate persistence failures to the caller.
- Keep pending relationship writes owned through caller cancellation, and wait for them to finish before closing the edge during cleanup, including when a write commits but reports an error.
- Skip edge cleanup when publication was skipped, and reject IDs belonging to running threads before publication.

## Testing

Add regression coverage for cancellation before commit or acknowledgement, errors after commit, skipped publication, and duplicate child IDs. Integration tests cover fresh children and full-history forks, verifying that failed publication leaves no child history, execution, or creation notification and preserves unrelated history during parent deletion.

GitOrigin-RevId: 6e2e3f32d9558091312651ab47aa845d7d13b4ca
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/6e2e3f32d9558091312651ab47aa845d7d13b4ca branch from a1a520d to 875a1a7 Compare October 29, 2026 17:26
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-29T17:26:06.428725Z a1a520d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@copyberry
copyberry Bot merged commit 875a1a7 into main Oct 29, 2026
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/6e2e3f32d9558091312651ab47aa845d7d13b4ca branch October 29, 2026 17:26
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant