mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Wire metrics client into memories extension (#24567)
## Summary - let the memories extension capture the process-global OTEL metrics client at install time - keep app-server/TUI/exec extension construction APIs unchanged - store the metrics client for future memory metrics without emitting any metrics yet ## Test plan - `just fmt` - `just bazel-lock-update` - `just bazel-lock-check` - Not run: tests/clippy per request; CI will cover them
This commit is contained in:
1 parent
3936ed221d
commit
c37884d5eb
4 files changed
+24
-9
No files matched your search
@@ -18,7 +18,7 @@ where
|
|||||||
{
|
{
|
||||||
let mut builder = ExtensionRegistryBuilder::<Config>::new();
|
let mut builder = ExtensionRegistryBuilder::<Config>::new();
|
||||||
codex_guardian::install(&mut builder, guardian_agent_spawner);
|
codex_guardian::install(&mut builder, guardian_agent_spawner);
|
||||||
codex_memories_extension::install(&mut builder);
|
codex_memories_extension::install(&mut builder, codex_otel::global());
|
||||||
Arc::new(builder.build())
|
Arc::new(builder.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ async-trait = { workspace = true }
|
|||||||
codex-core = { workspace = true }
|
codex-core = { workspace = true }
|
||||||
codex-extension-api = { workspace = true }
|
codex-extension-api = { workspace = true }
|
||||||
codex-features = { workspace = true }
|
codex-features = { workspace = true }
|
||||||
|
codex-otel = { workspace = true }
|
||||||
codex-tools = { workspace = true }
|
codex-tools = { workspace = true }
|
||||||
codex-utils-absolute-path = { workspace = true }
|
codex-utils-absolute-path = { workspace = true }
|
||||||
codex-utils-output-truncation = { workspace = true }
|
codex-utils-output-truncation = { workspace = true }
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use codex_extension_api::ThreadLifecycleContributor;
|
|||||||
use codex_extension_api::ThreadStartInput;
|
use codex_extension_api::ThreadStartInput;
|
||||||
use codex_extension_api::ToolContributor;
|
use codex_extension_api::ToolContributor;
|
||||||
use codex_features::Feature;
|
use codex_features::Feature;
|
||||||
|
use codex_otel::MetricsClient;
|
||||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||||
|
|
||||||
use crate::local::LocalMemoriesBackend;
|
use crate::local::LocalMemoriesBackend;
|
||||||
@@ -17,8 +18,18 @@ use crate::prompts::build_memory_tool_developer_instructions;
|
|||||||
use crate::tools;
|
use crate::tools;
|
||||||
|
|
||||||
/// Contributes Codex memory read-path prompt context and memory read tools.
|
/// Contributes Codex memory read-path prompt context and memory read tools.
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub(crate) struct MemoriesExtension;
|
pub(crate) struct MemoriesExtension {
|
||||||
|
_metrics_client: Option<MetricsClient>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MemoriesExtension {
|
||||||
|
fn new(metrics_client: Option<MetricsClient>) -> Self {
|
||||||
|
Self {
|
||||||
|
_metrics_client: metrics_client,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct MemoriesExtensionConfig {
|
pub(crate) struct MemoriesExtensionConfig {
|
||||||
@@ -97,8 +108,11 @@ impl ToolContributor for MemoriesExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Installs the memories extension contributors into the extension registry.
|
/// Installs the memories extension contributors into the extension registry.
|
||||||
pub fn install(registry: &mut ExtensionRegistryBuilder<Config>) {
|
pub fn install(
|
||||||
let extension = Arc::new(MemoriesExtension);
|
registry: &mut ExtensionRegistryBuilder<Config>,
|
||||||
|
metrics_client: Option<MetricsClient>,
|
||||||
|
) {
|
||||||
|
let extension = Arc::new(MemoriesExtension::new(metrics_client));
|
||||||
registry.thread_lifecycle_contributor(extension.clone());
|
registry.thread_lifecycle_contributor(extension.clone());
|
||||||
registry.config_contributor(extension.clone());
|
registry.config_contributor(extension.clone());
|
||||||
registry.prompt_contributor(extension);
|
registry.prompt_contributor(extension);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use crate::local::LocalMemoriesBackend;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tools_are_not_contributed_without_thread_config() {
|
fn tools_are_not_contributed_without_thread_config() {
|
||||||
let extension = MemoriesExtension;
|
let extension = MemoriesExtension::default();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
extension
|
extension
|
||||||
@@ -37,7 +37,7 @@ fn tools_are_not_contributed_without_thread_config() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tools_are_not_contributed_when_disabled() {
|
fn tools_are_not_contributed_when_disabled() {
|
||||||
let extension = MemoriesExtension;
|
let extension = MemoriesExtension::default();
|
||||||
let thread_store = ExtensionData::new("thread");
|
let thread_store = ExtensionData::new("thread");
|
||||||
thread_store.insert(MemoriesExtensionConfig {
|
thread_store.insert(MemoriesExtensionConfig {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@@ -53,7 +53,7 @@ fn tools_are_not_contributed_when_disabled() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tools_are_contributed_when_enabled() {
|
fn tools_are_contributed_when_enabled() {
|
||||||
let extension = MemoriesExtension;
|
let extension = MemoriesExtension::default();
|
||||||
let thread_store = ExtensionData::new("thread");
|
let thread_store = ExtensionData::new("thread");
|
||||||
thread_store.insert(MemoriesExtensionConfig {
|
thread_store.insert(MemoriesExtensionConfig {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@@ -111,7 +111,7 @@ async fn prompt_contribution_uses_memory_summary_when_enabled() {
|
|||||||
.await
|
.await
|
||||||
.expect("write memory summary");
|
.expect("write memory summary");
|
||||||
|
|
||||||
let extension = MemoriesExtension;
|
let extension = MemoriesExtension::default();
|
||||||
let thread_store = ExtensionData::new("thread");
|
let thread_store = ExtensionData::new("thread");
|
||||||
thread_store.insert(MemoriesExtensionConfig {
|
thread_store.insert(MemoriesExtensionConfig {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|||||||
Reference in new issue
Block a user