cc-viewer 1.6.49 → 1.6.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/concepts/ar/ToolsFirst.md +47 -0
- package/concepts/da/ToolsFirst.md +47 -0
- package/concepts/de/ToolsFirst.md +47 -0
- package/concepts/en/ToolsFirst.md +47 -0
- package/concepts/es/ToolsFirst.md +47 -0
- package/concepts/fr/ToolsFirst.md +47 -0
- package/concepts/it/ToolsFirst.md +47 -0
- package/concepts/ja/ToolsFirst.md +47 -0
- package/concepts/ko/ToolsFirst.md +47 -0
- package/concepts/no/ToolsFirst.md +47 -0
- package/concepts/pl/ToolsFirst.md +47 -0
- package/concepts/pt-BR/ToolsFirst.md +47 -0
- package/concepts/ru/ToolsFirst.md +47 -0
- package/concepts/th/ToolsFirst.md +47 -0
- package/concepts/tr/ToolsFirst.md +47 -0
- package/concepts/uk/ToolsFirst.md +47 -0
- package/concepts/zh/ToolsFirst.md +47 -0
- package/concepts/zh-TW/ToolsFirst.md +47 -0
- package/dist/assets/App-CsagnfUU.js +39 -0
- package/dist/assets/{AppHeader-CRtigv_9.css → AppHeader-MHCpfC0r.css} +1 -1
- package/dist/assets/{AppHeader.module-mubLi1xV.js → AppHeader.module-Dy9BXOVo.js} +149 -149
- package/dist/assets/{Mobile-BHNZcAYR.js → Mobile-DW4Jc99e.js} +1 -1
- package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
- package/dist/assets/{index-DPLzENgP.js → index-C8H1VbBG.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +2 -1
- package/dist/assets/App-BYcUiUrY.js +0 -39
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# لماذا تُدرج الأدوات أولاً؟
|
|
2
|
+
|
|
3
|
+
في لوحة السياق بـ cc-viewer، **تظهر Tools قبل System Prompt والMessages**. يعكس هذا الترتيب بدقة **تسلسل بادئة KV-Cache في Anthropic API**.
|
|
4
|
+
|
|
5
|
+
## تسلسل بادئة KV-Cache
|
|
6
|
+
|
|
7
|
+
عندما تبني Anthropic API الـ KV-Cache، تقوم بتسلسل السياق في بادئة وفق هذا **الترتيب الثابت**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
هذا يعني أن **Tools تأتي قبل System Prompt في بداية بادئة الـ cache تماماً**.
|
|
18
|
+
|
|
19
|
+
## لماذا تمتلك Tools وزناً أعلى في الـ Cache من System؟
|
|
20
|
+
|
|
21
|
+
في مطابقة بادئة KV-Cache، **المحتوى الأسبق أكثر أهمية** — أي تغيير يُبطل كل ما يليه:
|
|
22
|
+
|
|
23
|
+
1. **مطابقة البادئة تبدأ من البداية**: يقارن KV-Cache الطلب الحالي بالبادئة المخزنة token بـ token من البداية. فور اكتشاف عدم تطابق، يُبطَل كل المحتوى اللاحق.
|
|
24
|
+
|
|
25
|
+
2. **تغيير Tools = إبطال كامل للـ cache**: بما أن Tools تأتي أولاً، فأي تغيير في تعريفات الأدوات (حتى إضافة أو حذف MCP tool واحدة) **يكسر البادئة من البداية تماماً**، مما يُبطل كل الـ System Prompt والMessages المخزنة.
|
|
26
|
+
|
|
27
|
+
3. **تغيير System = إبطال cache الـ Messages**: يقع System Prompt في المنتصف، لذا تؤثر تغييراته فقط على جزء الـ Messages الذي يليه.
|
|
28
|
+
|
|
29
|
+
4. **تغيير Messages = يؤثر فقط على الذيل**: Messages تأتي في النهاية، لذا إضافة رسائل جديدة تُبطل فقط جزءاً صغيراً في النهاية — يبقى cache الـ Tools والـ System سليماً.
|
|
30
|
+
|
|
31
|
+
## التأثير العملي
|
|
32
|
+
|
|
33
|
+
| نوع التغيير | تأثير الـ Cache | السيناريو النموذجي |
|
|
34
|
+
|-------------|----------------|---------------------|
|
|
35
|
+
| إضافة/حذف Tool | **إبطال كامل** | اتصال/انقطاع MCP server، تفعيل/تعطيل إضافة IDE |
|
|
36
|
+
| تغيير System Prompt | فقدان cache الـ Messages | تعديل CLAUDE.md، حقن system reminder |
|
|
37
|
+
| إضافة رسالة جديدة | زيادة طرفية فقط | تدفق المحادثة الطبيعي (الأكثر شيوعاً، الأقل تكلفة) |
|
|
38
|
+
|
|
39
|
+
لهذا السبب يُعد `tools_change` في [CacheRebuild](CacheRebuild.md) أغلى أسباب إعادة البناء في الغالب — لأنه يكسر سلسلة البادئة من الأمام تماماً.
|
|
40
|
+
|
|
41
|
+
## تصميم واجهة cc-viewer
|
|
42
|
+
|
|
43
|
+
يرتب cc-viewer لوحة السياق لتتوافق مع تسلسل بادئة KV-Cache:
|
|
44
|
+
|
|
45
|
+
- **الترتيب من الأعلى إلى الأسفل = ترتيب تسلسل بادئة الـ cache**
|
|
46
|
+
- **التغييرات في الأعلى لها تأثير أكبر على معدل إصابة الـ cache**
|
|
47
|
+
- بالاقتران مع لوحة [KV-Cache-Text](KVCacheContent.md)، يمكنك رؤية النص الكامل لبادئة الـ cache مباشرة
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Hvorfor vises Tools først?
|
|
2
|
+
|
|
3
|
+
I cc-viewers kontekstpanel vises **Tools før System Prompt og Messages**. Denne rækkefølge afspejler præcist **Anthropic API's KV-Cache-præfikssekvens**.
|
|
4
|
+
|
|
5
|
+
## KV-Cache-præfikssekvens
|
|
6
|
+
|
|
7
|
+
Når Anthropic's API opbygger KV-Cache, sammensætter den konteksten til et præfiks i denne **faste rækkefølge**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Det betyder, at **Tools befinder sig før System Prompt helt i begyndelsen af cache-præfikset**.
|
|
18
|
+
|
|
19
|
+
## Hvorfor har Tools større cache-vægt end System?
|
|
20
|
+
|
|
21
|
+
Ved KV-Cache-præfiksmatchning er **tidligt indhold mere kritisk** — enhver ændring ugyldiggør alt efterfølgende indhold:
|
|
22
|
+
|
|
23
|
+
1. **Præfiksmatchning starter fra begyndelsen**: KV-Cache sammenligner den aktuelle anmodning med det cachede præfiks token for token fra starten. I det øjeblik en uoverensstemmelse opdages, ugyldiggøres alt efterfølgende indhold.
|
|
24
|
+
|
|
25
|
+
2. **Tools ændres = hele cache ugyldiggøres**: Da Tools kommer først, vil enhver ændring i værktøjsdefinitioner (selv tilføjelse eller fjernelse af et enkelt MCP-tool) **bryde præfikset helt fra starten** og ugyldiggøre al cachet System Prompt og Messages.
|
|
26
|
+
|
|
27
|
+
3. **System ændres = Messages-cache ugyldiggøres**: System Prompt befinder sig i midten, så dens ændringer ugyldiggør kun den efterfølgende Messages-del.
|
|
28
|
+
|
|
29
|
+
4. **Messages ændres = kun halen påvirkes**: Messages er i slutningen, så tilføjelse af nye beskeder ugyldiggør kun et lille afsluttende segment — Tools- og System-cache forbliver intakt.
|
|
30
|
+
|
|
31
|
+
## Praktisk betydning
|
|
32
|
+
|
|
33
|
+
| Ændringstype | Cache-påvirkning | Typisk scenarie |
|
|
34
|
+
|--------------|-----------------|-----------------|
|
|
35
|
+
| Tool tilføjet/fjernet | **Fuld ugyldiggørelse** | MCP server tilslut/frakobl, IDE-plugin til/fra |
|
|
36
|
+
| System Prompt ændring | Messages-cache tabt | CLAUDE.md redigering, system reminder-injektion |
|
|
37
|
+
| Ny besked tilføjet | Kun hale-tilvækst | Normal samtalegång (mest almindelig, billigst) |
|
|
38
|
+
|
|
39
|
+
Det er derfor `tools_change` i [CacheRebuild](CacheRebuild.md) typisk er den dyreste genopbygningsårsag — det bryder præfikskæden helt forrest.
|
|
40
|
+
|
|
41
|
+
## cc-viewers layoutdesign
|
|
42
|
+
|
|
43
|
+
cc-viewer arrangerer kontekstpanelet så det matcher KV-Cache-præfikssekvensen:
|
|
44
|
+
|
|
45
|
+
- **Rækkefølge fra top til bund = cache-præfiksets sammensætningsrækkefølge**
|
|
46
|
+
- **Ændringer højere oppe har større indflydelse på cache-hitrate**
|
|
47
|
+
- Kombineret med panelet [KV-Cache-Text](KVCacheContent.md) kan du se den fulde cache-præfikstekst direkte
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Warum werden Tools zuerst aufgelistet?
|
|
2
|
+
|
|
3
|
+
Im Context-Panel von cc-viewer **erscheinen Tools vor System Prompt und Messages**. Diese Reihenfolge spiegelt exakt die **KV-Cache-Präfix-Sequenz der Anthropic API** wider.
|
|
4
|
+
|
|
5
|
+
## KV-Cache-Präfix-Sequenz
|
|
6
|
+
|
|
7
|
+
Wenn die Anthropic API den KV-Cache aufbaut, verkettet sie den Kontext in dieser **festen Reihenfolge** zu einem Präfix:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Das bedeutet: **Tools befinden sich vor dem System Prompt, ganz am Anfang des Cache-Präfixes**.
|
|
18
|
+
|
|
19
|
+
## Warum haben Tools ein höheres Cache-Gewicht als System?
|
|
20
|
+
|
|
21
|
+
Beim KV-Cache-Präfix-Matching ist **früher Inhalt entscheidender** — jede Änderung macht alles Folgende ungültig:
|
|
22
|
+
|
|
23
|
+
1. **Präfix-Matching beginnt am Anfang**: Der KV-Cache vergleicht die aktuelle Anfrage token-für-token vom Anfang mit dem gecachten Präfix. Sobald eine Abweichung gefunden wird, wird der gesamte nachfolgende Inhalt invalidiert.
|
|
24
|
+
|
|
25
|
+
2. **Änderung der Tools = gesamter Cache invalidiert**: Da Tools an erster Stelle stehen, **bricht jede Änderung an Tool-Definitionen (auch das Hinzufügen oder Entfernen eines einzelnen MCP-Tools) das Präfix vom ersten Moment an**, wodurch alle gecachten System Prompt- und Messages-Inhalte invalidiert werden.
|
|
26
|
+
|
|
27
|
+
3. **Änderung von System = Messages-Cache invalidiert**: Der System Prompt befindet sich in der Mitte, sodass seine Änderungen nur den nachfolgenden Messages-Teil invalidieren.
|
|
28
|
+
|
|
29
|
+
4. **Änderung von Messages = nur das Ende betroffen**: Messages stehen am Ende, sodass das Anhängen neuer Messages nur ein kleines abschließendes Segment invalidiert — Tools- und System-Cache bleiben intakt.
|
|
30
|
+
|
|
31
|
+
## Praktische Auswirkungen
|
|
32
|
+
|
|
33
|
+
| Änderungstyp | Cache-Auswirkung | Typisches Szenario |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool hinzugefügt/entfernt | **Vollständige Invalidierung** | MCP-Server verbinden/trennen, IDE-Plugin ein-/ausschalten |
|
|
36
|
+
| System Prompt-Änderung | Messages-Cache verloren | CLAUDE.md bearbeiten, system reminder einfügen |
|
|
37
|
+
| Neue Message angehängt | Nur Tail-Inkrement | Normaler Gesprächsfluss (am häufigsten, am günstigsten) |
|
|
38
|
+
|
|
39
|
+
Deshalb ist `tools_change` in [CacheRebuild](CacheRebuild.md) oft der teuerste Rebuild-Grund — es bricht die Präfix-Kette ganz am Anfang.
|
|
40
|
+
|
|
41
|
+
## Layout-Design von cc-viewer
|
|
42
|
+
|
|
43
|
+
cc-viewer ordnet das Context-Panel so an, dass es der KV-Cache-Präfix-Sequenz entspricht:
|
|
44
|
+
|
|
45
|
+
- **Reihenfolge von oben nach unten = Reihenfolge der Cache-Präfix-Verkettung**
|
|
46
|
+
- **Änderungen weiter oben haben größeren Einfluss auf die Cache-Trefferquote**
|
|
47
|
+
- In Kombination mit dem [KV-Cache-Text](KVCacheContent.md)-Panel können Sie den vollständigen Cache-Präfix-Text direkt einsehen
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Why Are Tools Listed First?
|
|
2
|
+
|
|
3
|
+
In cc-viewer's Context panel, **Tools appear before System Prompt and Messages**. This ordering precisely mirrors the **Anthropic API's KV-Cache prefix sequence**.
|
|
4
|
+
|
|
5
|
+
## KV-Cache Prefix Sequence
|
|
6
|
+
|
|
7
|
+
When Anthropic's API constructs the KV-Cache, it concatenates context into a prefix in this **fixed order**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This means **Tools sit before System Prompt at the very beginning of the cache prefix**.
|
|
18
|
+
|
|
19
|
+
## Why Do Tools Have Higher Cache Weight Than System?
|
|
20
|
+
|
|
21
|
+
In KV-Cache prefix matching, **earlier content is more critical** — any change invalidates everything after it:
|
|
22
|
+
|
|
23
|
+
1. **Prefix matching starts from the beginning**: The KV-Cache compares the current request against the cached prefix token-by-token from the start. The moment a mismatch is found, all subsequent content is invalidated.
|
|
24
|
+
|
|
25
|
+
2. **Tools change = entire cache invalidated**: Since Tools come first, any change to tool definitions (even adding or removing a single MCP tool) **breaks the prefix from the very start**, invalidating all cached System Prompt and Messages.
|
|
26
|
+
|
|
27
|
+
3. **System change = Messages cache invalidated**: System Prompt sits in the middle, so its changes only invalidate the Messages portion that follows.
|
|
28
|
+
|
|
29
|
+
4. **Messages change = only the tail affected**: Messages are at the end, so appending new messages only invalidates a small trailing segment — Tools and System cache remain intact.
|
|
30
|
+
|
|
31
|
+
## Practical Impact
|
|
32
|
+
|
|
33
|
+
| Change Type | Cache Impact | Typical Scenario |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool added/removed | **Full invalidation** | MCP server connect/disconnect, IDE plugin toggle |
|
|
36
|
+
| System Prompt change | Messages cache lost | CLAUDE.md edit, system reminder injection |
|
|
37
|
+
| New message appended | Tail increment only | Normal conversation flow (most common, cheapest) |
|
|
38
|
+
|
|
39
|
+
This is why `tools_change` in [CacheRebuild](CacheRebuild.md) tends to be the most expensive rebuild reason — it breaks the prefix chain at the very front.
|
|
40
|
+
|
|
41
|
+
## cc-viewer's Layout Design
|
|
42
|
+
|
|
43
|
+
cc-viewer arranges the Context panel to match the KV-Cache prefix sequence:
|
|
44
|
+
|
|
45
|
+
- **Top-to-bottom order = cache prefix concatenation order**
|
|
46
|
+
- **Changes higher up have greater impact on cache hit rate**
|
|
47
|
+
- Paired with the [KV-Cache-Text](KVCacheContent.md) panel, you can see the full cache prefix text directly
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# ¿Por qué se listan primero los Tools?
|
|
2
|
+
|
|
3
|
+
En el panel Context de cc-viewer, **los Tools aparecen antes que el System Prompt y los Messages**. Este orden refleja con precisión la **secuencia de prefijo KV-Cache de la API de Anthropic**.
|
|
4
|
+
|
|
5
|
+
## Secuencia de prefijo KV-Cache
|
|
6
|
+
|
|
7
|
+
Cuando la API de Anthropic construye el KV-Cache, concatena el contexto en un prefijo en este **orden fijo**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Esto significa que **los Tools se encuentran antes del System Prompt, al comienzo del prefijo de caché**.
|
|
18
|
+
|
|
19
|
+
## ¿Por qué los Tools tienen mayor peso en caché que System?
|
|
20
|
+
|
|
21
|
+
En la coincidencia de prefijo KV-Cache, **el contenido más temprano es más crítico** — cualquier cambio invalida todo lo que viene después:
|
|
22
|
+
|
|
23
|
+
1. **La coincidencia de prefijo comienza desde el principio**: El KV-Cache compara la solicitud actual con el prefijo almacenado en caché token por token desde el inicio. En el momento en que se detecta una discrepancia, todo el contenido posterior queda invalidado.
|
|
24
|
+
|
|
25
|
+
2. **Cambio en Tools = todo el caché invalidado**: Como los Tools están primero, cualquier cambio en las definiciones de tool (incluso agregar o eliminar un solo MCP tool) **rompe el prefijo desde el mismísimo inicio**, invalidando todo el System Prompt y los Messages almacenados en caché.
|
|
26
|
+
|
|
27
|
+
3. **Cambio en System = caché de Messages invalidado**: El System Prompt está en el medio, por lo que sus cambios solo invalidan la porción de Messages que le sigue.
|
|
28
|
+
|
|
29
|
+
4. **Cambio en Messages = solo el final se ve afectado**: Los Messages están al final, por lo que agregar nuevos messages solo invalida un pequeño segmento final — los cachés de Tools y System permanecen intactos.
|
|
30
|
+
|
|
31
|
+
## Impacto práctico
|
|
32
|
+
|
|
33
|
+
| Tipo de cambio | Impacto en caché | Escenario típico |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool agregado/eliminado | **Invalidación completa** | Conexión/desconexión de servidor MCP, activación/desactivación de plugin IDE |
|
|
36
|
+
| Cambio en System Prompt | Caché de Messages perdido | Edición de CLAUDE.md, inyección de system reminder |
|
|
37
|
+
| Nuevo message agregado | Solo incremento de cola | Flujo de conversación normal (el más común, el más económico) |
|
|
38
|
+
|
|
39
|
+
Por eso `tools_change` en [CacheRebuild](CacheRebuild.md) tiende a ser la razón de reconstrucción más costosa — rompe la cadena de prefijo desde el principio.
|
|
40
|
+
|
|
41
|
+
## Diseño del panel de cc-viewer
|
|
42
|
+
|
|
43
|
+
cc-viewer organiza el panel Context para que coincida con la secuencia de prefijo KV-Cache:
|
|
44
|
+
|
|
45
|
+
- **Orden de arriba a abajo = orden de concatenación del prefijo de caché**
|
|
46
|
+
- **Los cambios más arriba tienen mayor impacto en la tasa de aciertos del caché**
|
|
47
|
+
- Junto con el panel [KV-Cache-Text](KVCacheContent.md), puedes ver el texto completo del prefijo de caché directamente
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Pourquoi les Tools sont-ils listés en premier ?
|
|
2
|
+
|
|
3
|
+
Dans le panneau Context de cc-viewer, **les Tools apparaissent avant le System Prompt et les Messages**. Cet ordre reflète précisément la **séquence de préfixe KV-Cache de l'API Anthropic**.
|
|
4
|
+
|
|
5
|
+
## Séquence de préfixe KV-Cache
|
|
6
|
+
|
|
7
|
+
Lorsque l'API Anthropic construit le KV-Cache, elle concatène le contexte en un préfixe dans cet **ordre fixe** :
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Cela signifie que **les Tools se trouvent avant le System Prompt, tout au début du préfixe de cache**.
|
|
18
|
+
|
|
19
|
+
## Pourquoi les Tools ont-ils un poids de cache supérieur à System ?
|
|
20
|
+
|
|
21
|
+
Dans la correspondance de préfixe KV-Cache, **le contenu en début de séquence est plus critique** — toute modification invalide tout ce qui suit :
|
|
22
|
+
|
|
23
|
+
1. **La correspondance de préfixe commence par le début** : Le KV-Cache compare la requête actuelle au préfixe mis en cache token par token depuis le début. Dès qu'une divergence est détectée, tout le contenu suivant est invalidé.
|
|
24
|
+
|
|
25
|
+
2. **Modification des Tools = tout le cache invalidé** : Les Tools étant en première position, toute modification des définitions de tool (même l'ajout ou la suppression d'un seul MCP tool) **brise le préfixe dès le tout début**, invalidant tous les System Prompt et Messages mis en cache.
|
|
26
|
+
|
|
27
|
+
3. **Modification de System = cache des Messages invalidé** : Le System Prompt se trouve au milieu, donc ses modifications n'invalident que la portion Messages qui suit.
|
|
28
|
+
|
|
29
|
+
4. **Modification des Messages = seule la fin est affectée** : Les Messages sont à la fin, donc l'ajout de nouveaux messages n'invalide qu'un petit segment final — les caches Tools et System restent intacts.
|
|
30
|
+
|
|
31
|
+
## Impact pratique
|
|
32
|
+
|
|
33
|
+
| Type de modification | Impact sur le cache | Scénario typique |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool ajouté/supprimé | **Invalidation complète** | Connexion/déconnexion d'un serveur MCP, activation/désactivation d'un plugin IDE |
|
|
36
|
+
| Modification du System Prompt | Cache des Messages perdu | Édition de CLAUDE.md, injection de system reminder |
|
|
37
|
+
| Nouveau message ajouté | Incrément de queue uniquement | Flux de conversation normal (le plus fréquent, le moins coûteux) |
|
|
38
|
+
|
|
39
|
+
C'est pourquoi `tools_change` dans [CacheRebuild](CacheRebuild.md) tend à être la raison de reconstruction la plus coûteuse — elle brise la chaîne de préfixe dès le tout début.
|
|
40
|
+
|
|
41
|
+
## Conception de la mise en page de cc-viewer
|
|
42
|
+
|
|
43
|
+
cc-viewer organise le panneau Context pour correspondre à la séquence de préfixe KV-Cache :
|
|
44
|
+
|
|
45
|
+
- **Ordre de haut en bas = ordre de concaténation du préfixe de cache**
|
|
46
|
+
- **Les modifications plus haut ont un impact plus grand sur le taux de succès du cache**
|
|
47
|
+
- Associé au panneau [KV-Cache-Text](KVCacheContent.md), vous pouvez voir directement le texte complet du préfixe de cache
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Perché i Tools sono elencati per primi?
|
|
2
|
+
|
|
3
|
+
Nel pannello Context di cc-viewer, **i Tools appaiono prima di System Prompt e Messages**. Questo ordine riflette con precisione la **sequenza del prefisso KV-Cache dell'API di Anthropic**.
|
|
4
|
+
|
|
5
|
+
## Sequenza del prefisso KV-Cache
|
|
6
|
+
|
|
7
|
+
Quando l'API di Anthropic costruisce il KV-Cache, concatena il contesto in un prefisso in questo **ordine fisso**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Ciò significa che **i Tools si trovano prima del System Prompt, all'inizio del prefisso di cache**.
|
|
18
|
+
|
|
19
|
+
## Perché i Tools hanno un peso di cache maggiore di System?
|
|
20
|
+
|
|
21
|
+
Nella corrispondenza del prefisso KV-Cache, **il contenuto precedente è più critico** — qualsiasi modifica invalida tutto ciò che segue:
|
|
22
|
+
|
|
23
|
+
1. **La corrispondenza del prefisso inizia dall'inizio**: Il KV-Cache confronta la richiesta corrente con il prefisso memorizzato nella cache token per token dall'inizio. Nel momento in cui viene rilevata una discrepanza, tutto il contenuto successivo viene invalidato.
|
|
24
|
+
|
|
25
|
+
2. **Modifica dei Tools = intera cache invalidata**: Poiché i Tools sono in prima posizione, qualsiasi modifica alle definizioni dei tool (anche aggiungere o rimuovere un singolo MCP tool) **rompe il prefisso dal primissimo inizio**, invalidando tutti i System Prompt e i Messages memorizzati nella cache.
|
|
26
|
+
|
|
27
|
+
3. **Modifica di System = cache dei Messages invalidata**: Il System Prompt si trova nel mezzo, quindi le sue modifiche invalidano solo la porzione dei Messages che segue.
|
|
28
|
+
|
|
29
|
+
4. **Modifica dei Messages = solo la coda è interessata**: I Messages sono alla fine, quindi aggiungere nuovi messages invalida solo un piccolo segmento finale — le cache di Tools e System rimangono intatte.
|
|
30
|
+
|
|
31
|
+
## Impatto pratico
|
|
32
|
+
|
|
33
|
+
| Tipo di modifica | Impatto sulla cache | Scenario tipico |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool aggiunto/rimosso | **Invalidazione completa** | Connessione/disconnessione server MCP, attivazione/disattivazione plugin IDE |
|
|
36
|
+
| Modifica del System Prompt | Cache dei Messages persa | Modifica di CLAUDE.md, iniezione di system reminder |
|
|
37
|
+
| Nuovo message aggiunto | Solo incremento della coda | Flusso di conversazione normale (il più comune, il meno costoso) |
|
|
38
|
+
|
|
39
|
+
Ecco perché `tools_change` in [CacheRebuild](CacheRebuild.md) tende ad essere il motivo di ricostruzione più costoso — rompe la catena del prefisso fin dall'inizio.
|
|
40
|
+
|
|
41
|
+
## Design del layout di cc-viewer
|
|
42
|
+
|
|
43
|
+
cc-viewer organizza il pannello Context in modo da corrispondere alla sequenza del prefisso KV-Cache:
|
|
44
|
+
|
|
45
|
+
- **Ordine dall'alto verso il basso = ordine di concatenazione del prefisso di cache**
|
|
46
|
+
- **Le modifiche più in alto hanno un impatto maggiore sul tasso di successo della cache**
|
|
47
|
+
- Abbinato al pannello [KV-Cache-Text](KVCacheContent.md), è possibile vedere direttamente il testo completo del prefisso di cache
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# なぜToolsが最初に表示されるのか?
|
|
2
|
+
|
|
3
|
+
cc-viewerのContextパネルでは、**ToolsはSystem PromptとMessagesより前に表示されます**。この順序は、**Anthropic APIのKV-Cacheプレフィックスシーケンス**を正確に反映しています。
|
|
4
|
+
|
|
5
|
+
## KV-Cacheプレフィックスシーケンス
|
|
6
|
+
|
|
7
|
+
Anthropic のAPIがKV-Cacheを構築する際、コンテキストを以下の**固定された順序**でプレフィックスとして連結します:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
つまり、**ToolsはSystem Promptより前、キャッシュプレフィックスの最先頭に位置します**。
|
|
18
|
+
|
|
19
|
+
## なぜToolsはSystemよりキャッシュの重みが大きいのか?
|
|
20
|
+
|
|
21
|
+
KV-Cacheのプレフィックスマッチングでは、**前方のコンテンツほど重要**です — 変更が発生すると、それ以降のすべてが無効化されます:
|
|
22
|
+
|
|
23
|
+
1. **プレフィックスマッチングは先頭から開始される**:KV-Cacheは現在のリクエストをキャッシュされたプレフィックスと先頭からtoken単位で比較します。不一致が見つかった瞬間、それ以降のコンテンツはすべて無効化されます。
|
|
24
|
+
|
|
25
|
+
2. **Toolsの変更 = キャッシュ全体が無効化**:Toolsは最前列にあるため、tool定義の変更(MCP toolの追加・削除1つでも)は**プレフィックスを最先頭から破壊し**、キャッシュされたSystem PromptとMessagesすべてを無効化します。
|
|
26
|
+
|
|
27
|
+
3. **Systemの変更 = Messagesキャッシュが無効化**:System Promptは中間に位置するため、その変更は後続のMessages部分のみを無効化します。
|
|
28
|
+
|
|
29
|
+
4. **Messagesの変更 = 末尾部分のみ影響**:Messagesは末尾にあるため、新しいmessageの追加は小さな末尾セグメントのみを無効化します — ToolsとSystemのキャッシュはそのまま保持されます。
|
|
30
|
+
|
|
31
|
+
## 実際の影響
|
|
32
|
+
|
|
33
|
+
| 変更の種類 | キャッシュへの影響 | 典型的なシナリオ |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool追加/削除 | **完全無効化** | MCPサーバーの接続/切断、IDEプラグインの切り替え |
|
|
36
|
+
| System Promptの変更 | Messagesキャッシュが失われる | CLAUDE.mdの編集、system reminderの挿入 |
|
|
37
|
+
| 新しいmessageの追加 | 末尾の増分のみ | 通常の会話フロー(最も一般的、最もコストが低い) |
|
|
38
|
+
|
|
39
|
+
これが、[CacheRebuild](CacheRebuild.md)における`tools_change`が最もコストの高いリビルド理由になりやすい理由です — プレフィックスチェーンを最前部から破壊するからです。
|
|
40
|
+
|
|
41
|
+
## cc-viewerのレイアウト設計
|
|
42
|
+
|
|
43
|
+
cc-viewerはContextパネルをKV-Cacheプレフィックスシーケンスと一致するように配置しています:
|
|
44
|
+
|
|
45
|
+
- **上から下の順序 = キャッシュプレフィックスの連結順序**
|
|
46
|
+
- **上位の変更ほどキャッシュヒット率への影響が大きい**
|
|
47
|
+
- [KV-Cache-Text](KVCacheContent.md)パネルと組み合わせることで、キャッシュプレフィックスの全テキストを直接確認できます
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Tools가 왜 먼저 나열되는가?
|
|
2
|
+
|
|
3
|
+
cc-viewer의 Context 패널에서 **Tools는 System Prompt와 Messages보다 앞에 표시됩니다**. 이 순서는 **Anthropic API의 KV-Cache 프리픽스 시퀀스**를 정확히 반영한 것입니다.
|
|
4
|
+
|
|
5
|
+
## KV-Cache 프리픽스 시퀀스
|
|
6
|
+
|
|
7
|
+
Anthropic의 API가 KV-Cache를 구성할 때, 컨텍스트를 다음 **고정된 순서**로 프리픽스에 연결합니다:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
즉, **Tools는 System Prompt보다 앞에, 캐시 프리픽스의 맨 처음에 위치합니다**.
|
|
18
|
+
|
|
19
|
+
## Tools가 System보다 캐시 가중치가 높은 이유는?
|
|
20
|
+
|
|
21
|
+
KV-Cache 프리픽스 매칭에서는 **앞쪽의 콘텐츠일수록 더 중요**합니다 — 변경이 발생하면 그 이후의 모든 내용이 무효화됩니다:
|
|
22
|
+
|
|
23
|
+
1. **프리픽스 매칭은 처음부터 시작됩니다**: KV-Cache는 현재 요청을 캐시된 프리픽스와 처음부터 token 단위로 비교합니다. 불일치가 발견되는 순간, 이후의 모든 콘텐츠가 무효화됩니다.
|
|
24
|
+
|
|
25
|
+
2. **Tools 변경 = 전체 캐시 무효화**: Tools가 맨 앞에 있기 때문에, tool 정의의 변경(MCP tool 하나를 추가하거나 제거하는 것만으로도)은 **프리픽스를 맨 처음부터 깨뜨려**, 캐시된 System Prompt와 Messages 전체를 무효화합니다.
|
|
26
|
+
|
|
27
|
+
3. **System 변경 = Messages 캐시 무효화**: System Prompt는 중간에 위치하므로, 변경 시 그 뒤에 오는 Messages 부분만 무효화됩니다.
|
|
28
|
+
|
|
29
|
+
4. **Messages 변경 = 끝부분만 영향받음**: Messages는 마지막에 있으므로, 새로운 message 추가는 작은 끝부분 세그먼트만 무효화합니다 — Tools와 System 캐시는 그대로 유지됩니다.
|
|
30
|
+
|
|
31
|
+
## 실제 영향
|
|
32
|
+
|
|
33
|
+
| 변경 유형 | 캐시 영향 | 일반적인 시나리오 |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool 추가/제거 | **전체 무효화** | MCP 서버 연결/연결 해제, IDE 플러그인 전환 |
|
|
36
|
+
| System Prompt 변경 | Messages 캐시 손실 | CLAUDE.md 편집, system reminder 삽입 |
|
|
37
|
+
| 새 message 추가 | 끝부분 증분만 | 일반적인 대화 흐름 (가장 일반적, 가장 저렴) |
|
|
38
|
+
|
|
39
|
+
이것이 [CacheRebuild](CacheRebuild.md)에서 `tools_change`가 가장 비용이 많이 드는 리빌드 이유가 되기 쉬운 이유입니다 — 프리픽스 체인을 맨 앞에서부터 깨뜨리기 때문입니다.
|
|
40
|
+
|
|
41
|
+
## cc-viewer의 레이아웃 설계
|
|
42
|
+
|
|
43
|
+
cc-viewer는 Context 패널을 KV-Cache 프리픽스 시퀀스와 일치하도록 배치합니다:
|
|
44
|
+
|
|
45
|
+
- **위에서 아래로의 순서 = 캐시 프리픽스 연결 순서**
|
|
46
|
+
- **위쪽의 변경일수록 캐시 히트율에 더 큰 영향을 미침**
|
|
47
|
+
- [KV-Cache-Text](KVCacheContent.md) 패널과 함께 사용하면, 캐시 프리픽스의 전체 텍스트를 직접 확인할 수 있습니다
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Hvorfor vises Tools først?
|
|
2
|
+
|
|
3
|
+
I cc-viewers kontekstpanel vises **Tools før System Prompt og Messages**. Denne rekkefølgen gjenspeiler nøyaktig **Anthropic API-ens KV-Cache-prefiks-sekvens**.
|
|
4
|
+
|
|
5
|
+
## KV-Cache-prefiks-sekvens
|
|
6
|
+
|
|
7
|
+
Når Anthropic's API bygger opp KV-Cache, setter den sammen konteksten til et prefiks i denne **faste rekkefølgen**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Dette betyr at **Tools befinner seg før System Prompt helt i begynnelsen av cache-prefikset**.
|
|
18
|
+
|
|
19
|
+
## Hvorfor har Tools høyere cache-vekt enn System?
|
|
20
|
+
|
|
21
|
+
Ved KV-Cache-prefiksmatchning er **tidlig innhold mer kritisk** — enhver endring ugyldiggjør alt som kommer etter:
|
|
22
|
+
|
|
23
|
+
1. **Prefiksmatchning starter fra begynnelsen**: KV-Cache sammenligner den gjeldende forespørselen med det bufrede prefikset token for token fra starten. I det øyeblikket et avvik oppdages, ugyldiggjøres alt etterfølgende innhold.
|
|
24
|
+
|
|
25
|
+
2. **Tools endres = hele cachen ugyldiggjøres**: Siden Tools kommer først, vil enhver endring i verktøydefinisjoner (selv å legge til eller fjerne ett enkelt MCP-tool) **bryte prefikset helt fra starten**, og ugyldiggjøre all bufret System Prompt og Messages.
|
|
26
|
+
|
|
27
|
+
3. **System endres = Messages-cache ugyldiggjøres**: System Prompt befinner seg i midten, så dens endringer ugyldiggjør bare den etterfølgende Messages-delen.
|
|
28
|
+
|
|
29
|
+
4. **Messages endres = bare halen påvirkes**: Messages er på slutten, så å legge til nye meldinger ugyldiggjør bare et lite avsluttende segment — cache for Tools og System forblir intakt.
|
|
30
|
+
|
|
31
|
+
## Praktisk betydning
|
|
32
|
+
|
|
33
|
+
| Endringstype | Cache-påvirkning | Typisk scenario |
|
|
34
|
+
|--------------|-----------------|-----------------|
|
|
35
|
+
| Tool lagt til/fjernet | **Full ugyldiggjøring** | MCP server tilkobling/frakobling, IDE-plugin av/på |
|
|
36
|
+
| System Prompt-endring | Messages-cache tapt | CLAUDE.md-redigering, system reminder-injeksjon |
|
|
37
|
+
| Ny melding lagt til | Bare hale-inkrement | Normal samtaleflyt (vanligst, billigst) |
|
|
38
|
+
|
|
39
|
+
Dette er grunnen til at `tools_change` i [CacheRebuild](CacheRebuild.md) typisk er den dyreste gjenoppbyggingsårsaken — den bryter prefikskjeden helt fremst.
|
|
40
|
+
|
|
41
|
+
## cc-viewers layoutdesign
|
|
42
|
+
|
|
43
|
+
cc-viewer arrangerer kontekstpanelet slik at det matcher KV-Cache-prefiks-sekvensen:
|
|
44
|
+
|
|
45
|
+
- **Rekkefølge fra topp til bunn = cache-prefiks-sammensettingsrekkefølge**
|
|
46
|
+
- **Endringer høyere opp har større innvirkning på cache-hitrate**
|
|
47
|
+
- Kombinert med [KV-Cache-Text](KVCacheContent.md)-panelet kan du se den fullstendige cache-prefiks-teksten direkte
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Dlaczego Tools są wyświetlane jako pierwsze?
|
|
2
|
+
|
|
3
|
+
W panelu kontekstu cc-viewer **Tools pojawiają się przed System Prompt i Messages**. Ta kolejność dokładnie odzwierciedla **sekwencję prefiksu KV-Cache w Anthropic API**.
|
|
4
|
+
|
|
5
|
+
## Sekwencja prefiksu KV-Cache
|
|
6
|
+
|
|
7
|
+
Gdy Anthropic API buduje KV-Cache, łączy kontekst w prefiks w tej **stałej kolejności**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Oznacza to, że **Tools znajdują się przed System Prompt na samym początku prefiksu cache**.
|
|
18
|
+
|
|
19
|
+
## Dlaczego Tools mają większy wpływ na cache niż System?
|
|
20
|
+
|
|
21
|
+
W dopasowywaniu prefiksu KV-Cache **wcześniejsza treść jest bardziej krytyczna** — każda zmiana unieważnia wszystko, co po niej następuje:
|
|
22
|
+
|
|
23
|
+
1. **Dopasowywanie prefiksu zaczyna się od początku**: KV-Cache porównuje bieżące żądanie z zbuforowanym prefiksem token po tokenie od początku. W momencie znalezienia niezgodności cała późniejsza treść zostaje unieważniona.
|
|
24
|
+
|
|
25
|
+
2. **Zmiana Tools = cały cache unieważniony**: Ponieważ Tools są na pierwszym miejscu, każda zmiana w definicjach narzędzi (nawet dodanie lub usunięcie jednego MCP tool) **przerywa prefiks od samego początku**, unieważniając cały zbuforowany System Prompt i Messages.
|
|
26
|
+
|
|
27
|
+
3. **Zmiana System = cache Messages unieważniony**: System Prompt znajduje się w środku, więc jego zmiany unieważniają tylko następującą po nim część Messages.
|
|
28
|
+
|
|
29
|
+
4. **Zmiana Messages = dotyczy tylko końca**: Messages są na końcu, więc dołączanie nowych wiadomości unieważnia jedynie niewielki końcowy segment — cache Tools i System pozostaje nienaruszony.
|
|
30
|
+
|
|
31
|
+
## Praktyczny wpływ
|
|
32
|
+
|
|
33
|
+
| Typ zmiany | Wpływ na cache | Typowy scenariusz |
|
|
34
|
+
|------------|---------------|-------------------|
|
|
35
|
+
| Tool dodane/usunięte | **Pełne unieważnienie** | Połączenie/rozłączenie serwera MCP, włączenie/wyłączenie wtyczki IDE |
|
|
36
|
+
| Zmiana System Prompt | Utrata cache Messages | Edycja CLAUDE.md, wstrzyknięcie system reminder |
|
|
37
|
+
| Nowa wiadomość dodana | Tylko przyrost końcowy | Normalny przepływ rozmowy (najczęstszy, najtańszy) |
|
|
38
|
+
|
|
39
|
+
Dlatego `tools_change` w [CacheRebuild](CacheRebuild.md) jest zazwyczaj najdroższym powodem przebudowy — przerywa łańcuch prefiksu na samym początku.
|
|
40
|
+
|
|
41
|
+
## Projekt układu cc-viewer
|
|
42
|
+
|
|
43
|
+
cc-viewer rozmieszcza panel kontekstu tak, aby odpowiadał sekwencji prefiksu KV-Cache:
|
|
44
|
+
|
|
45
|
+
- **Kolejność od góry do dołu = kolejność łączenia prefiksu cache**
|
|
46
|
+
- **Zmiany wyżej mają większy wpływ na współczynnik trafień cache**
|
|
47
|
+
- W połączeniu z panelem [KV-Cache-Text](KVCacheContent.md) możesz bezpośrednio zobaczyć pełny tekst prefiksu cache
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Por que os Tools são listados primeiro?
|
|
2
|
+
|
|
3
|
+
No painel Context do cc-viewer, **os Tools aparecem antes do System Prompt e dos Messages**. Essa ordenação reflete precisamente a **sequência de prefixo KV-Cache da API da Anthropic**.
|
|
4
|
+
|
|
5
|
+
## Sequência de prefixo KV-Cache
|
|
6
|
+
|
|
7
|
+
Quando a API da Anthropic constrói o KV-Cache, ela concatena o contexto em um prefixo nesta **ordem fixa**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Isso significa que **os Tools ficam antes do System Prompt, bem no início do prefixo de cache**.
|
|
18
|
+
|
|
19
|
+
## Por que os Tools têm maior peso de cache do que System?
|
|
20
|
+
|
|
21
|
+
Na correspondência de prefixo KV-Cache, **o conteúdo anterior é mais crítico** — qualquer alteração invalida tudo o que vem depois:
|
|
22
|
+
|
|
23
|
+
1. **A correspondência de prefixo começa pelo início**: O KV-Cache compara a requisição atual com o prefixo em cache token por token desde o início. No momento em que uma divergência é encontrada, todo o conteúdo subsequente é invalidado.
|
|
24
|
+
|
|
25
|
+
2. **Alteração nos Tools = cache inteiro invalidado**: Como os Tools vêm primeiro, qualquer alteração nas definições de tool (mesmo adicionar ou remover um único MCP tool) **quebra o prefixo desde o início absoluto**, invalidando todos os System Prompt e Messages em cache.
|
|
26
|
+
|
|
27
|
+
3. **Alteração no System = cache de Messages invalidado**: O System Prompt fica no meio, então suas alterações invalidam apenas a porção de Messages que o segue.
|
|
28
|
+
|
|
29
|
+
4. **Alteração nos Messages = apenas o final é afetado**: Os Messages ficam no final, então adicionar novos messages invalida apenas um pequeno segmento final — os caches de Tools e System permanecem intactos.
|
|
30
|
+
|
|
31
|
+
## Impacto prático
|
|
32
|
+
|
|
33
|
+
| Tipo de alteração | Impacto no cache | Cenário típico |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool adicionado/removido | **Invalidação completa** | Conexão/desconexão de servidor MCP, ativação/desativação de plugin de IDE |
|
|
36
|
+
| Alteração no System Prompt | Cache de Messages perdido | Edição de CLAUDE.md, injeção de system reminder |
|
|
37
|
+
| Novo message adicionado | Apenas incremento de cauda | Fluxo de conversa normal (o mais comum, o mais barato) |
|
|
38
|
+
|
|
39
|
+
É por isso que `tools_change` no [CacheRebuild](CacheRebuild.md) tende a ser o motivo de reconstrução mais custoso — ele quebra a cadeia de prefixo bem na frente.
|
|
40
|
+
|
|
41
|
+
## Design de layout do cc-viewer
|
|
42
|
+
|
|
43
|
+
O cc-viewer organiza o painel Context para corresponder à sequência de prefixo KV-Cache:
|
|
44
|
+
|
|
45
|
+
- **Ordem de cima para baixo = ordem de concatenação do prefixo de cache**
|
|
46
|
+
- **Alterações mais acima têm maior impacto na taxa de acerto do cache**
|
|
47
|
+
- Combinado com o painel [KV-Cache-Text](KVCacheContent.md), você pode ver diretamente o texto completo do prefixo de cache
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Почему Tools перечислены первыми?
|
|
2
|
+
|
|
3
|
+
В панели Context в cc-viewer **Tools отображаются раньше System Prompt и Messages**. Этот порядок точно отражает **последовательность префикса KV-Cache API Anthropic**.
|
|
4
|
+
|
|
5
|
+
## Последовательность префикса KV-Cache
|
|
6
|
+
|
|
7
|
+
Когда API Anthropic формирует KV-Cache, он объединяет контекст в префикс в следующем **фиксированном порядке**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────┐
|
|
11
|
+
│ 1. Tools (JSON Schema definitions) │ ← Start of cache prefix
|
|
12
|
+
│ 2. System Prompt │
|
|
13
|
+
│ 3. Messages (conversation history + current turn)│ ← End of cache prefix
|
|
14
|
+
└─────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Это означает, что **Tools находятся перед System Prompt, в самом начале префикса кэша**.
|
|
18
|
+
|
|
19
|
+
## Почему Tools имеют больший вес в кэше, чем System?
|
|
20
|
+
|
|
21
|
+
При сопоставлении префиксов KV-Cache **более ранний контент является более критичным** — любое изменение делает недействительным всё, что следует после:
|
|
22
|
+
|
|
23
|
+
1. **Сопоставление префикса начинается с самого начала**: KV-Cache сравнивает текущий запрос с кэшированным префиксом token за token с начала. Как только обнаруживается несоответствие, весь последующий контент становится недействительным.
|
|
24
|
+
|
|
25
|
+
2. **Изменение Tools = весь кэш недействителен**: Поскольку Tools стоят первыми, любое изменение определений tool (даже добавление или удаление одного MCP tool) **нарушает префикс с самого начала**, делая недействительными все кэшированные System Prompt и Messages.
|
|
26
|
+
|
|
27
|
+
3. **Изменение System = кэш Messages недействителен**: System Prompt находится посередине, поэтому его изменения делают недействительной только следующую за ним часть Messages.
|
|
28
|
+
|
|
29
|
+
4. **Изменение Messages = затронут только хвост**: Messages находятся в конце, поэтому добавление новых messages делает недействительным лишь небольшой хвостовой сегмент — кэши Tools и System остаются нетронутыми.
|
|
30
|
+
|
|
31
|
+
## Практическое влияние
|
|
32
|
+
|
|
33
|
+
| Тип изменения | Влияние на кэш | Типичный сценарий |
|
|
34
|
+
|-------------|-------------|-----------------|
|
|
35
|
+
| Tool добавлен/удалён | **Полная инвалидация** | Подключение/отключение сервера MCP, включение/выключение плагина IDE |
|
|
36
|
+
| Изменение System Prompt | Кэш Messages утерян | Редактирование CLAUDE.md, внедрение system reminder |
|
|
37
|
+
| Добавлено новое message | Только хвостовой инкремент | Обычный ход разговора (самый частый, самый дешёвый) |
|
|
38
|
+
|
|
39
|
+
Вот почему `tools_change` в [CacheRebuild](CacheRebuild.md) как правило является наиболее дорогостоящей причиной перестройки — она нарушает цепочку префикса с самого начала.
|
|
40
|
+
|
|
41
|
+
## Дизайн макета cc-viewer
|
|
42
|
+
|
|
43
|
+
cc-viewer организует панель Context в соответствии с последовательностью префикса KV-Cache:
|
|
44
|
+
|
|
45
|
+
- **Порядок сверху вниз = порядок объединения префикса кэша**
|
|
46
|
+
- **Изменения выше имеют большее влияние на показатель попаданий в кэш**
|
|
47
|
+
- В сочетании с панелью [KV-Cache-Text](KVCacheContent.md) вы можете напрямую увидеть полный текст префикса кэша
|