fix: Windows 本地 agent 的 execute 工具现在能继承宿主环境,正常调用 python/curl/edge-tts 等外部命令 - #246
Open
chujieHong wants to merge 5 commits into
Open
fix: Windows 本地 agent 的 execute 工具现在能继承宿主环境,正常调用 python/curl/edge-tts 等外部命令#246chujieHong wants to merge 5 commits into
chujieHong wants to merge 5 commits into
Conversation
deepagents LocalShellBackend defaults inherit_env=False, so every agent execute() subprocess starts with an empty environment (no PATH/SystemRoot) and external tools (python/curl/ffmpeg/edge-tts) are unfindable. POSIX sh fills in a default PATH, so the breakage is effectively Windows-specific. Inject inherit_env=True into the Windows default agent backend spec (default_agent_backend_spec) and, via setdefault, into windows_neutralize_host_root for configured local_shell specs. An explicit inherit_env=false (empty-env sandbox) is preserved. Filesystem backends are skipped: no execute tool, and its constructor rejects the kwarg. Adds unit tests covering local_shell injection, filesystem skip, and explicit-override preservation. Verified end-to-end: a fresh agent thread now runs venv edge-tts via execute and delivers a valid MP3.
…cute Two Windows-only defects in the harness stack made agent shell commands unusable on Chinese Windows: 1. deepagents LocalShellBackend.execute runs subprocesses with text=True (strict UTF-8). Under PYTHONUTF8=1 the pipe reader crashes with UnicodeDecodeError when native tools (dir, git, ffmpeg, curl) emit GBK/CP936, dropping the entire output and returning a spurious exit code - the confusion that sent agents into endless self-diagnosis loops. Fixed with a bytes-mode reader + errors=replace decode. 2. harness_agent's virtual-path rewrite treats the / after a drive letter as a virtual path start, so C:/Users/... became C:'<root>'\Users\... and every absolute Windows path failed with file not found. Tightened the bare-token lookbehind to also exclude : and backslash. Patches applied idempotently at import (Windows only) via octop.infra.backend.windows_execute.
chujieHong
force-pushed
the
fix/windows-local-shell-inherit-env
branch
from
August 12, 2026 10:18
267be61 to
3559881
Compare
The CI-failing test asserted inherit_env unconditionally, but the resolver injects it only on Windows (on POSIX sh supplies a default PATH from the empty env, so nothing is added). Make the assertion platform-aware so the test passes on both linux and windows CI jobs.
…HANGELOG conflict)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
deepagents LocalShellBackend defaults inherit_env=False, so every agent execute() subprocess starts with an empty environment (no PATH/SystemRoot) and external tools (python/curl/ffmpeg/edge-tts) are unfindable. POSIX sh fills in a default PATH, so the breakage is effectively Windows-specific.
Inject inherit_env=True into the Windows default agent backend spec (default_agent_backend_spec) and, via setdefault, into windows_neutralize_host_root for configured local_shell specs. An explicit inherit_env=false (empty-env sandbox) is preserved. Filesystem backends are skipped: no execute tool, and its constructor rejects the kwarg.
Adds unit tests covering local_shell injection, filesystem skip, and explicit-override preservation. Verified end-to-end: a fresh agent thread now runs venv edge-tts via execute and delivers a valid MP3.
Summary
deepagents LocalShellBackend 默认 inherit_env=False,agent 每次 execute() 的子进程都从空环境启动(无 PATH/SystemRoot),外部工具 python/curl/ffmpeg/edge-tts 全部不可查找。POSIX 的 sh 会补一个默认 PATH,所以这个问题实际上只影响 Windows。
在 Windows 默认 agent backend spec(default_agent_backend_spec)中注入 inherit_env=True,并通过 setdefault 注入到 windows_neutralize_host_root 中已配置的 local_shell spec。显式的 inherit_env=false(空环境沙箱)会被保留。filesystem backend 跳过注入:它没有 execute 工具,且其构造器不接受该 kwarg。

新增单测覆盖:local_shell 注入、filesystem 跳过、显式覆盖保留。端到端验证:新建 agent 会话线程现在能经 execute 调用 venv 内的 edge-tts 并交付有效 MP3。
修复 Windows 上本地 agent execute 工具因子进程继承空环境(inherit_env=False)而无法运行任何外部命令的问题:在默认 backend spec 与 Windows 归一化中注入 inherit_env=True,使 python/curl/ffmpeg/edge-tts 等工具开箱即用;同时保留显式 inherit_env: false 的沙箱出口,并跳过无 execute 的 filesystem backend。
Target branch
develop(feature / fix — default)main(release/*orhotfix/*only)Type of change
Test plan
PYTHONUTF8=1 /Scripts/python.exe -m pytest tests/unit/backend/test_resolver.py tests/unit/agents/test_agent_manager.py → 70 passed, 2 skipped
ruff check + mypy → 均 clean
端到端(WebSocket 真实会话):新 agent 线程经 execute 调用 venv 内 edge-tts,产出有效 MP3 并 send_file_to_user 交付
make allpasses locallyChecklist
CHANGELOG.md(if user-facing)