llm.asm chat mode (`--chat`) prompt building and KV-cache management.
Raw Developer Origin & Technical Request
GitHub Issue
Nov 26, 2026
Low priority — a note on a template deviation in multi-turn chat, which may well be a deliberate trade-off of the append-only KV-cache design.
### What happens
In `--chat` mode each turn's prompt is built by `tok_build_chat_prompt`, which in no-think mode appends the empty block `\n\n\n\n` after `assistant\n` (`shared/tokenizer.asm:198-205`). That matches the official Qwen3 template for the *current* generation prompt. But because the KV cache is only ever appended to (`.chat_infer` → `run_tokens`, `01-qwen3-inference/main.asm:484-495`), those 4 tokens stay in the history of every earlier assistant turn. The official template renders past assistant turns without the think block.
The same mechanism means that with `/think` the full reasoning text of earlier turns stays in context, whereas the official template strips reasoning from history — which also uses up the 2048-token context faster.
### How I checked
- KV-cache turn 2 in `--chat` is token-identical to a full recompute of the same token history, so the engine itself is consistent.
- Feeding llama.cpp (Q8_0 GGUF) the exact `asm-llm` token history gives the same turn-2 answer as `asm-llm`; feeding it the officially formatted history (no think block in past turns) gives a different answer.
Example: turn 1 "My name is Boris…", turn 2 "What is my name?". Neither format gave a good answer with this 0.6B model, so I cannot claim a quality impact — only that the context differs from what the model...
Developer Debate & Comments
No active discussions extracted for this entry yet.
Adjacent Repository Pain Points
Other highly discussed features and pain points extracted from alesha-pro/llm.asm.
asm-llm: decode drops ~20x when -t equals hardware threads and other processes compete for the cores
Frequently Asked Questions
Market intelligence mapped to llm.asm chat mode (`--chat`) prompt building and KV-cache management..
How is llm.asm chat mode (`--chat`) prompt building and KV-cache management. positioned in the market?
What are the foundational technologies related to llm.asm chat mode (`--chat`) prompt building and KV-cache management.?
Engagement Signals
Cross-Market Term Frequency
Counts stored text matches for foundational terms like KV cache and append-only in analysed public discussions. These counts do not measure adoption.
Stored text matches, not adoption or market-share measurements.
- KV cache: 5 records
- append-only: 5 records
- --chat mode: 1 records
- tok_build_chat_prompt: 1 records
- no-think mode: 1 records
- empty <think> block: 1 records
- shared/tokenizer.asm:198-205: 1 records
- official Qwen3 template: 1 records
- current generation prompt: 1 records
- .chat_infer: 1 records
- run_tokens: 1 records
- 01-qwen3-inference/main.asm:484-495: 1 records
- history of every earlier assistant turn: 1 records
- full reasoning text: 1 records
- strips reasoning from history: 1 records
- 2048-token context: 1 records
- token-identical: 1 records
- full recompute: 1 records
- llama.cpp (Q8_0 GGUF): 1 records
- exact asm-llm token history: 1 records
- officially formatted history: 1 records
- 0.6B model: 1 records
- assistant\n: 0 records
SaaS Metrics