feat: inject LETTA_AGENT_ID into hook environment context (#731)
Co-authored-by: letta-code <248085862+letta-code@users.noreply.github.com> Co-authored-by: Cameron <cpfiffer@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
79d02ffbdc
commit
4c702057e0
@@ -29,13 +29,21 @@ function trySpawnWithLauncher(
|
||||
throw new Error("Empty launcher");
|
||||
}
|
||||
|
||||
// Extract agent_id if present (available on many hook input types)
|
||||
const agentId = "agent_id" in input ? input.agent_id : undefined;
|
||||
|
||||
// Build environment: start with parent env but exclude LETTA_AGENT_ID to prevent inheritance
|
||||
// We only want to pass the agent ID that's explicitly provided in the hook input
|
||||
const { LETTA_AGENT_ID: _, ...parentEnv } = process.env;
|
||||
|
||||
return spawn(executable, args, {
|
||||
cwd: workingDirectory,
|
||||
env: {
|
||||
...process.env,
|
||||
...parentEnv,
|
||||
// Add hook-specific environment variables
|
||||
LETTA_HOOK_EVENT: input.event_type,
|
||||
LETTA_WORKING_DIR: workingDirectory,
|
||||
...(agentId && { LETTA_AGENT_ID: agentId }),
|
||||
},
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user