anthropics / anthropics/claude-code
[BUG] Prompt suggestions send a second full-context model call per turn, ~doubling token usage
- Langage dominant
- Python
- Étoiles
- 145k
- Forks
- 23.1k
- Métriques de merge des PR
- Métriques de PR en attente
Description
### Preflight Checklist
- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
### What's Wrong?
With prompt suggestions enabled (the default), Claude Code sends a **second, separate model request on every turn** — a "suggestion mode" call that carries the **entire conversation and the full tool list**. Because it's full-context, it costs almost as much as the actual reply, roughly **doubling per-turn token / quota consumption**. Nothing in the UI indicates a second billed call is happening.
I confirmed it by routing the client through a local proxy and reading the `usage` field of every `POST /v1/messages` response. Per user turn I see two `claude-sonnet-5` requests:
1. the reply (`input=2`, tiny)
2. a second request whose system prompt starts with `[SUGGESTION MODE: Suggest what the user might naturally type next into Claude Code.]`, carrying `n_msgs=20`, all 42 tool definitions, and ~60k tokens of cached context.
Setting `CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false` removes the second request entirely, which confirms the suggestion feature is the cause.
### What Should Happen?
Generating a next-prompt suggestion should not cost as much as answering the user. Either:
- make suggestions opt-**in**, or
- generate them with a cheaper model (e.g. Haiku) and a trimmed context instead of the full conversation + all tool definitions, or
- at minimum, surface that suggestions issue a separate billed model call.
### Error Messages/Logs
Captured token usage for a single `ok` turn (warm cache), via mitmproxy reading the `usage` field. No secrets included — token counts only.
**Before (default, suggestions on) — two Sonnet calls per turn:**
| call | model | input | cache_read | cache_write | output |
|------|-------|-------|-----------|-------------|--------|
| reply | claude-sonnet-5 | 2 | 60,381 | 68 | 4 |
| suggestion | claude-sonnet-5 | 504 | 60,449 | 4 | 9 |
Suggestion request system prompt begins:
[SUGGESTION MODE: Suggest what the user might naturally type next into Claude Code.]
**After (`CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false`) — one Sonnet call per turn:**
| call | model | input | cache_read | cache_write | output |
|------|-------|-------|-----------|-------------|--------|
| reply | claude-sonnet-5 | 2 | 59,956 | 0 | 4 |
### Steps to Reproduce
1. Start a local intercepting proxy: `mitmdump -s capture.py`, where the addon parses the `usage` field of each `POST /v1/messages` response (`input_tokens`/`cache_*` from the `message_start` SSE event, `output_tokens` from `message_delta`).
2. Point Claude Code at it: set `HTTPS_PROXY=http://127.0.0.1:8080` and `NODE_EXTRA_CA_CERTS` to the mitmproxy CA cert (the Node client ignores the OS cert store). Restart the app.
3. Send a prompt that triggers no tools and a fixed reply: `Reply with exactly the word ok and nothing else. Do not use any tools.`
4. Observe **two** `claude-sonnet-5` requests per turn — the reply and a `[SUGGESTION MODE...]` request carrying full context.
5. Add `"CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false"` to the `env` block in settings.json, restart, repeat step 3 — now only **one** request per turn.
### Claude Model
Sonnet (default)
### Is this a regression?
I don't know
### Last Working Version
_No response_
### Claude Code Version
2.1.241
### Platform
Anthropic API
### Operating System
Windows
### Terminal/Shell
Other
### Additional Information
- Workaround for anyone hitting this: add `"env": { "CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false" }` to settings.json.
- Related: #74826 (acknowledges suggestions carry a token cost, but frames it as an opt-in tradeoff — this report shows it is on by default and full-context), #52979 (baseline overhead for trivial prompts).
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Start by reproducing the two-request behavior with capture.py, mitmdump, and the settings.json environment override described in the report. Trace the prompt-suggestion request path and determine which proposed resolution is accepted; done means the selected behavior is implemented and the capture shows no unnecessary full-context billed call, with suggestions still behaving as intended.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- api, cli
- Type d'issue
- Bug
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Active
- Clarté
- À clarifier
- Accessibilité débutants
- 30/100