personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add env var passing from cortex requests to agent subprocesses

Enables environment variable overrides to flow from cortex_request config
through to the spawned muse-agents subprocess. Env vars specified in
persona JSON configs or request-level config are merged into the
subprocess environment, with JOURNAL_PATH always forced last to prevent
override. Handoff agents inherit parent's env unless explicitly overridden.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+20 -1
+9
docs/CORTEX.md
··· 46 46 "facet": "my-project", // Optional: project context 47 47 "save": "analysis.md", // Optional: save result to file in day directory 48 48 "day": "20250109", // Optional: YYYYMMDD format, defaults to current day 49 + "env": { // Optional: environment variables for subprocess 50 + "API_KEY": "secret", 51 + "DEBUG": "true" 52 + }, 49 53 "handoff": { // Optional: chain to another agent on completion 50 54 "persona": "reviewer", 51 55 "prompt": "Review the analysis", ··· 255 259 - Useful for creating per-facet reports, newsletters, or analyses 256 260 - `always`: Override active facet detection for multi-facet agents (default: false) 257 261 - When true, agent runs for all non-muted facets regardless of activity 262 + - `env`: Environment variables to set for the agent subprocess (object) 263 + - Keys are variable names, values are coerced to strings 264 + - Request-level `env` overrides persona defaults 265 + - Inherited by handoff agents unless explicitly overridden 266 + - Note: `JOURNAL_PATH` cannot be overridden (always set by Cortex) 258 267 259 268 ## MCP Tools Integration 260 269
+11 -1
muse/cortex.py
··· 372 372 # Pass the full config through to the agent as NDJSON 373 373 ndjson_input = json.dumps(config) 374 374 375 - # Prepare environment 375 + # Prepare environment - apply config overrides first, then force JOURNAL_PATH 376 376 env = os.environ.copy() 377 + env_overrides = config.get("env") 378 + if env_overrides and isinstance(env_overrides, dict): 379 + env.update({k: str(v) for k, v in env_overrides.items()}) 377 380 env["JOURNAL_PATH"] = str(self.journal_path) 378 381 379 382 # Spawn the agent process ··· 721 724 # Ensure we do not propagate parent handoff metadata. 722 725 handoff_config.pop("handoff", None) 723 726 handoff_config.pop("handoff_from", None) 727 + 728 + # Inherit env from parent if not explicitly set in handoff config 729 + if "env" not in handoff_config: 730 + with self.lock: 731 + parent_env = self.agent_requests.get(parent_id, {}).get("env") 732 + if parent_env: 733 + handoff_config["env"] = parent_env 724 734 725 735 # Only pass through additional overrides if any remain. 726 736 extra_config = handoff_config or None