Add an injectable attachment store to ThreadManager (#42634)

## What changed

- Add the `codex-attachment-store` crate with storage-neutral attachment metadata, references, errors, and an asynchronous persistence interface.
- Provide an inline implementation that preserves attachment bytes as media-typed base64 data URLs.
- Inject the store into `ThreadManager`, expose it to consumers, and retain inline storage as the default for existing entry points.

## Testing

- Verify inline storage round-trips binary, text, PNG, and JPEG data.
- Verify attachment debug output redacts URLs while retaining file IDs.

GitOrigin-RevId: 7688dcd3c89d7540ed2398f3e7c63881fbfcda97
This commit is contained in:
Krish Chainani authored and copyberry committed 2026-09-03 23:20:54 +00:00
1 parent d979df154c
commit 03467026f2
20 files changed
+249

No files matched your search

+15
View File
@@ -23,6 +23,8 @@ use codex_agent_graph_store::LocalAgentGraphStore;
use codex_analytics::AnalyticsEventsClient;
use codex_app_server_protocol::ThreadHistoryBuilder;
use codex_app_server_protocol::TurnStatus;
use codex_attachment_store::AttachmentStore;
use codex_attachment_store::InlineAttachmentStore;
use codex_code_mode::CodeModeSessionProvider;
use codex_code_mode::DisabledCodeModeSessionProvider;
use codex_code_mode::ProcessOwnedCodeModeSessionProvider;
@@ -355,6 +357,7 @@ pub(crate) struct ThreadManagerState {
code_mode_session_provider: Arc<dyn CodeModeSessionProvider>,
extensions: Arc<ExtensionRegistry<Config>>,
user_instructions_provider: Arc<dyn UserInstructionsProvider>,
image_store: Arc<dyn AttachmentStore>,
thread_store: Arc<dyn ThreadStore>,
agent_graph_store: Option<Arc<dyn AgentGraphStore>>,
attestation_provider: Option<Arc<dyn AttestationProvider>>,
@@ -414,6 +417,11 @@ pub fn thread_store_from_config(
}
}
/// Constructs the default image store that preserves inline images.
pub fn passthrough_image_store() -> Arc<dyn AttachmentStore> {
Arc::new(InlineAttachmentStore)
}
/// Construct the default SQLite-backed agent graph store when local state is available.
pub fn local_agent_graph_store_from_state_db(
state_db: Option<&StateDbHandle>,
@@ -435,6 +443,7 @@ impl ThreadManager {
extensions: Arc<ExtensionRegistry<Config>>,
user_instructions_provider: Arc<dyn UserInstructionsProvider>,
analytics_events_client: Option<AnalyticsEventsClient>,
image_store: Arc<dyn AttachmentStore>,
thread_store: Arc<dyn ThreadStore>,
agent_graph_store: Option<Arc<dyn AgentGraphStore>>,
installation_id: String,
@@ -483,6 +492,7 @@ impl ThreadManager {
code_mode_session_provider,
extensions,
user_instructions_provider,
image_store,
thread_store,
agent_graph_store,
attestation_provider,
@@ -633,6 +643,7 @@ impl ThreadManager {
user_instructions_provider: Arc::new(
crate::test_support::EmptyUserInstructionsProvider,
),
image_store: passthrough_image_store(),
thread_store,
agent_graph_store,
attestation_provider: None,
@@ -672,6 +683,10 @@ impl ThreadManager {
self.state.environment_manager.clone()
}
pub fn image_store(&self) -> Arc<dyn AttachmentStore> {
Arc::clone(&self.state.image_store)
}
/// Starts the local rollout migration path after a runtime feature enablement.
///
/// Startup config handles the initial launch in [`thread_store_from_config`]. This covers