mirror of
https://github.com/openai/codex.git
synced 2026-11-24 15:21:20 +00:00
Copy current thread attachments into non-ephemeral forks (#45579)
## What changed Copy the source thread's current attachments when creating a non-ephemeral fork, including forks at an earlier turn. Copies receive new attachment IDs and creation timestamps while preserving resource identities and payloads. Attachment membership can then change independently on either thread; referenced resources are not copied. Await the atomic copy before publishing the fork. If copying fails, log the error and allow the conversation fork to succeed without attachments. Resuming a fork does not copy attachments again. Document that clients should use `forkedFromId` on `thread/started` and fetch the fork's attachments with `thread/attachment/list`; copying does not emit per-attachment updates. ## Testing Add coverage for atomic rollback, independent attachment membership, inheritance across history cutoffs, successful conversation forks after copy failures, and resuming without restoring removed attachments. GitOrigin-RevId: 939d2c6a3073ccfcd922380c6beda45d3deac606
This commit is contained in:
1 parent
4e6450bbfd
commit
19286b8819
10 files changed
+339
-15
No files matched your search
@@ -2145,6 +2145,8 @@ impl ThreadManagerState {
|
||||
} else {
|
||||
codex_sandboxing::WindowsSandboxProxySettingsMode::Reconcile
|
||||
};
|
||||
let attachment_source =
|
||||
forked_from_thread_id.filter(|_| matches!(&initial_history, InitialHistory::Forked(_)));
|
||||
let (session, io) = Session::spawn(SessionSpawnArgs {
|
||||
startup,
|
||||
config,
|
||||
@@ -2207,6 +2209,21 @@ impl ThreadManagerState {
|
||||
windows_sandbox_proxy_settings_mode,
|
||||
})
|
||||
.await?;
|
||||
if let Some(source_thread_id) = attachment_source
|
||||
&& session.live_thread().is_some()
|
||||
&& self.thread_store.supports_thread_attachments()
|
||||
{
|
||||
// Fork initialization already handles persistence. Copy current membership before
|
||||
// registration, but do not fail the conversation fork for attachment metadata errors.
|
||||
let thread_id = session.thread_id();
|
||||
if let Err(error) = self
|
||||
.thread_store
|
||||
.copy_thread_attachments(source_thread_id, thread_id)
|
||||
.await
|
||||
{
|
||||
warn!(%thread_id, %source_thread_id, %error, "failed to copy fork attachments");
|
||||
}
|
||||
}
|
||||
// Enable Full Access form input only after session startup so a required MCP server cannot
|
||||
// block startup while waiting for form input.
|
||||
if session
|
||||
|
||||
Reference in new issue
Block a user