fix(grok): use Responses search tools#6
Merged
kunkundi merged 3 commits intoJul 16, 2026
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.
修改内容
/responses,并声明web_search工具。x_search,把本轮账号规范化后传入allowed_x_handles,最多保留 20 个。output_text和output[].content[]文本。DASHBOARD_GROK_API_MODE:auto:Grok 4.5 使用 Responses API,其他模型保持 Chat Completions;responses:显式启用搜索工具接口,适用于模型别名或兼容网关;chat:显式保留/chat/completions兼容模式。X_WATCHLIST_REQUEST_TIMEOUT_SECONDS,默认 45 秒,限制为 8–120 秒。问题原因
原实现始终调用
/chat/completions,只通过提示词要求模型搜索实时信息,没有向 API 声明搜索工具。对通过 Responses API 提供web_search/x_search的模型和网关,这无法保证获得实时检索结果。此外,X 单账号请求超时硬编码为 25 秒,工具检索稍慢时会产生不必要的失败,用户也无法根据上游网关延迟进行调整。
兼容性
默认模式为
auto。现有非 Grok 4.5 模型继续使用原来的 Chat Completions 请求,因此不会强制改变旧部署;模型别名和第三方兼容网关可以显式选择接口模式。本次修改不改变 X 去重、通知发送、美股评级内容格式或交易决策逻辑。
验证
完整
tests.test_dashboard_auth在 Windows 上运行 102 项,其中 100 项通过;剩余两项是既有平台差异:Windows 文件权限位不等于0600,以及子进程默认代码页导致中文夹具乱码,均与本次改动无关。Closes #5