Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
test: add codex provider configuration reproducers
Gabriel Scharb6a375344ac33
diff --git a/crates/ai-memory-cli/src/commands/llm_test.rs b/crates/ai-memory-cli/src/commands/llm_test.rsindex 1b094dc4..9bac7dc0 100644--- a/crates/ai-memory-cli/src/commands/llm_test.rs+++ b/crates/ai-memory-cli/src/commands/llm_test.rs@@ -87,6 +87,14 @@ mod tests {);}+ #[test]+ fn codex_choice_maps_to_runtime_provider() {+ assert_eq!(+ ProviderChoice::from(LlmProviderChoice::Codex),+ ProviderChoice::Codex+ );+ }+#[test]fn llm_test_exercises_pipeline_sampling_compatibility() {let request = representative_request("diagnostic".into());diff --git a/crates/ai-memory-cli/src/config.rs b/crates/ai-memory-cli/src/config.rsindex 4b5a63c8..c9a28e7b 100644--- a/crates/ai-memory-cli/src/config.rs+++ b/crates/ai-memory-cli/src/config.rs@@ -2809,6 +2809,48 @@ mod tests {assert_eq!(provider.reasoning_effort, effort);}+ #[test]+ fn codex_provider_uses_codex_home_auth_and_default_model() {+ let tmp = TempDir::new().unwrap();+ let codex_home = tmp.path().join("custom-codex-home");+ let cfg = Config {+ llm_provider: Some("codex".into()),+ runtime_env: RuntimeEnv {+ codex_home: Some(codex_home.clone()),+ codex_executable: Some(PathBuf::from("codex-custom")),+ ..RuntimeEnv::default()+ },+ ..Config::default()+ };++ let provider = cfg.llm_provider_config().unwrap().unwrap();+ let auth = provider.auth.require_codex_auth().unwrap();++ assert_eq!(provider.provider, ProviderChoice::Codex);+ assert_eq!(provider.model, "gpt-5.6-luna");+ assert_eq!(auth.auth_file, codex_home.join("auth.json"));+ assert_eq!(auth.executable, Path::new("codex-custom"));+ }++ #[test]+ fn codex_provider_falls_back_to_platform_home() {+ let tmp = TempDir::new().unwrap();+ let cfg = Config {+ llm_provider: Some("codex".into()),+ runtime_env: RuntimeEnv {+ home_dir: Some(tmp.path().display().to_string()),+ ..RuntimeEnv::default()+ },+ ..Config::default()+ };++ let provider = cfg.llm_provider_config().unwrap().unwrap();+ let auth = provider.auth.require_codex_auth().unwrap();++ assert_eq!(auth.auth_file, tmp.path().join(".codex").join("auth.json"));+ assert_eq!(auth.executable, Path::new("codex"));+ }+#[test]fn provider_config_forwards_the_operator_headers() {let tmp = TempDir::new().unwrap();diff --git a/crates/ai-memory-llm/src/auth.rs b/crates/ai-memory-llm/src/auth.rsindex f6434114..4f0b4032 100644--- a/crates/ai-memory-llm/src/auth.rs+++ b/crates/ai-memory-llm/src/auth.rs@@ -420,4 +420,19 @@ mod tests {let auth = ProviderAuth::anthropic_oauth_token(Some(SecretString::from("tok")));assert!(auth.optional_api_key().is_none());}++ #[test]+ fn codex_auth_round_trips_only_resolved_paths() {+ let auth = ProviderAuth::codex(+ "/tmp/.codex/auth.json",+ "/opt/codex/bin/codex",+ );+ let codex = auth.require_codex_auth().unwrap();++ assert_eq!(auth.requirement(), AuthRequirement::CodexAuthFile);+ assert_eq!(auth.source(), CredentialSource::TokenFile);+ assert_eq!(codex.auth_file, Path::new("/tmp/.codex/auth.json"));+ assert_eq!(codex.executable, Path::new("/opt/codex/bin/codex"));+ assert!(!format!("{codex:?}").contains("token"));+ }}diff --git a/crates/ai-memory-llm/src/factory.rs b/crates/ai-memory-llm/src/factory.rsindex 08d94c74..c1249ba3 100644--- a/crates/ai-memory-llm/src/factory.rs+++ b/crates/ai-memory-llm/src/factory.rs@@ -462,6 +462,11 @@ mod tests {ProviderChoice::OpenAiOAuth.auth_requirement(),AuthRequirement::OpenAiOAuthToken);+ assert_eq!(ProviderChoice::Codex.name(), "codex");+ assert_eq!(+ ProviderChoice::Codex.auth_requirement(),+ AuthRequirement::CodexAuthFile+ );assert_eq!(ProviderChoice::Copilot.auth_requirement(),AuthRequirement::CopilotToken