From 47c875f6b5d404d319151866726ed48092e87957 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 26 Jun 2025 12:25:23 +0200 Subject: [PATCH] Pass GEMINI_API_KEY to agent process if available --- crates/agent2/src/agent2.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/agent2/src/agent2.rs b/crates/agent2/src/agent2.rs index f61f86fab7d1520cc887d37c6273a0860b947dc6..98fd802cb224d9192c3608c3f50ca3be7a4dafe8 100644 --- a/crates/agent2/src/agent2.rs +++ b/crates/agent2/src/agent2.rs @@ -309,7 +309,8 @@ mod tests { pub fn gemini_agent(project: Entity, mut cx: AsyncApp) -> Result> { let cli_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../gemini-cli/packages/cli"); - let child = util::command::new_smol_command("node") + let mut command = util::command::new_smol_command("node"); + command .arg(cli_path) .arg("--acp") .args(["--model", "gemini-2.5-flash"]) @@ -317,9 +318,13 @@ mod tests { .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::inherit()) - .kill_on_drop(true) - .spawn() - .unwrap(); + .kill_on_drop(true); + + if let Ok(gemini_key) = std::env::var("GEMINI_API_KEY") { + command.env("GEMINI_API_KEY", gemini_key); + } + + let child = command.spawn().unwrap(); Ok(AcpAgent::stdio(child, project, &mut cx)) }