mirror of
https://github.com/openai/codex.git
synced 2026-05-24 04:54:52 +00:00
## Why Memory prompt injection should be owned by the extension path that app-server composes at runtime, not by an inlined special case inside `codex-core`. This keeps `codex-core` focused on session orchestration while allowing the memories extension to own its app-server prompt behavior. ## What Changed - Registers `codex-memories-extension` in the app-server extension registry. - Moves the memory developer-instruction injection out of `core/src/session/mod.rs` and into the memories extension prompt contributor. - Adds config-change handling so the extension keeps its per-thread memory settings in sync after startup. - Leaves memories read/retrieval tools unregistered for now so this PR only changes prompt injection. - Removes the stale `cargo-shear` ignore now that app-server depends on the extension crate. ## Validation Not run locally; validation is left to CI.
42 lines
1.5 KiB
Rust
42 lines
1.5 KiB
Rust
use std::sync::Arc;
|
|
use std::sync::Weak;
|
|
|
|
use codex_core::NewThread;
|
|
use codex_core::StartThreadOptions;
|
|
use codex_core::ThreadManager;
|
|
use codex_core::config::Config;
|
|
use codex_extension_api::AgentSpawnFuture;
|
|
use codex_extension_api::AgentSpawner;
|
|
use codex_extension_api::ExtensionRegistry;
|
|
use codex_extension_api::ExtensionRegistryBuilder;
|
|
use codex_protocol::ThreadId;
|
|
use codex_protocol::error::CodexErr;
|
|
|
|
pub(crate) fn thread_extensions<S>(guardian_agent_spawner: S) -> Arc<ExtensionRegistry<Config>>
|
|
where
|
|
S: AgentSpawner<StartThreadOptions, Spawned = NewThread, Error = CodexErr> + 'static,
|
|
{
|
|
let mut builder = ExtensionRegistryBuilder::<Config>::new();
|
|
codex_guardian::install(&mut builder, guardian_agent_spawner);
|
|
codex_memories_extension::install(&mut builder);
|
|
Arc::new(builder.build())
|
|
}
|
|
|
|
pub(crate) fn guardian_agent_spawner(
|
|
thread_manager: Weak<ThreadManager>,
|
|
) -> impl AgentSpawner<StartThreadOptions, Spawned = NewThread, Error = CodexErr> {
|
|
move |forked_from_thread_id: ThreadId,
|
|
options: StartThreadOptions|
|
|
-> AgentSpawnFuture<'static, NewThread, CodexErr> {
|
|
let thread_manager = thread_manager.clone();
|
|
Box::pin(async move {
|
|
let thread_manager = thread_manager.upgrade().ok_or_else(|| {
|
|
CodexErr::UnsupportedOperation("thread manager dropped".to_string())
|
|
})?;
|
|
thread_manager
|
|
.spawn_subagent(forked_from_thread_id, options)
|
|
.await
|
|
})
|
|
}
|
|
}
|