cache-diagnostics changedbuild-with-claude/cache-diagnostics
Nearest release: v2.1.304, published under an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+14added
Lines−22removed
From line
30
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits13to this page, all time
The whole hunk
from line 30, old and new numbered
/
from line 30
3030<CodeGroup>
3131 ```bash cURL
3232 # Turn 1: establish the cache and opt in to diagnostics
33 response=$(curl -sS --fail-with-body https://api.anthropic.com/v1/messages \
33 curl -sS --fail-with-body https://api.anthropic.com/v1/messages \
3434 -H "x-api-key: $ANTHROPIC_API_KEY" \
3535 -H "anthropic-version: 2023-06-01" \
3636 -H "content-type: application/json" \
from line 41
4141 "system": "You are an AI assistant analyzing a large document. <document>...</document>",
4242 "messages": [{"role": "user", "content": "Summarize section 1."}],
4343 "diagnostics": {"previous_message_id": null}
44 }')
45 jq '{id, diagnostics}' <<< "$response"
46 message_id=$(jq -r '.id' <<< "$response")
44 }'
4745
48 # Turn 2: reference the previous turn so the API can compare prefixes
46 # Turn 2: pass the id from the turn 1 response as previous_message_id, so the API can compare prefixes.
47 # In the response, diagnostics: null means no divergence was found.
4948 curl -sS --fail-with-body https://api.anthropic.com/v1/messages \
5049 -H "x-api-key: $ANTHROPIC_API_KEY" \
5150 -H "anthropic-version: 2023-06-01" \
from line 60
6160 {"role": "user", "content": "Now summarize section 2."}
6261 ],
6362 "diagnostics": {"previous_message_id": "'"$message_id"'"}
64 }' | jq '{id, diagnostics}' # diagnostics: null means no divergence was found
63 }'
6564 ```
6665
6766 ```bash CLI
68 # Turn 1
69 turn1=$(ant beta:messages create \
70 --transform '{id,usage,diagnostics}' <<'YAML'
67 # Turn 1: establish the cache and opt in to diagnostics
68 ant beta:messages create <<'YAML'
7169 model: claude-opus-5-5
7270 max_tokens: 1024
7371 cache_control:
from line 77
7977 diagnostics:
8078 previous_message_id: null
8179 YAML
82 )
83 printf '%s\n' "$turn1"
8480
85 # Turn 2: pass the id from turn 1 as previous_message_id
86 message_id=$(jq -r '.id' <<<"$turn1")
87 ant beta:messages create \
88 --transform '{id,usage,diagnostics}' <<YAML
81 # Turn 2: pass the id from the turn 1 response as previous_message_id
82 ant beta:messages create <<YAML
8983 model: claude-opus-5-5
9084 max_tokens: 1024
9185 cache_control:
from line 417
423417 {"role": "user", "content": "Now summarize section 2."}
424418 ],
425419 "diagnostics": {"previous_message_id": "'"$message_id"'"}
426 }' | jq -R 'select(startswith("data: ")) | ltrimstr("data: ") | fromjson | select(.type == "message_start") | .message.diagnostics'
420 }'
427421 ```
428422
429423 ```bash CLI
430424 # Turn 2: stream. With --stream the CLI emits each SSE event as one JSON object.
431 # diagnostics arrives on the message_start event; pick it out with jq.
432 ant beta:messages create \
433 --stream --format jsonl <<YAML |
425 # diagnostics arrives on the message_start event.
426 ant beta:messages create --stream <<YAML
434427 model: claude-opus-5-5
435428 max_tokens: 1024
436429 cache_control:
from line 439
446439 diagnostics:
447440 previous_message_id: $message_id
448441 YAML
449 jq -c 'select(.type == "message_start") | .message | {id,usage,diagnostics}'
450442 ```
451443
452444 ```python Python
No line in this hunk matches that.