Skip to content

【No.8】test(agentic): add cross-protocol request consistency tests - #335

Merged
SigureMo merged 3 commits into
redai-studio:mainfrom
yuhongming-2026:feat/agentic-multiprotocol-golden-tests
Oct 8, 2026
Merged

SigureMo merged 3 commits into
redai-studio:mainfrom
yuhongming-2026:feat/agentic-multiprotocol-golden-tests

Conversation

@yuhongming-2026

Copy link
Copy Markdown
Contributor

Summary

  • Add offline golden fixtures and tests for Chat Completions / Responses / Anthropic Messages so semantically equivalent requests normalize to identical messages, tools, and chat_template_kwargs.
  • Harden check_messages image/tool-call validation so illegal inputs are rejected with stable full-path field errors (e.g. messages[2].tool_calls[0].id).
  • Cover text, tool call/result, image URL/base64, and anomaly paths without network or real model services.

Test plan

  • python -m pytest tests/agentic/ -q (46 passed)
  • Confirm required CI is green on the PR
  • Comment @SigureMo 任务已完成,请求 review. after bot review

Related to #321

@yuhongming-2026

Copy link
Copy Markdown
Contributor Author

@SigureMo 任务已完成,请求 review

@SigureMo

Copy link
Copy Markdown
Member

我看没有认领第八题呀

@rai-studio-bot

rai-studio-bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: 🔎 审查中

审查版本: 7f3e1c6

目标分支: main

新一轮审查已开始:上一轮在 67047da 完成复验但因头部推进(作者推送 7f3e1c6 修复 oxfmt 格式)未发布结论。本轮按新对比范围 815de3a..7f3e1c6 重新验证:与已通过轮次相比仅 4 个 fixture 被 oxfmt 重排,其余内容逐字节一致。

审查阶段进度范围与结果
常规审查 🔎 进行中 正在按新钉定头部 7f3e1c6 复核:与 67047da 的增量是否仅为格式重排、测试是否仍通过、既有结论是否成立。
深度审查 ⏳ 待开始 待通用验证完成后,按新范围复核必要性结论(生产代码与测试)。

审查发现

待处理
编号 严重性 问题状态规则来源
暂无待处理的记录。
已解决或已取代
编号 严重性 问题状态规则来源
F1 High severity 数据集图片在媒体转换前被拒绝 ✅ 已解决 —
F2 High severity 无 tool_call_id 的既有工具观察被拒绝 ✅ 已解决 —
F3 Medium severity 普通文本与 system 多文本块跨协议一致性 ✅ 已解决 —
F4 Low severity 合并重复的 golden fixture 断言
精简建议(非阻塞)
✅ 已解决 —
Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

@yuhongming-2026

Copy link
Copy Markdown
Contributor Author

我看没有认领第八题呀

8872a44b3bf7c80237b475548a978c4f bu's不是我和hongwei-2026组队了,你不知道吗,还是我没有认领任务8,你在搞笑吗 @SigureMo @hongwei-2026

@yuhongming-2026

Copy link
Copy Markdown
Contributor Author
8872a44b3bf7c80237b475548a978c4f

@yuhongming-2026

Copy link
Copy Markdown
Contributor Author

@SigureMo ,你认真看看

@yuhongming-2026

Copy link
Copy Markdown
Contributor Author

我组队了

@SigureMo

Copy link
Copy Markdown
Member

哦抱歉看到了,麻烦先过了 CI 和 bot review 再提交

@yuhongming-2026
yuhongming-2026 force-pushed the feat/agentic-multiprotocol-golden-tests branch from a28594b to 3384ff7 Compare September 19, 2026 07:17
@SigureMo

Copy link
Copy Markdown
Member

@rai-studio-bot 请继续深度 review,专注于:

  • 是否有不合适的测试 case,不要测试不会发生的场景
  • 是否有过度防御逻辑,防御要适当,非实际可能发生的场景,不要单独防御
  • 代码是否足够精简,在能够完成任务的前提下,在不丧失可读性的前提下,可以考虑精简掉无用逻辑

可以进一步参考 https://github.com/ShigureLab/nyanpasu/blob/main/AGENTS.md 中的原则进行 review

@SigureMo

Copy link
Copy Markdown
Member
image

@hongwei-2026 如果 hongming-2026 是 @yuhongming-2026 麻烦修改一下报名哈

@yuhongming-2026
yuhongming-2026 force-pushed the feat/agentic-multiprotocol-golden-tests branch from 3384ff7 to f13de98 Compare September 19, 2026 07:49

@rai-studio-bot rai-studio-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已复核 f13de98:数据集图片与无 ID 工具观察的兼容性问题均已修复。仍有 system 文本块归一化差异需跟进,另附一项精简重复测试的非阻塞建议,详见行级评论。

未发现只能在 Python 内部构造的异常用例。隔离加载源码归一化函数后 51 项测试通过;完整 pytest 受缺少 Ray 限制,多节点 GPU 集成测试未运行,当前提交尚无 CI checks。

Powered by Nyanpasu with gpt-6-astra medium, please check the suggestions carefully.

Comment thread relax/agentic/session/state.py Outdated
Comment on lines +148 to +149
if all(part.get("type") == "text" for part in normalized_parts):
return "".join(str(part["text"]) for part in normalized_parts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 优先级:P2

请保留 system 多文本块的段落分隔。这里对所有角色直接拼接 text,导致 Chat 的 {"role":"system","content":[{"type":"text","text":"Rule A"},{"type":"text","text":"Rule B"}]} 变成 "Rule ARule B";改动前为 "Rule A\n\nRule B",Anthropic 顶层 system 使用相同两个块时仍产生后者。

该 JSON 可直接经过 HTTP normalizer;既改变了原有 system prompt,又使跨协议 messages/state hash 不一致。已在当前提交隔离执行原函数复现,现有 51 个用例仍全部通过。建议保留 system 的双换行连接规则,仅对适用角色折叠,并补充多 block system 的跨协议 fixture。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 b810d7d 修复:共享 content 归一化和 Responses 的 system 投影均使用双换行,新增三协议 system_text_list fixture 与直接回归用例。隔离执行当前源码函数后,Chat、Responses、Anthropic 均匹配 Rule A\n\nRule B,既有 system prompt 分隔得以保留。

Comment on lines +51 to +61
@pytest.mark.parametrize("case_name", GOLDEN_CASES)
def test_semantically_equivalent_protocols_share_canonical_fields(case_name: str) -> None:
expected = _load_json(FIXTURES / f"{case_name}.canonical.json")
normalized_by_protocol = {
protocol: _canonical_fields(normalizer(_load_json(FIXTURES / protocol / f"{case_name}.request.json")))
for protocol, normalizer in PROTOCOL_NORMALIZERS.items()
}
for protocol, fields in normalized_by_protocol.items():
assert fields == expected, protocol
values = list(normalized_by_protocol.values())
assert values[0] == values[1] == values[2]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 优先级:P3

这里重新读取同一组 fixture 并断言每个协议等于同一个 expected,已经被上方参数化的 test_protocol_golden_fixture_matches_canonical 完整覆盖;随后三者相等又可由这些断言直接推出,没有增加可检测的行为。

建议删除这一重复用例,保留上方按协议参数化的测试(失败时也能直接定位协议),把新增覆盖用于尚未测试的 system 多文本块等实际边界。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 b810d7d 修复:删除了重复的跨协议相等用例,保留按协议参数化的 canonical fixture 断言,并增加了 system 多文本块覆盖。

Unify Chat Completions, Responses, and Anthropic Messages into one
messages/tools/chat_template_kwargs shape with offline consistency and
error-path coverage, while keeping dataset image parts, optional
tool_call_id, and system multi-text paragraph separators compatible.

Co-authored-by: Cursor <[email protected]>
@yuhongming-2026
yuhongming-2026 force-pushed the feat/agentic-multiprotocol-golden-tests branch from f13de98 to b810d7d Compare September 19, 2026 08:02

@rai-studio-bot rai-studio-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已复核 b810d7d,先前问题均已修复,未发现新的可行动问题,审查通过。

隔离加载源码归一化函数后 51 项测试通过;完整 pytest 因缺少 Ray 无法收集,未运行需要多节点 GPU 的集成测试。当前提交尚无 CI checks,以上结论不代表 CI 已通过。

Powered by Nyanpasu with gpt-6-astra medium, please check the suggestions carefully.

@yuhongming-2026

Copy link
Copy Markdown
Contributor Author
图像 @hongwei-2026如果 hongming-2026 是@yuhongming-2026麻烦修改一下报名哈

改好了

@yuhongming-2026

Copy link
Copy Markdown
Contributor Author
图像 @hongwei-2026如果 hongming-2026 是@yuhongming-2026麻烦修改一下报名哈

改好了

@SigureMo

xiaoliang0601
xiaoliang0601 previously approved these changes Oct 8, 2026

@SigureMo SigureMo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@SigureMo SigureMo changed the title 【No.8】Agentic 多协议一致性测试 【No.8】test(agentic): add cross-protocol request consistency tests Oct 8, 2026
@SigureMo
SigureMo merged commit 5ba49c1 into redai-studio:main Oct 8, 2026
12 checks passed
@hongwei-2026

Copy link
Copy Markdown

谢谢老师

Mukayi added a commit to Mukayi/Relax that referenced this pull request Oct 12, 2026
…er-profiler

Brings in upstream/main 653c43c..dce533b (redai-studio#257, redai-studio#258, redai-studio#285, redai-studio#323, redai-studio#330,
redai-studio#335, redai-studio#408, redai-studio#409, redai-studio#412, redai-studio#414, redai-studio#416, redai-studio#417, redai-studio#419-redai-studio#421, redai-studio#424, redai-studio#426, redai-studio#427,
redai-studio#430, and 42 commits synced on 10-12 without PR numbers).

The only conflict is relax/utils/env.py: cc4b052 adds the DeepSeek-V4
MXFP4 QAT variables at the same spot where this branch adds the straggler
profiler variables. Resolved by keeping both blocks, straggler first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants