feat: consolidate subagent execution for dynamic tasks (#3444)

Co-authored-by: Lifei Zhou <lifei@squareup.com>
This commit is contained in:
Wendy Tang
2025-07-17 18:48:00 -07:00
committed by GitHub
parent 9f65455cc3
commit 4771ffbb5b
36 changed files with 751 additions and 1062 deletions
@@ -3,6 +3,10 @@ use std::time::Instant;
#[tokio::test]
async fn test_pricing_cache_performance() {
// Use a unique cache directory for this test to avoid conflicts
let test_cache_dir = format!("/tmp/goose_test_cache_perf_{}", std::process::id());
std::env::set_var("GOOSE_CACHE_DIR", &test_cache_dir);
// Initialize the cache
let start = Instant::now();
initialize_pricing_cache()
@@ -65,10 +69,18 @@ async fn test_pricing_cache_performance() {
first_fetch_duration,
second_fetch_duration
);
// Clean up
std::env::remove_var("GOOSE_CACHE_DIR");
let _ = std::fs::remove_dir_all(&test_cache_dir);
}
#[tokio::test]
async fn test_pricing_refresh() {
// Use a unique cache directory for this test to avoid conflicts
let test_cache_dir = format!("/tmp/goose_test_cache_refresh_{}", std::process::id());
std::env::set_var("GOOSE_CACHE_DIR", &test_cache_dir);
// Initialize first
initialize_pricing_cache()
.await
@@ -90,10 +102,18 @@ async fn test_pricing_refresh() {
refreshed_pricing.is_some(),
"Expected pricing after refresh"
);
// Clean up
std::env::remove_var("GOOSE_CACHE_DIR");
let _ = std::fs::remove_dir_all(&test_cache_dir);
}
#[tokio::test]
async fn test_model_not_in_openrouter() {
// Use a unique cache directory for this test to avoid conflicts
let test_cache_dir = format!("/tmp/goose_test_cache_model_{}", std::process::id());
std::env::set_var("GOOSE_CACHE_DIR", &test_cache_dir);
initialize_pricing_cache()
.await
.expect("Failed to initialize pricing cache");
@@ -104,12 +124,20 @@ async fn test_model_not_in_openrouter() {
pricing.is_none(),
"Should return None for non-existent model"
);
// Clean up
std::env::remove_var("GOOSE_CACHE_DIR");
let _ = std::fs::remove_dir_all(&test_cache_dir);
}
#[tokio::test]
async fn test_concurrent_access() {
use tokio::task;
// Use a unique cache directory for this test to avoid conflicts
let test_cache_dir = format!("/tmp/goose_test_cache_concurrent_{}", std::process::id());
std::env::set_var("GOOSE_CACHE_DIR", &test_cache_dir);
initialize_pricing_cache()
.await
.expect("Failed to initialize pricing cache");
@@ -133,4 +161,8 @@ async fn test_concurrent_access() {
assert!(has_pricing, "Task {} should have gotten pricing", task_id);
println!("Task {} took: {:?}", task_id, duration);
}
// Clean up
std::env::remove_var("GOOSE_CACHE_DIR");
let _ = std::fs::remove_dir_all(&test_cache_dir);
}