accounting: use the accountant's own size bound (Withhold(res)), stop passing TokensBefore

未关闭
#2,159 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
57/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
backend

调研方向

Read core/accounting/host.go around line 654 and core/accounting/metrics.go around line 252, then check the accountant dependency versions and the v0.11.0 API. Update the dependency and make both call-site changes described in the issue; run the accounting tests. Done when Withhold receives only the result and the observation no longer sets TokensBefore.

由索引模型根据 Issue 内容生成。

描述

Summary

Cortex passes its own request size to the accountant in two places. accountant v0.11.0 measures the size itself, and the host size is going away (rossoctl/context-guru#1523). Please move Cortex to the library's own size bound.

What we found

Cortex main at 2cb6e041 (accountant pinned at v0.10.0):

  • core/accounting/host.go:654: accountant.Withhold(p.result, before). This is the legacy form with a host size.
  • core/accounting/metrics.go:252: acmetrics.Observation{..., TokensBefore: tokensBefore}. A positive TokensBefore makes the sink use the legacy host bound.

Why

  • With a host size, the bound compares host tokens against the accountant's ratio tokens. That is two different measures. Removed text that is denser than the request average (hex, code) can then make an honest request fail as implausible_size (rossoctl/accountant#126 review).
  • From v0.11.0, Withhold(res) with no size measures the client messages itself (Result.MessageTokens, PricedOp.SavedMessages/CausedMessages, design §6.7). Tool declarations are not counted.
  • context-guru moved to it in rossoctl/context-guru#1529.

Proposal

  1. Bump to accountant and accountant/metrics v0.11.0.
  2. core/accounting/host.go: call accountant.Withhold(p.result).
  3. core/accounting/metrics.go: stop setting TokensBefore in the Observation.
  4. This is a behavior change for Cortex: the size bound moves from the host measure to the library measure. The Cortex owners decide it.

After this merges, the accountant removes the size argument of Withhold, SizeNotGiven and Observation.TokensBefore in its next minor release (rossoctl/context-guru#1523, #1524).

主要语言
Go
星标
31
派生
49
平均合并
9 小时 43 分钟
30 天内合并 PR
367

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rossoctl/cortex 的其他 Issue

查看 rossoctl/cortex 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。