Usage-based token scale can be deflated by providers that exclude cached tokens from prompt_tokens
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with _usage_total in mellea/stdlib/context/compactor.py, which derives the measured token count from total_tokens or prompt_tokens + completion_tokens, then read ChatContext._usage_scale in mellea/stdlib/context/chat.py where the ratio is clamped to _MIN_USAGE_SCALE. The work is investigate-and-guard: choose a plausibility check (budget cross-check, prefer prompt_tokens, or skip the correction when the total is implausibly small). Done means a guard is in place with tests covering an Anthropic-style cache-excluded usage payload.
索引モデルが issue の本文から書いたものです。
説明
What happened?
_usage_total (mellea/stdlib/context/compactor.py) derives the measured
token count from total_tokens, falling back to prompt_tokens + completion_tokens. Through providers whose usage accounting excludes
cache-read tokens from prompt_tokens (Anthropic-style accounting, common
via LiteLLM routing), the measured total covers only the uncached suffix plus
the completion.
In ChatContext._usage_scale (mellea/stdlib/context/chat.py, from #1760),
every receipt/identity check still passes and estimated >= _MIN_MEASURED_ESTIMATE still passes, so the ratio is computed from the
deflated measurement and clamps to _MIN_USAGE_SCALE (0.5). Every history
item is then costed at half its estimate, so up to ~2x the model's real
context can be admitted within the budget — producing hard context-length API
errors. The pre-#1760 unscaled estimate was inaccurate in the same direction,
but was never multiplied down by a mismeasurement.
Ollama is not affected: its prompt_eval_count includes KV-cached prefix
tokens (verified during the #1760 review).
What did you expect to happen?
The correction should not silently over-admit history based on a measurement
that under-counts the request.
Notes
- Scope as investigate-and-guard rather than a presumed fix. Options to
evaluate: cross-check the measured total against the current budget before
applying the ratio; preferprompt_tokensas the basis whentotal_tokens
is inconsistent with it; or skip the correction when the measured total is
implausibly small relative to the rendered request. - Related to the "overhead is counted twice" discussion in the #1760 review
(documented, not changed, in the merged code).
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 161
- 平均マージ
- 4日 3時間
- マージ済み PR(30日)
- 45
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
generative-computing/mellea のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
generative-computing/mellea#1864 ·
メンテナーはふだん 3 日以内に返信
-
bug: instruct() and react() replay tool-call turns without tool_calls対応中かも @simonyang08 が 21 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
generative-computing/mellea#1784 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Silently mangled docstrings: lone backslash line-continuations in non-raw docstrings collapse command examples対応中かも @madhusudhan1260 が 18 日前に担当しました。 オープンgood first issue p2
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
generative-computing/mellea#1780 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
area/telemetry enhancement p2
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
generative-computing/mellea#1210 ·
メンテナーはふだん 3 日以内に返信
-
area/requirement area/stdlib enhancement p2
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
generative-computing/mellea#31 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
generative-computing/mellea の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
OpenFreeEnergy/openfe#2371 ·
メンテナーはふだん 2 日以内に返信
-
HMDB's smiles file writes "None" for metabolites with an empty <smiles/> (file not currently used)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
NCATSTranslator/Babel#1269 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
404 on sample dataオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
bcgov/nr-hydrometric-rating-curve#443 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100