fix(usage): 统一模型身份解析并修正 OpenClaw 模型归类 - #73
Open
liuweifeng wants to merge 1 commit into
Open
Conversation
模型进入按模型统计和价格计算前统一使用精确目录匹配,无法确认的模型保留原始 ID,避免 OpenClaw 与 Hermes 的模型名称和估算价格分叉。 Co-authored-by: Codex <noreply@openai.com>
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.
为什么改
OpenClaw 和 Hermes 对模型 ID 的处理方式不一致。
同一个模型在 Hermes 中显示为原始模型名,但 OpenClaw 在找不到匹配项时会回退到代表性模型。这样会造成两个问题:模型名称显示不准,价格也可能按错误的模型计算。
改了什么
统一模型身份
模型 ID 现在按以下顺序处理:
canonical_slug;无法确认的模型不会再被猜成 Opus 或其他模型。
模型展示和价格计算使用同一个模型身份,避免两边各自处理后产生不同结果。
保存模型目录信息
价格更新仍然使用 OpenRouter 的公开模型目录,同时保存模型的
name、canonical_slug、owned_by以及输入、输出和缓存价格。这些信息用于后续的精确匹配和价格查询。
修正 OpenClaw 与 Hermes
OpenClaw 和 Hermes 现在使用同一套模型身份逻辑。模型明细中会保留
model_id,这样后续重新计算成本或合并多设备数据时,不需要再从显示名称反推模型。补齐模型明细 UI
Hermes 和 OpenClaw 卡片接入现有的“按模型”展开区,与其他 token Agent 保持一致。
模型展开区支持查看各模型的 token 总量、输入、输出、缓存和估算成本。没有 token/model 明细的任务记录仍然只显示任务状态。
数据示例
对于能在公开目录中精确匹配的模型:
没有匹配结果时:
这种情况下保留原始模型名称,不使用其他模型的名称或价格。
数据影响
Token 数量、会话数、任务数和日期归属不会改变。
重新扫描后,模型分组名称、模型明细行、无权威账单时的估算成本,以及多设备合并后的模型列表可能发生变化。原始日志仍然存在时,旧数据可以按新的模型身份重新归类。
验证
python3 -m unittest discover -s testsswift build -c debuggit diff --check.app和.dmg