Add durable user-message queue dispatch (#37204)

## What changed

- Add a storage-neutral queue extension for listing, adding, editing, reordering, deleting, and explicitly starting queued user messages.
- Dispatch queued messages in FIFO order when a thread becomes idle after a completed turn, while leaving them queued after interruptions or failures.
- Wait for user input to be persisted before removing its queue item, and report hook rejection, task termination, and persistence failures distinctly.
- Snapshot local image and audio attachments into validated data URLs before storing them, enforce input limits, and emit `ThreadQueueChanged` events after mutations.

## Testing

- Cover queue mutations, automatic and explicit dispatch, interruption and failure behavior, hook rejection, invalid records, input limits, and local attachment snapshotting.

GitOrigin-RevId: 14f39d7c8cbaccb767a6da84b82cced0edfcb4b9
This commit is contained in:
efrazer-oai authored and copyberry committed 2026-08-06 03:11:42 +00:00
1 parent 70b4653232
commit bc8b25ea02
42 files changed
+2114 -140

No files matched your search

+13 -5
View File
@@ -26,7 +26,7 @@ use codex_protocol::error::CodexErr;
use codex_protocol::protocol::Event;
use codex_protocol::protocol::EventMsg;
use codex_rollout::state_db::StateDbHandle;
use codex_thread_store::ThreadStore;
use codex_thread_store::QueueStore;
use crate::outgoing_message::OutgoingMessageSender;
use crate::outgoing_message::ThreadScopedOutgoingMessageSender;
@@ -44,8 +44,8 @@ pub(crate) struct ThreadExtensionDependencies {
pub(crate) executor_skill_provider: Arc<dyn codex_skills_extension::SkillProvider>,
pub(crate) git_attribution_base_url: String,
pub(crate) http_client_factory: HttpClientFactory,
/// Process-scoped persistence backend for extensions that need stored thread history.
pub(crate) thread_store: Arc<dyn ThreadStore>,
/// Process-scoped persistence backend for queued user messages.
pub(crate) queue_store: Option<Arc<dyn QueueStore>>,
}
pub(crate) fn thread_extensions<S>(
@@ -66,9 +66,17 @@ where
executor_skill_provider,
git_attribution_base_url,
http_client_factory,
thread_store: _thread_store,
queue_store,
} = dependencies;
let mut builder = ExtensionRegistryBuilder::<Config>::with_event_sink(event_sink);
let mut builder = ExtensionRegistryBuilder::<Config>::with_event_sink(Arc::clone(&event_sink));
if let Some(queue) = queue_store {
let queue_service = Arc::new(codex_queue_extension::QueuedItemService::new(
queue,
thread_manager.clone(),
event_sink,
));
codex_queue_extension::install(&mut builder, queue_service);
}
if let Some(state_db) = state_db {
codex_goal_extension::install_with_backend(
&mut builder,