mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-08-07 07:49:02 +00:00
* fix(agent-core-v2): keep context size readings on the measured path The step fold creates the assistant message in the context before the exchange finishes (a skeleton at step.begin, filled by content.part folds during streaming), and the input array llmRequester passes to contextSize.measured() is that same live array — it already includes the output. Taking input.length + output.length therefore counted the folded output twice, storing a measured prefix length one past the live context. The inflated length permanently failed get()'s measured fast path, so reads silently fell back to per-message estimates (e.g. ~50 tokens shown for a ~29k-token "hi"). Take the live context length as the measured prefix instead (input and context are identical under the identity guard), and clamp the measured prefix to the context length in get() so a bad record can never knock reads off the measured path again. Add contextSize tests driving real turns that assert the wire model, get(), and rpc getContext against the exchange totals. * feat(klient): add context-usage example tracing a fresh session Polls agent.getContext()/agent.getUsage() and streams agent events for a new session after one "hi" against a real server, printing a timeline of when the context/token readings move, plus a final consistency check comparing the measured tokenCount to cumulative usage. Model seeding is optional via KIMI_EXAMPLE_* env; the server token resolves from <kimi-home>/server.token like the v2 e2e helpers. * chore: add changeset for the context size fix |
||
|---|---|---|
| .. | ||
| basic.ts | ||
| context-usage.ts | ||
| smoke.ts | ||