Repository navigation
fix(logs): retain bounded Search request metadata - #1
Merged
Merged
Conversation
3 of 4 tasks
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.
Search 费用日志保留实际查询参数
本 PR 由 Codex 辅助实现,目标为维护者管理的
AI4SAI/new-api:sai,不向上游仓库投稿。原生计费与日志存储继续由 new-api 负责。🔗 关联任务 / Related Issue
用户要求搜索 API 的费用流水能查看搜索参数,并质疑用 token 展示按次搜索费用。该缺口直接定位于 Search handler 未保存参数;本 PR 补齐后续日志,Portal 的按次展示在对应产品仓库处理。
参考:原生 Search/Fetch 引入 PR #7867。2026-10-31 16:38 UTC 读取官方 main
ea343c4a,Search handler 与当前部署基线仍相同,未包含此元数据。🚀 变更类型 / Type of change
📝 变更描述 / Description
成功的独立 Search 原本只留下费用、路由和零 token 数,缺少实际查询依据。现在从经过渠道覆盖后的请求中提取
query、count、need_content,与实际result_count、outcome=success一起写入现有Log.Other.web_search。查询长度与请求条数按官方接口边界限制;重试清除上一尝试的元数据。不会保存原始问题、定位信息、Header、Key、完整请求或网页正文。现有价格、预扣、结算、退款、SQL 和数据表不变;空结果及失败保持原日志/退款语义,历史缺失参数不回填。
📸 运行证明 / Proof of Work
执行:
四个包通过,116 个测试及子测试通过事件,零失败、零跳过。真实 HTTP handler 用例确认覆盖后的参数、默认值和原响应保持,未知/私密字段不进入元数据,空结果仍退款,Fetch 不产生 Search 参数。
SQLite 3.50.4 通过原预扣、结算、消费日志写入和
GetUserLogs读取,保存查询参数并保持 375 quota、零模型 token;重复结算未重复收费,普通用户投影保留 Search 参数并移除管理员信息。gofmt与git diff --check通过。本 PR 无 UI 改动,因此不附界面截图。未运行 MySQL/PostgreSQL 矩阵,未部署,未调用真实供应商。
✅ 提交前检查项 / Checklist