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

Aperta
#2,159 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
Go
Stelle
31
Fork
49
Merge medio
9h 43m
PR unite (30g)
367

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rossoctl/cortex

Tutte le issue di rossoctl/cortex

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.