Meta: quota exhaustion reports need per-request usage in wire logs to be actionable

Abierto
#5,368 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
15/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
ai, tooling

Línea de trabajo

Start in loopService.ts around dynamicTools (about line 638 for normal turns, 861 for operation requests) and operationTools() (about line 658), and compare how the compaction request resolves its tools block with a normal turn. The open question is which tool-resolution approach to use, and the issue is still awaiting maintainer approval. Done means the compaction request keeps the same tools block as a normal turn, so the cached prefix is reused, and the wire log records the per-request fields the issue describes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Several reports describe quota being consumed faster than expected. Grouping them here because they need the same kind of evidence to become actionable, and because at least one of them has a measured cause we can fix.

Primary: #679, #3948, #3781, #3926. All are still open.

One measured case

#4935 records a compaction with 941,639 input tokens and only 26,368 cached (2.8%). The reporter's controlled follow-up found the cause: with a tool allowlist active, a normal request sends about 40 tool definitions but the compaction request sends 30, and cache hits drop from 98.1% to 2.6%. Tool definitions sit at the front of a request, so a change there invalidates the cached prefix for the system prompt and everything after it — extra billable input on every compaction.

The other reports lack the data to say what happened. #679 reports 26 interactions in 90 seconds with two log lines and no reproduction steps. #3948 is a screenshot plus "does not follow instructions, wastes tokens". #3781 names 0.7.5 as a regression and asks whether context is being re-sent; #3926 reports a stuck turn followed by a 403. None of these can currently show whether the quota went to repeated requests, one uncached request, a changed tools block, or a request that never completed — and a maintainer cannot tell from the metadata either.

Proposed direction

We are preparing two changes and will share the full patch in a PR once this issue is approved:

  1. Keep the tools block stable across compaction. Normal turns resolve tools dynamically (dynamicTools: true, loopService.ts:638), but operation requests default to dynamicTools: false (loopService.ts:861) and operationTools() (loopService.ts:658) filters a startup snapshot of tools — it can only remove, never add. That is why the compaction request ends up with a different tools block and breaks the cached prefix. The direction is to make the compaction request use the same tool resolution as a normal turn. We are still weighing a one-line dynamicTools: true against having operation inherit the previous turn's exact tools snapshot; the trade-off is whether deferred-tool schemas leak into the operation, and will be resolved in the PR.
  2. Make future reports self-evident. Add per-request fields to the wire log — turn and step ids, a hash of the tools block, cache hit count, and the step-end reason — so a report can show whether quota went to repeated requests, one uncached request, a changed tools block, or a request that never completed.

Full diffs, edge cases (deferred tools, allowlist changes, profile switches), and tests will come with the PR. We are deliberately not treating all four reports as one root cause: #4935 is proven, #3926 is plausibly the stuck-turn problem tracked separately, #679 and #3948 need logs before any conclusion, and #3781 needs a version-by-version comparison. A session-level spending cap is a product decision and is out of scope.

Request

Would a maintainer /approve this issue so we can open an external bug-fix PR linking it? We would scope the PR to the measured #4935 cache fix and the logging change, and leave the symptom-only reports for follow-up. Happy to wait for triage or narrow further if needed.

This is based on code audit and the reports linked above; I do not have a runnable checkout, so the test suite and a live A/B measurement will be part of the PR.

Lenguaje dominante
TypeScript
Estrellas
8.3k
Forks
1.4k
Merge medio
12 h 6 min
PR fusionados (30 d)
596

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MoonshotAI/kimi-code

Todos los issues de MoonshotAI/kimi-code

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.