fix(agent-management): pass env vars to agent in spawn_streaming

The spawn_streaming() function was not passing environment variables
from SpawnOptions.env to the spawned process. This caused agents like
Claude to not receive ANTHROPIC_API_KEY, resulting in silent
authentication failures.

The non-streaming spawn() method correctly passes env vars (lines 298-300),
but spawn_streaming() was missing this code path.

This fix adds the same env var loop to spawn_streaming(), ensuring that
credentials extracted from the host environment are properly passed to
spawned agents.
This commit is contained in:
Greg Ceccarelli 2026-01-29 17:05:24 -05:00
parent ab210fa38a
commit c4b033a5c0

View file

@ -327,6 +327,12 @@ impl AgentManager {
options.streaming_input = true;
}
let mut command = self.build_command(agent, &options)?;
// Pass environment variables to the agent process (e.g., ANTHROPIC_API_KEY)
for (key, value) in &options.env {
command.env(key, value);
}
if matches!(agent, AgentId::Codex | AgentId::Claude) {
command.stdin(Stdio::piped());
}