changes per review. Remove option to configure moim. Filter moim from testprovider messages. remove useless comment

This commit is contained in:
Tyler Longwell
2025-10-06 14:58:16 -04:00
parent 250b3c8c8a
commit beb11cd233
6 changed files with 12 additions and 102 deletions
@@ -8,13 +8,10 @@ mod tests {
use crate::scenario_tests::scenario_runner::run_scenario;
use anyhow::Result;
use goose::conversation::message::Message;
use serial_test::serial;
#[tokio::test]
#[serial]
async fn test_what_is_your_name() -> Result<()> {
std::env::set_var("GOOSE_MOIM_ENABLED", "false");
let result = run_scenario(
run_scenario(
"what_is_your_name",
text("what is your name"),
None,
@@ -28,17 +25,13 @@ mod tests {
Ok(())
},
)
.await;
std::env::remove_var("GOOSE_MOIM_ENABLED");
result
.await
}
#[tokio::test]
#[serial]
async fn test_weather_tool() -> Result<()> {
std::env::set_var("GOOSE_MOIM_ENABLED", "false");
// Google tells me it only knows about the weather in the US, so we skip it.
let result = run_scenario(
run_scenario(
"weather_tool",
text("tell me what the weather is in Berlin, Germany"),
Some(&["Google"]),
@@ -62,18 +55,14 @@ mod tests {
Ok(())
},
)
.await;
std::env::remove_var("GOOSE_MOIM_ENABLED");
result
.await
}
#[tokio::test]
#[serial]
async fn test_image_analysis() -> Result<()> {
std::env::set_var("GOOSE_MOIM_ENABLED", "false");
// Google says it doesn't know about images, the other providers complain about
// the image format, so we only run this for OpenAI and Anthropic.
let result = run_scenario(
run_scenario(
"image_analysis",
image("What do you see in this image?", "test_image"),
Some(&["Google", "azure_openai", "groq"]),
@@ -84,16 +73,12 @@ mod tests {
Ok(())
},
)
.await;
std::env::remove_var("GOOSE_MOIM_ENABLED");
result
.await
}
#[tokio::test]
#[serial]
async fn test_context_length_exceeded_error() -> Result<()> {
std::env::set_var("GOOSE_MOIM_ENABLED", "false");
let result = run_scenario(
run_scenario(
"context_length_exceeded",
Box::new(|provider| {
let model_config = provider.get_model_config();
@@ -115,8 +100,6 @@ mod tests {
Ok(())
},
)
.await;
std::env::remove_var("GOOSE_MOIM_ENABLED");
result
.await
}
}
-1
View File
@@ -495,7 +495,6 @@ fn render_dynamic_task_request(call: &CallToolRequestParam, debug: bool) {
fn render_todo_request(call: &CallToolRequestParam, _debug: bool) {
print_tool_header(call);
// For todo_write, always show the full content without redaction
if let Some(args) = &call.arguments {
if let Some(Value::String(content)) = args.get("content") {
println!("{}: {}", style("content").dim(), style(content).green());
-29
View File
@@ -1,6 +1,5 @@
use crate::agents::extension_manager::ExtensionManager;
use crate::agents::SessionConfig;
use crate::config::Config;
use crate::conversation::message::{Message, MessageContent};
use uuid::Uuid;
@@ -13,15 +12,6 @@ pub async fn inject_moim(
extension_manager: &ExtensionManager,
_session: &Option<SessionConfig>,
) -> Vec<Message> {
let config = Config::global();
let moim_enabled = config
.get_param::<bool>("goose_moim_enabled")
.unwrap_or(true);
if !moim_enabled {
tracing::debug!("MOIM disabled by configuration");
return messages.to_vec();
}
let moim_content = match extension_manager.collect_moim().await {
Some(content) if !content.trim().is_empty() => content,
@@ -84,11 +74,9 @@ fn find_moim_insertion_point(messages: &[Message]) -> usize {
#[cfg(test)]
mod tests {
use super::*;
use serial_test::serial;
#[tokio::test]
async fn test_moim_insertion_empty_conversation() {
// MOIM is enabled by default
let messages = vec![];
let extension_manager = ExtensionManager::new();
@@ -123,23 +111,6 @@ mod tests {
assert!(content.contains("Current date and time:"));
}
#[tokio::test]
#[serial]
async fn test_moim_disabled() {
std::env::set_var("GOOSE_MOIM_ENABLED", "false");
let messages = vec![Message::user().with_text("Hello")];
let extension_manager = ExtensionManager::new();
let result = inject_moim(&messages, &extension_manager, &None).await;
// Should return original messages unchanged
assert_eq!(result.len(), 1);
assert!(result[0].id.is_none() || !result[0].id.as_ref().unwrap().starts_with("moim_"));
std::env::remove_var("GOOSE_MOIM_ENABLED");
}
#[test]
fn test_find_insertion_point_empty() {
let messages = vec![];
@@ -68,6 +68,10 @@ impl TestProvider {
fn hash_input(messages: &[Message]) -> String {
let stable_messages: Vec<_> = messages
.iter()
// Filter out MOIM messages (ephemeral context that shouldn't affect test determinism)
.filter(|msg| {
!msg.id.as_ref().is_some_and(|id| id.starts_with("moim_"))
})
.map(|msg| (msg.role.clone(), msg.content.clone()))
.collect();
let serialized = serde_json::to_string(&stable_messages).unwrap_or_default();
@@ -11,7 +11,6 @@ use tokio_util::sync::CancellationToken;
use goose::agents::extension::{Envs, ExtensionConfig};
use goose::agents::extension_manager::ExtensionManager;
use serial_test::serial;
use test_case::test_case;
use once_cell::sync::Lazy;
@@ -133,14 +132,11 @@ enum TestMode {
vec![]
)]
#[tokio::test]
#[serial]
async fn test_replayed_session(
command: Vec<&str>,
tool_calls: Vec<CallToolRequestParam>,
required_envs: Vec<&str>,
) {
// Disable MOIM for replayed sessions to ensure consistency with recorded data
std::env::set_var("GOOSE_MOIM_ENABLED", "false");
let replay_file_name = command
.iter()
.map(|s| s.replace("/", "_"))
@@ -250,5 +246,4 @@ async fn test_replayed_session(
}
panic!("Test failed: {:?}", err);
}
std::env::remove_var("GOOSE_MOIM_ENABLED");
}
-42
View File
@@ -1,42 +0,0 @@
use goose::agents::extension::ExtensionConfig;
use goose::agents::Agent;
use serial_test::serial;
#[tokio::test]
#[serial]
async fn test_moim_content_includes_timestamp() {
let agent = Agent::new();
// Collect MOIM content
let moim_content = agent.extension_manager.collect_moim().await;
assert!(moim_content.is_some());
let content = moim_content.unwrap();
// Should always include timestamp
assert!(content.contains("Current date and time:"));
}
#[tokio::test]
#[serial]
async fn test_moim_with_todo_content() {
let agent = Agent::new();
// Add TODO extension with content
let todo_config = ExtensionConfig::Platform {
name: "todo".to_string(),
description: "Task management".to_string(),
bundled: None,
available_tools: vec![],
};
agent.add_extension(todo_config).await.unwrap();
// The TODO extension should now be available
let moim_content = agent.extension_manager.collect_moim().await;
assert!(moim_content.is_some());
let content = moim_content.unwrap();
// Should include timestamp
assert!(content.contains("Current date and time:"));
}