Repository navigation
【No.8】 Agentic 多协议一致性测试 - #341
yaoyao12345666 wants to merge 3 commits into
Conversation
# 🐛 Bug Fix ## Validate canonical protocol inputs - Reject malformed message blocks, image payloads, tool calls, tool results, and unsupported tool types with stable request paths - Normalize multiple text blocks to one canonical string across protocol adapters - Canonicalize JSON-backed tool schemas and template values before state hashing - Preserve deterministic state hashes without stringifying unsupported values --- # ✅ Tests ## Add independent three-protocol golden fixtures - Cover Chat Completions, Responses, and Anthropic Messages through their public normalization paths - Verify complete messages, tools, and chat template kwargs across text, multi-text, tool, and image scenarios - Exercise invalid roles, missing identifiers, incomplete content, image failures, ordering, and input immutability --- # 📝 Documentation ## Document the Task 8 test contract - Record fixture structure, canonical fields, portable validation commands, and task boundaries
Nyanpasu 审查看板审查状态: ✅ 已通过 审查版本: 2d0e920 复审通过(针对合并 main 后的新 head):PR 自身 11 个文件与上一轮已批准的 ac6c735 逐字节一致,合并未触及 PR 文件且经导入闭包核查无交互;此前三项发现仍保持修复。91 项协议测试在依赖隔离下通过,CI 全量单测(Python 3.10/3.11/3.12)、pre-commit 与多模态 GPU 集成均通过;H20 GPU 单测仍在运行,与本 PR 改动范围无关。
审查发现待处理
已解决或已取代
提交范围 · 接收 11 · 建议移出 0 · 待确认 0接收 11 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。
精简审查与验证依据
生产代码的必要性与替代方案
测试的必要性与替代方案
Powered by Nyanpasu with glm-5.3[1m] xhigh, please check the suggestions carefully.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rai-studio-bot
left a comment
There was a problem hiding this comment.
需要修改:新的内容校验会阻断全局数据集的多模态 Agentic 会话构建,另有工具请求的兼容性回归,详见行级意见。
新增 91 项测试通过,另以依赖隔离的实际函数验证了基线与当前提交的行为差异。现有 Agentic 回归测试因缺少 numpy 无法收集;尚无 CI 结果,未运行需要多节点 GPU 的集成测试。
| else: | ||
| raise ValueError(f"{field}.type must be one of: image_url, text") |
There was a problem hiding this comment.
请在执行这项 canonical 校验前先转换数据集图片。build_messages(relax/utils/data/data_utils.py:260)在 --multimodal-keys 路径生成 {"type":"image","image":...},而 _sample_messages(relax/agentic/pipeline/runtime.py:741)先 _normalize_prompt → check_messages,之后才 _transport_dataset_message_media。因此使用全局图文数据集时,这里会在合法内部图片转为 image_url 之前抛错,使 _build_session_specs 失败。
用实际源码函数做依赖隔离验证:对含 {"type":"image","image":"https://example.com/image.png"} 的 user prompt,基线成功生成 image_url,当前提交抛出 messages[0].content[0].type must be one of: image_url, text。请调整转换/校验顺序,并补充 _sample_messages 的图文数据集回归用例;只测三种 HTTP 请求入口无法覆盖这条路径。
There was a problem hiding this comment.
已在 ac6c735 修复:_sample_messages 现在先转换数据集媒体,再调用 check_messages。原图文复现已成功生成 image_url;新增 test_sample_messages_transports_dataset_images_before_validation 也通过依赖隔离的实际函数执行验证。完整测试模块仍因环境缺少 numpy 无法收集,此项代码问题已解决。
| parameters = function.get("parameters") | ||
| if not isinstance(parameters, dict): | ||
| raise TypeError(f"tools[{index}].function.parameters must be a dict, got {type(parameters)}") |
There was a problem hiding this comment.
请保留 Chat Completions 无参数函数省略 parameters 的合法写法。OpenAI 的函数定义 明确允许省略该字段,表示空参数列表。现在普通 user 消息配合 tools=[{"type":"function","function":{"name":"get_time"}}] 会在 _normalized_chat_request 返回 400;基线可通过归一化。这会使已有无参数工具请求失效,新增 MISSING_TOOL_SCHEMA_CASES 反而固定了该回归。请区分字段缺省与字段类型错误,为缺省值保留/定义稳定的无参数表示,并改为正向覆盖。
There was a problem hiding this comment.
已在 ac6c735 修复:省略 parameters 的无参数函数现在归一化为 {},显式传入错误类型仍会被拒绝。原请求复现和新增正向用例均通过。
| elif block_type == "tool_result": | ||
| if "content" not in block: | ||
| raise AgenticChatRequestError( | ||
| f"{block_field}.content is required", | ||
| param="messages", | ||
| ) |
There was a problem hiding this comment.
请继续接受省略 content 的空工具结果。Anthropic 官方文档 将该字段标为可选,并给出了只有 type 和 tool_use_id 的示例。在此前存在匹配 tool_use 时,基线会通过下方 block.get("content", "") 将这种结果归一化为空字符串;新增检查却返回 400,导致无输出工具执行后的合法下一轮请求失败。删除这项必填限制,并将省略字段的形式加入已有空工具结果一致性测试。
| elif block_type == "tool_result": | |
| if "content" not in block: | |
| raise AgenticChatRequestError( | |
| f"{block_field}.content is required", | |
| param="messages", | |
| ) | |
| elif block_type == "tool_result": |
There was a problem hiding this comment.
已在 ac6c735 修复:移除了 content 必填检查,省略该字段的匹配工具结果恢复归一化为空字符串。原请求复现及 test_anthropic_empty_tool_result_may_omit_content 均通过。
rai-studio-bot
left a comment
There was a problem hiding this comment.
复查通过:此前问题均已修复,本轮未发现新的需修改问题。
91 项协议测试通过;新增数据集图片回归用例通过依赖隔离验证。完整 Agentic 测试模块仍因缺少 numpy 无法收集,暂无 CI 结果;未运行需要多节点 GPU 的集成测试。
rai-studio-bot
left a comment
There was a problem hiding this comment.
复审通过(合并 main 后的新 head 2d0e9203)
本轮针对 merge commit 复查:PR 自身 11 个文件与上一轮已批准的 ac6c735 逐字节一致,合并未触及 PR 文件;经导入闭包核查,main 新变更的模块均不在 PR 改动文件的依赖范围内,无交互影响。此前三项发现(数据集图片转换顺序、无参数工具 schema 省略、Anthropic 空 tool result 省略 content)在新 head 复验均保持修复。91 项协议一致性测试以真实归一化函数复跑通过,CI 全量单测(Python 3.10/3.11/3.12)、pre-commit 与多模态 GPU 集成亦全部通过;H20 GPU 单测仍在运行,与本 PR 改动范围无关。
三条行级线程在上轮已有验证回复;本账号缺少线程 resolve 权限,烦请作者或维护者确认后点击 resolved。
审查详情、范围裁定与必要性审计见看板:#341 (comment)
|
如果完成了,记得按照流程「提交」哦 |
|
本赛题已经由 #335 合入并锁定,感谢参与~ |


Summary
messages,tools, andchat_template_kwargsfrom independently authored native fixtures.Type of Change
Test plan
Scope
This PR is limited to Agentic protocol request canonicalization and its test coverage. It does not modify scheduling, lifecycle management, training, model execution, GPU execution, or external services.
Related to #321