Skip to content

Add app-server thread/delete API#25018

Merged
etraut-openai merged 22 commits into
mainfrom
etraut/thread-delete-api
Jun 10, 2026
Merged

Add app-server thread/delete API#25018
etraut-openai merged 22 commits into
mainfrom
etraut/thread-delete-api

Conversation

@etraut-openai

Copy link
Copy Markdown
Collaborator

Why

Clients can archive and unarchive threads today, but there is no app-server API for permanently removing a thread. Deletion also needs to cover the full session tree: deleting a main thread should remove spawned subagent threads and the related local metadata instead of leaving orphaned rollout files, goals, or subagent state behind.

What

  • Adds the v2 thread/delete request and thread/deleted notification, with the response shape kept consistent with thread/archive.
  • Implements local hard delete for active and archived rollout files.
  • Deletes the requested thread's state DB row as the commit point, then best-effort cleans associated state including spawned descendants, goals, spawn edges, logs, dynamic tools, and agent job assignments.
  • Updates app-server API docs and generated protocol schema/TypeScript fixtures.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2df653fcc2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/request_processors/thread_processor.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d86f1d76f5

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b169881ec

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated
Comment thread codex-rs/tui/src/chatwidget/protocol.rs
Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated
@etraut-openai etraut-openai changed the title Add app-server thread/delete API Add app-server thread/delete API May 29, 2026

@jif-oai jif-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m worried this is modeling hard delete as a best-effort orchestration across several persistence systems, without a durable deleted/tombstone state
I think the API shape is fine, but the commit point needs to move to a durable store-level delete/tombstone contract before this can safely promise permanent full-tree deletion (which is the whole point and pretty important if we consider the data safety question)

Comment thread codex-rs/thread-store/src/local/delete_thread.rs Outdated
Comment thread codex-rs/state/src/runtime/threads.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/common.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d49dccc8ea

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60c0f05bf0

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated
@etraut-openai

etraut-openai commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

Thinking more about the feedback... We need to decide the intended use of thread/delete. Is it designed to clean up visible threads in the UI and free up disk space, or is it designed to guarantee permanent deletion of the data? It's a subtle but important distinction.

If we treat this as a guaranteed deletion of the data, then we need to fail the operation if we're unable to delete one or more of the rollout files, and that leaves users stuck with visible threads that they no longer want to see — and with no recourse to remove them other than to attempt to find and delete the files manually and then somehow repair or reconstruct their db. This is probably a reasonable tradeoff.

I've changed the implementation to fail if one or more rollout files cannot be deleted. Database updates are now best-effort.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ddb4d9f9c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/thread-store/src/store.rs
Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs
Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs
Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e19cfeb55

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs
Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated
Comment thread codex-rs/thread-store/src/local/delete_thread.rs Outdated
@etraut-openai etraut-openai requested a review from a team as a code owner May 31, 2026 18:46
@etraut-openai etraut-openai requested a review from jif-oai May 31, 2026 20:05

@jif-oai jif-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reinforce the sqlite reliability

let thread_id = ThreadId::from_string(&params.thread_id)
.map_err(|err| invalid_request(format!("invalid thread id: {err}")))?;

let mut thread_ids = self.state_db_spawn_subtree_thread_ids(thread_id).await?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit racy to snapshot at that time. I'm not sure what's possible to do though

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

Comment thread codex-rs/state/src/runtime/threads.rs Outdated
warn!("failed to delete logs for thread {thread_id}: {err}");
}

if let Err(err) = self.memories.delete_thread_memory(thread_id).await {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still make it best-effort. Should we have a retry policy (with some exponential back-off)?
Or even dumping what needs to be done somewhere (like in a file) and then having an async worker that retry later?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should add this level of complexity.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0d3423e6a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/thread-store/src/local/delete_thread.rs
Comment thread codex-rs/thread-store/src/local/delete_thread.rs
Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs Outdated
Comment thread codex-rs/thread-store/src/local/delete_thread.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc4bad38ef

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs
Comment thread codex-rs/thread-store/src/local/delete_thread.rs
Comment thread codex-rs/app-server/src/request_processors/thread_delete.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bb48c783f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/thread-store/src/local/delete_thread.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3a9560c18

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server-protocol/src/protocol/common.rs
@etraut-openai

etraut-openai commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

I'm not convinced that we need to so far as to guarantee deletion of metadata, but I understand your perspective. I've changed the design to return failure if any part of the deletion fails — either file system or db. Since the operation isn't transactional, we have no practical way to roll back if we get half way through a deletion. That means we'll end up with partially-deleted threads. The new approach is designed to do these deletions in an order that can be retried. For example, we don't delete the subagent hierarchy metadata until the end because doing it earlier would cause the subagent associations to be lost.

You suggested that we should maybe implement a retry policy with backoff and persisted work queues, etc. I think that's overkill in terms of complexity.

@etraut-openai etraut-openai requested a review from jif-oai June 2, 2026 07:53
@etraut-openai etraut-openai force-pushed the etraut/thread-delete-api branch 4 times, most recently from de99a95 to e04ba87 Compare June 9, 2026 20:29
self.validate_root_thread_delete(thread_id, thread_ids.len() > 1)
.await?;
for thread_id_to_delete in thread_ids.iter().copied() {
self.prepare_thread_for_delete(thread_id_to_delete).await;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will need to think a bit about sub-agents and their state in cleanups but we can do this later

return Err(ThreadStoreError::ThreadNotFound { thread_id });
}

store.live_recorders.lock().await.remove(&thread_id);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thread/name/set also persists the id and name in session_index.jsonl, but this path returns success without removing those records. I think we should just happen something in the file to unassign the name (and btw I would like to nuke this file in the future)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed. I added code to delete the name from this file.

Add a v2 thread/delete method that hard-deletes a requested thread, discovers spawned descendants before the root delete, emits thread/deleted notifications for committed deletes, and cleans up associated state best effort after the root state row is deleted.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b30942237

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/thread-store/src/local/delete_thread.rs
Comment thread codex-rs/rollout/src/session_index.rs Outdated
Comment thread codex-rs/state/src/runtime/threads.rs
@etraut-openai etraut-openai force-pushed the etraut/thread-delete-api branch from 1b30942 to 126b310 Compare June 10, 2026 17:25
@etraut-openai etraut-openai merged commit a19d43a into main Jun 10, 2026
31 checks passed
@etraut-openai etraut-openai deleted the etraut/thread-delete-api branch June 10, 2026 18:22
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants