Repository navigation
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.
Author
Agent
Type
Description
Anthropic-compatible relay 可能在
message_start返回零值或缺失的 input/cache usage,直到末尾message_delta才补全。当前流式实现只更新output_tokens,导致 SDK 的输入与缓存计数一直为 0,下游 UI 的 Cache hit 显示为「—」。保留原始 usage 状态并按字段合并累计更新,再通过现有
convertUsage统一归一化。省略字段保留旧值,显式零值覆盖,重复累计快照不会相加;仅含 usage 的 delta 也不会清空已经收到的 stop reason。FinishStepPart改为在message_stop发出一次,包含完整计数。未完成流保留已观察到的 usage,同时不发出成功的步骤完成事件。Verification
MISE_TRUSTED_CONFIG_PATHS=$PWD mise run ci:build、vet、lint 和完整 short test suite 通过。go test -race ./provider/anthropic/messages ./sdk -count=1通过。集成验证版本:Memoh
e3901c745,Twilight20c743e256e2795fa5aa2950cbffd000ece4ca35。环境为本地开发栈http://127.0.0.1:41682,模型mimo-v2.6-pro,使用/v1/messages。通过真实聊天 UI 创建并逐个读取 8 个文件,刷新页面后续聊复核;独立工作区读取确认每个文件 101 行、首行整数之和为 28。两轮聊天的 7 次流式请求逐次核对,provider 与 PostgreSQL 完全一致:
UI 显示 Input 155.0K、Output 752、Cache hit 75%,与 74.7528% 的实际计数比值一致。另通过真实 Memoh Generate、Stream 和消息追加三组场景,42 次工具调用均恰好执行一次,provider usage 与 SDK 聚合值一致。
UI 截图已在本地核验。
gh pr edit --attach因当前账号没有上游仓库写权限而失败,PR 暂缺截图附件。Human QA