fix(core): 修复 partial 工具的延迟类型注解解析 - #8302
Open
Shuhan Si (2gg-bit) wants to merge 1 commit into
Open
Shuhan Si (2gg-bit) wants to merge 1 commit into
Shuhan Si (2gg-bit) wants to merge 1 commit into
Conversation
Contributor
|
Shuhan Si (@2gg-bit) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This branch has not been deployed
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.
Why are these changes needed?
修复
FunctionTool(functools.partial(...))在函数使用延迟求值类型注解时抛出NameError的问题。get_typed_signature已解包 partial,却仍从 partial 对象读取__globals__;该对象没有这个属性,Annotated和用户定义的模型类型因此无法解析。现在从被包装函数读取全局命名空间,同时继续使用 partial 的签名,保留已经绑定的位置参数/关键字参数行为。新增测试覆盖两种绑定方式、
Annotated、模型返回类型、实际工具执行,以及未包装函数。Related issue number
本地复现;已检索开放的 partial/get_typed_signature PR,未发现相同修复。
Checks
在仓库 uv 锁定开发环境运行 autogen-core 的
poe fmt、poe lint、poe mypy、poe pyright全部通过;poe test:229 passed。新增用例修改前 2 失败、1 通过,修复后全部通过。为 core 现有测试补齐同一 checkout 的 autogen-ext,以及锁文件版本的 Ollama 和 email-validator。没有修改依赖清单或锁文件;未运行其他包及文档构建。AI 披露:代码、测试和中文描述由 OpenAI Codex 生成并自动检查,尚无人工复核。