Open
Conversation
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.
概要
这个 PR 是对现有
#35的后续替代版,保持最小改动原则,主要吸收了:#35的 planning 顺序/会话错误加固#35/#37的输出污染清洗方向#34的 provider completion 解析修复思路这次没有引入新工具、没有修改公开 schema、没有提交 README / 测试 / 本地协作文件,只提交核心代码修复。
主要改动
1. 修复
web_search在部分 Grok 中转站上的空结果/截断/假成功问题choices=null)”的显式识别request_id和错误摘要,便于和中转站排障2. 加固
plan_*调用稳定性level=1/2完成态拦截session_id时返回结构化错误,而不是模糊失败plan_*工具设计不变,不恢复单一search_planning3. 清理
web_search输出污染,并增强web_fetch错误显性化<think>和明显的拒绝/注入类污染前缀I'm Grok ... I don't follow/adopt ...这类新污染前缀web_fetch对 Tavily / Firecrawl 失败给出更明确的 provider 级错误归因4. Windows 兼容性
WindowsSelectorEventLoopPolicy()为什么要这样改
最近的真实问题不是简单的“默认模型设置不对”,而是不同 Grok 中转站对
/v1/chat/completions的实现质量差异很大。本地实测中:
https://api.925214.xyz/v1grok-4.1-fast:0/6成功grok-4.20-beta:0/6成功choices=nullhttps://ai.huan666.de/v1grok-4.1-fast:10/10成功,且输出干净grok-4.20-beta:成功率高,但更慢,且历史样本里出现过一次污染前缀因此这次 PR 优先修的是:
验证
本地自动化验证
uv run --with pytest --with pytest-asyncio pytest -q20 passeduv run --with ruff ruff check .python3 -m py_compile src/grok_search/*.py src/grok_search/providers/*.py tests/*.pygit diff --check本地未提交的回归覆盖点
以下回归测试已在本地跑过,但本次按最小改动原则 未把 tests 一并提交:
stream=False发请求<think>与拒绝/注入污染文本清洗WindowsSelectorEventLoopPolicy()helperweb_fetchprovider 级错误聚合有意不包含的内容
为保持 PR 聚焦,这次 没有 一并提交:
AGENTS.md.gitignore这些内容都已在本地验证或整理,但不属于这次上游代码修复的最小必要集合。
关联
#34#35#37#33#39