Repository navigation
fix: 启动 AutoCAD 前补齐 Windows 登录环境变量,消除许可代理崩溃弹窗 - #10
Merged
luomufanye-cloud merged 2 commits intoNov 26, 2026
Merged
Conversation
Agent shells that inherit only a core environment (Codex with shell_environment_policy inherit="core") drop ALLUSERSPROFILE and other logon variables. DCOM hands the caller's environment to the AutoCAD it launches, and Autodesk's licensing agent throws std::runtime_error at startup without ALLUSERSPROFILE. Every retry then raised an "Autodesk Error Report" dialog. Before DispatchEx, fill in missing variables from an allowlist using the user's default logon environment. Existing values are never overwritten, and nothing outside the allowlist is copied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
问题
由 agent 通过 luomu-cad 启动 AutoCAD 时,会弹出 "Autodesk Error Report",或者干脆启动失败。具体表现跟发起启动的 agent 宿主有关。
根因
DispatchEx由 DCOM 启动 AutoCAD 时,会把 MCP 服务端进程的环境传给 AutoCAD;这个环境又来自启动 MCP 服务端的 agent 宿主。shell_environment_policy inherit = "core"会删掉ALLUSERSPROFILE等变量。ALLUSERSPROFILE。ALLUSERSPROFILE时,Autodesk 许可代理AdskLicensingAgent.exe一启动就抛出std::runtime_error,每次重试都弹一个错误报告。在 MCP SDK 默认环境下,未修复的代码甚至连 AutoCAD 都启动不了(COM 返回 0x80080005 "服务器运行失败")。修改
cad.py新增_complete_windows_environment()。它在DispatchEx之前运行,按白名单从当前用户的默认登录环境(CreateEnvironmentBlock)补回缺失的 Windows 登录变量。cad_start启动,所以不管哪个 agent 宿主调用,都会经过这里。DispatchEx时ALLUSERSPROFILE已经存在。最后这个测试在去掉修复后会失败。验证
本机 AutoCAD 2024,经真实 stdio MCP 服务端调用
cad_start,每种环境各启动一个新实例,等待 45 秒后检查:inherit=corepytest:1013 passed,18 skipped。本 PR 叠加在 #9(1.0.0 候选)之上;main 上的同一修复是单独的 PR。如果 #9 先合并,需要先把本 PR 的目标分支改成 main,再删除 #9 的分支。
🤖 Generated with Claude Code