Usage-based token scale can be deflated by providers that exclude cached tokens from prompt_tokens
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
调研方向
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 小时
- 30 天内合并 PR
- 45
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shards未关闭status/accepted type/bug
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
bug vector-store
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
EverMind-AI/Raven#1413 ·
维护者通常 1 天内回复
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS pools可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
维护者通常 2 天内回复