Skip to content

Commit b2bca36

Browse files
committed
Explain: Fix environment (again) and tidy.
Building the env dictionary is more Pythonic and also fixes a bug (in which `env=None` was mistakenly passed through due to how `update()` works - bah). I should have done this change as suggested, first time around!
1 parent e33f0d9 commit b2bca36

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

explain/copilot_cli_agent.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,11 @@ async def ask(self, question: str, port: int, tools: list[str]) -> str:
105105
prompt = question
106106

107107
allowed_tools = ["UDB_Server", "shell(grep)", "shell(find)", "shell(cat)", "shell(xargs)"]
108-
env_changes = {
108+
env = {
109+
**os.environ,
109110
"XDG_CONFIG_HOME": str(self._tempdir),
110111
"XDG_STATE_HOME": str(self._tempdir),
111112
}
112-
if runtime_dir := os.environ.get("XDG_RUNTIME_DIR"):
113-
# Pass through runtime state so it has auth access.
114-
env_changes["XDG_RUNTIME_DIR"] = runtime_dir
115113

116114
try:
117115
copilot = await asyncio.create_subprocess_exec(
@@ -127,7 +125,7 @@ async def ask(self, question: str, port: int, tools: list[str]) -> str:
127125
"claude-sonnet-4.5",
128126
"-p",
129127
prompt,
130-
env=os.environ.copy().update(env_changes),
128+
env=env,
131129
stdin=asyncio.subprocess.PIPE,
132130
stdout=asyncio.subprocess.PIPE,
133131
stderr=asyncio.subprocess.PIPE,

0 commit comments

Comments
 (0)