agent-cost-analyzer 0.0.0 → 0.16.1
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/LICENSE +21 -0
- package/README.md +72 -5
- package/THIRD-PARTY-NOTICES.md +3510 -0
- package/bin/agent-cost-analyzer.js +22 -0
- package/bin/node-gate.js +41 -0
- package/dist/cli.js +315313 -0
- package/dist/data/learn-scripts/cache-basics.json +163 -0
- package/dist/data/learn-scripts/cache-ttl-1-hour-breakpoint.json +176 -0
- package/dist/data/learn-scripts/cache-ttl-smoke-break.json +190 -0
- package/dist/data/learn-scripts/cascading-model-switch-then-ttl-lapse.json +121 -0
- package/dist/data/learn-scripts/clear.json +133 -0
- package/dist/data/learn-scripts/compaction.json +98 -0
- package/dist/data/learn-scripts/image-attachment-invalidation.json +108 -0
- package/dist/data/learn-scripts/inline-exploration-bloat.json +115 -0
- package/dist/data/learn-scripts/instructions-edit.json +99 -0
- package/dist/data/learn-scripts/mcp-tool-change.json +93 -0
- package/dist/data/learn-scripts/model-switch.json +88 -0
- package/dist/data/learn-scripts/reasoning-budget-toggle.json +98 -0
- package/dist/data/learn-scripts/rewind.json +139 -0
- package/dist/data/learn-scripts/session-forking-multi-branch.json +124 -0
- package/dist/data/learn-scripts/session-forking.json +99 -0
- package/dist/data/learn-scripts/silent-instructions-pullin.json +104 -0
- package/dist/data/learn-scripts/subagent-cheaper-model.json +70 -0
- package/dist/data/learn-scripts/subagent-session.json +70 -0
- package/dist/data/price-book/anthropic-api.json +662 -0
- package/dist/data/price-book/github-copilot.json +1402 -0
- package/dist/data/price-book/google-api.json +507 -0
- package/dist/data/price-book/openai-api.json +1184 -0
- package/dist/data/vendor-profiles/anthropic.json +568 -0
- package/dist/data/vendor-profiles/google.json +190 -0
- package/dist/data/vendor-profiles/microsoft.json +96 -0
- package/dist/data/vendor-profiles/moonshot.json +115 -0
- package/dist/data/vendor-profiles/openai.json +442 -0
- package/dist/data/vendor-profiles/xai.json +217 -0
- package/dist/mcp-apps/views.html +124 -0
- package/dist/web/assets/commit-mono-latin-400-normal-s0S3qwFW.woff +0 -0
- package/dist/web/assets/commit-mono-latin-400-normal-wzhe4RuD.woff2 +0 -0
- package/dist/web/assets/commit-mono-latin-700-normal-1-GU0IUE.woff +0 -0
- package/dist/web/assets/commit-mono-latin-700-normal-DU8mrtj2.woff2 +0 -0
- package/dist/web/assets/index-DeqVluBu.js +76 -0
- package/dist/web/assets/index-EJpifWDV.css +1 -0
- package/dist/web/assets/source-serif-4-latin-400-normal-C1O10bxN.woff +0 -0
- package/dist/web/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- package/dist/web/assets/source-serif-4-latin-600-normal-DeJomR3S.woff +0 -0
- package/dist/web/assets/source-serif-4-latin-600-normal-DouSKlru.woff2 +0 -0
- package/dist/web/index.html +32 -0
- package/package.json +18 -4
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "model-switch",
|
|
3
|
+
"title": "Model Switch Mid-Session",
|
|
4
|
+
"category": "Model switching",
|
|
5
|
+
"harnesses": ["vscode-local", "copilot-agent-host", "claude-code"],
|
|
6
|
+
"sessionKind": "main",
|
|
7
|
+
"staticPrefix": {
|
|
8
|
+
"toolsTokens": 1200,
|
|
9
|
+
"systemTokens": 1800
|
|
10
|
+
},
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"index": 1,
|
|
14
|
+
"userMessage": "Let's plan out the caching layer for the API.",
|
|
15
|
+
"assistantResponse": "Sure, exploring the code to plan it out.",
|
|
16
|
+
"toolCalls": [],
|
|
17
|
+
"explanation": "Normal first turn on the starting model: writes the static prefix plus this turn's own content; nothing to read yet.",
|
|
18
|
+
"newContent": {
|
|
19
|
+
"userTokens": 500,
|
|
20
|
+
"toolResultTokens": 0,
|
|
21
|
+
"reasoningTokens": 150,
|
|
22
|
+
"outputTokens": 150
|
|
23
|
+
},
|
|
24
|
+
"events": []
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"index": 2,
|
|
28
|
+
"userMessage": "Sounds good, go ahead.",
|
|
29
|
+
"assistantResponse": "Continuing with the plan.",
|
|
30
|
+
"toolCalls": [],
|
|
31
|
+
"explanation": "Normal turn that reuses and extends the starting model's cache.",
|
|
32
|
+
"newContent": {
|
|
33
|
+
"userTokens": 200,
|
|
34
|
+
"toolResultTokens": 0,
|
|
35
|
+
"reasoningTokens": 120,
|
|
36
|
+
"outputTokens": 180
|
|
37
|
+
},
|
|
38
|
+
"events": []
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"index": 3,
|
|
42
|
+
"userMessage": "Actually, switch to the more capable model for this next part.",
|
|
43
|
+
"assistantResponse": "Switching models now and continuing with the full context.",
|
|
44
|
+
"toolCalls": [],
|
|
45
|
+
"explanation": "Model switch: prompt caches are scoped per model, so the first model's cache is worthless to the new one. The whole prior history plus the new message is sent as uncached input and the new model writes its own first cache entry. The new model's prices apply from here on.",
|
|
46
|
+
"newContent": {
|
|
47
|
+
"userTokens": 150,
|
|
48
|
+
"toolResultTokens": 0,
|
|
49
|
+
"reasoningTokens": 250,
|
|
50
|
+
"outputTokens": 300
|
|
51
|
+
},
|
|
52
|
+
"events": [
|
|
53
|
+
{
|
|
54
|
+
"type": "model-switch",
|
|
55
|
+
"toRole": "primary"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"index": 4,
|
|
61
|
+
"userMessage": "Continue.",
|
|
62
|
+
"assistantResponse": "Continuing under the new model.",
|
|
63
|
+
"toolCalls": [],
|
|
64
|
+
"explanation": "Behaves like a normal, healthy cache-building turn again, now under the new model's cache and prices.",
|
|
65
|
+
"newContent": {
|
|
66
|
+
"userTokens": 120,
|
|
67
|
+
"toolResultTokens": 0,
|
|
68
|
+
"reasoningTokens": 150,
|
|
69
|
+
"outputTokens": 200
|
|
70
|
+
},
|
|
71
|
+
"events": []
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"index": 5,
|
|
75
|
+
"userMessage": "Great, thanks.",
|
|
76
|
+
"assistantResponse": "You're welcome.",
|
|
77
|
+
"toolCalls": [],
|
|
78
|
+
"explanation": "The cache keeps growing normally under the new model, with no further disruption.",
|
|
79
|
+
"newContent": {
|
|
80
|
+
"userTokens": 80,
|
|
81
|
+
"toolResultTokens": 0,
|
|
82
|
+
"reasoningTokens": 90,
|
|
83
|
+
"outputTokens": 140
|
|
84
|
+
},
|
|
85
|
+
"events": []
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "reasoning-budget-toggle",
|
|
3
|
+
"title": "Toggling Extended Thinking Mid-Session",
|
|
4
|
+
"category": "Reasoning settings",
|
|
5
|
+
"harnesses": ["vscode-local", "copilot-agent-host", "claude-code"],
|
|
6
|
+
"sessionKind": "main",
|
|
7
|
+
"staticPrefix": {
|
|
8
|
+
"toolsTokens": 1800,
|
|
9
|
+
"systemTokens": 1200
|
|
10
|
+
},
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"index": 1,
|
|
14
|
+
"userMessage": "Let's design the retry logic for the payment webhook handler.",
|
|
15
|
+
"assistantResponse": "Sure, looking at the current webhook handler.",
|
|
16
|
+
"toolCalls": [],
|
|
17
|
+
"explanation": "Normal first turn: writes the static prefix plus this turn's own content. Extended thinking is off, so reasoning stays at its normal baseline.",
|
|
18
|
+
"newContent": {
|
|
19
|
+
"userTokens": 800,
|
|
20
|
+
"toolResultTokens": 0,
|
|
21
|
+
"reasoningTokens": 150,
|
|
22
|
+
"outputTokens": 150
|
|
23
|
+
},
|
|
24
|
+
"events": []
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"index": 2,
|
|
28
|
+
"userMessage": "It should use exponential backoff with jitter.",
|
|
29
|
+
"assistantResponse": "Got it, planning exponential backoff with jitter.",
|
|
30
|
+
"toolCalls": [],
|
|
31
|
+
"explanation": "Normal turn reusing and extending the cache.",
|
|
32
|
+
"newContent": {
|
|
33
|
+
"userTokens": 150,
|
|
34
|
+
"toolResultTokens": 0,
|
|
35
|
+
"reasoningTokens": 120,
|
|
36
|
+
"outputTokens": 180
|
|
37
|
+
},
|
|
38
|
+
"events": []
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"index": 3,
|
|
42
|
+
"userMessage": "This retry logic has a lot of edge cases — turn on extended thinking for this part.",
|
|
43
|
+
"assistantResponse": "Switching to extended thinking mode for this design.",
|
|
44
|
+
"toolCalls": [],
|
|
45
|
+
"explanation": "Enabling extended thinking changes the request itself, which invalidates the conversation cache. Reasoning tokens also jump while the model spends a much larger budget deliberating.",
|
|
46
|
+
"newContent": {
|
|
47
|
+
"userTokens": 100,
|
|
48
|
+
"toolResultTokens": 0,
|
|
49
|
+
"reasoningTokens": 900,
|
|
50
|
+
"outputTokens": 250
|
|
51
|
+
},
|
|
52
|
+
"events": [
|
|
53
|
+
{
|
|
54
|
+
"type": "thinking-changed",
|
|
55
|
+
"enabled": true
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"index": 4,
|
|
61
|
+
"userMessage": "Good — now write the code.",
|
|
62
|
+
"assistantResponse": "Writing the retry logic now.",
|
|
63
|
+
"toolCalls": [
|
|
64
|
+
{
|
|
65
|
+
"name": "replace_string_in_file",
|
|
66
|
+
"argsSummary": "src/webhooks/payment-retry.ts"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"explanation": "Normal turn under the new, still elevated reasoning budget; the cache rebuilds under the current settings.",
|
|
70
|
+
"newContent": {
|
|
71
|
+
"userTokens": 100,
|
|
72
|
+
"toolResultTokens": 200,
|
|
73
|
+
"reasoningTokens": 400,
|
|
74
|
+
"outputTokens": 220
|
|
75
|
+
},
|
|
76
|
+
"events": []
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"index": 5,
|
|
80
|
+
"userMessage": "That's solid — turn extended thinking back off, we're done with the tricky part.",
|
|
81
|
+
"assistantResponse": "Turning extended thinking back off.",
|
|
82
|
+
"toolCalls": [],
|
|
83
|
+
"explanation": "Turning extended thinking back off invalidates the cache again, in the same way: any change to the thinking setting alters the request, in either direction. Toggling mid-task costs a full miss twice.",
|
|
84
|
+
"newContent": {
|
|
85
|
+
"userTokens": 100,
|
|
86
|
+
"toolResultTokens": 0,
|
|
87
|
+
"reasoningTokens": 100,
|
|
88
|
+
"outputTokens": 120
|
|
89
|
+
},
|
|
90
|
+
"events": [
|
|
91
|
+
{
|
|
92
|
+
"type": "thinking-changed",
|
|
93
|
+
"enabled": false
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "rewind",
|
|
3
|
+
"title": "/rewind (or Editing a Previous Turn)",
|
|
4
|
+
"category": "Rewind",
|
|
5
|
+
"harnesses": ["vscode-local", "copilot-agent-host", "claude-code"],
|
|
6
|
+
"sessionKind": "main",
|
|
7
|
+
"staticPrefix": {
|
|
8
|
+
"toolsTokens": 1800,
|
|
9
|
+
"systemTokens": 1200
|
|
10
|
+
},
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"index": 1,
|
|
14
|
+
"userMessage": "Let's fix the broken checkout flow.",
|
|
15
|
+
"assistantResponse": "Sure, looking into the checkout flow now.",
|
|
16
|
+
"toolCalls": [],
|
|
17
|
+
"explanation": "Normal first turn: the static prefix and this turn's own content are written to the cache.",
|
|
18
|
+
"newContent": {
|
|
19
|
+
"userTokens": 1000,
|
|
20
|
+
"toolResultTokens": 0,
|
|
21
|
+
"reasoningTokens": 150,
|
|
22
|
+
"outputTokens": 150
|
|
23
|
+
},
|
|
24
|
+
"events": []
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"index": 2,
|
|
28
|
+
"userMessage": "The error happens right after the payment step.",
|
|
29
|
+
"assistantResponse": "Got it, focusing on the code that runs right after payment.",
|
|
30
|
+
"toolCalls": [
|
|
31
|
+
{
|
|
32
|
+
"name": "read_file",
|
|
33
|
+
"argsSummary": "src/checkout/payment.ts"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"explanation": "Normal turn: reads the cached prefix and extends it with the new content.",
|
|
37
|
+
"newContent": {
|
|
38
|
+
"userTokens": 50,
|
|
39
|
+
"toolResultTokens": 100,
|
|
40
|
+
"reasoningTokens": 120,
|
|
41
|
+
"outputTokens": 180
|
|
42
|
+
},
|
|
43
|
+
"events": []
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"index": 3,
|
|
47
|
+
"userMessage": "Go ahead and fix it.",
|
|
48
|
+
"assistantResponse": "Editing the shipping-calculation module to fix the checkout error.",
|
|
49
|
+
"toolCalls": [
|
|
50
|
+
{
|
|
51
|
+
"name": "replace_string_in_file",
|
|
52
|
+
"argsSummary": "src/checkout/shipping.ts (wrong file — misread the stack trace)"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"explanation": "Wrong path: a misread stack trace sends the model to edit the wrong file. This turn's AI Credits are already billed and will not be refunded when it is rewound away.",
|
|
56
|
+
"newContent": {
|
|
57
|
+
"userTokens": 500,
|
|
58
|
+
"toolResultTokens": 1200,
|
|
59
|
+
"reasoningTokens": 200,
|
|
60
|
+
"outputTokens": 180
|
|
61
|
+
},
|
|
62
|
+
"events": []
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"index": 4,
|
|
66
|
+
"userMessage": "/rewind to before that edit — the error is actually in payment.ts, not shipping.ts.",
|
|
67
|
+
"assistantResponse": "Rewound. Editing payment.ts instead, based on the corrected instruction.",
|
|
68
|
+
"toolCalls": [
|
|
69
|
+
{
|
|
70
|
+
"name": "replace_string_in_file",
|
|
71
|
+
"argsSummary": "src/checkout/payment.ts"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"explanation": "The rewind rolls back to the end of the second turn and continues with a corrected instruction. The abandoned step is never read again, so the request resumes from the earlier, smaller prefix, which is still a warm cache hit. The mistaken turn's cost is spent, but it never inflates any later request.",
|
|
75
|
+
"newContent": {
|
|
76
|
+
"userTokens": 360,
|
|
77
|
+
"toolResultTokens": 300,
|
|
78
|
+
"reasoningTokens": 140,
|
|
79
|
+
"outputTokens": 160
|
|
80
|
+
},
|
|
81
|
+
"events": [
|
|
82
|
+
{
|
|
83
|
+
"type": "rewind",
|
|
84
|
+
"toStep": 2
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"index": 5,
|
|
90
|
+
"userMessage": "That looks right, thanks.",
|
|
91
|
+
"assistantResponse": "Glad that fixed it.",
|
|
92
|
+
"toolCalls": [],
|
|
93
|
+
"explanation": "Normal turn on the corrected branch: the mistaken detour never appears in this or any later request.",
|
|
94
|
+
"newContent": {
|
|
95
|
+
"userTokens": 60,
|
|
96
|
+
"toolResultTokens": 0,
|
|
97
|
+
"reasoningTokens": 70,
|
|
98
|
+
"outputTokens": 100
|
|
99
|
+
},
|
|
100
|
+
"events": []
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"textByHarness": {
|
|
104
|
+
"vscode-local": {
|
|
105
|
+
"title": "Restore a checkpoint (or edit a previous request)",
|
|
106
|
+
"userMessages": [
|
|
107
|
+
"Let's fix the broken checkout flow.",
|
|
108
|
+
"The error happens right after the payment step.",
|
|
109
|
+
"Go ahead and fix it.",
|
|
110
|
+
"Restore the checkpoint from before that edit — the error is actually in payment.ts, not shipping.ts.",
|
|
111
|
+
"That looks right, thanks."
|
|
112
|
+
],
|
|
113
|
+
"explanations": [
|
|
114
|
+
"Normal first turn: the static prefix and this turn's own content are written to the cache.",
|
|
115
|
+
"Normal turn: reads the cached prefix and extends it with the new content.",
|
|
116
|
+
"Wrong path: a misread stack trace sends the model to edit the wrong file. This turn's AI Credits are already billed and will not be refunded when it is rewound away.",
|
|
117
|
+
"Restoring the checkpoint (or editing the earlier request and resubmitting) rolls back to the end of the second turn and continues with a corrected instruction. The abandoned step is never read again, so the request resumes from the earlier, smaller prefix, which is still a warm cache hit. The mistaken turn's cost is spent, but it never inflates any later request.",
|
|
118
|
+
"Normal turn on the corrected branch: the mistaken detour never appears in this or any later request."
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
"copilot-agent-host": {
|
|
122
|
+
"title": "Restore a checkpoint (or edit a previous request)",
|
|
123
|
+
"userMessages": [
|
|
124
|
+
"Let's fix the broken checkout flow.",
|
|
125
|
+
"The error happens right after the payment step.",
|
|
126
|
+
"Go ahead and fix it.",
|
|
127
|
+
"Restore the checkpoint from before that edit — the error is actually in payment.ts, not shipping.ts.",
|
|
128
|
+
"That looks right, thanks."
|
|
129
|
+
],
|
|
130
|
+
"explanations": [
|
|
131
|
+
"Normal first turn: the static prefix and this turn's own content are written to the cache.",
|
|
132
|
+
"Normal turn: reads the cached prefix and extends it with the new content.",
|
|
133
|
+
"Wrong path: a misread stack trace sends the model to edit the wrong file. This turn's AI Credits are already billed and will not be refunded when it is rewound away.",
|
|
134
|
+
"Restoring the checkpoint (or editing the earlier request and resubmitting) rolls back to the end of the second turn and continues with a corrected instruction. The abandoned step is never read again, so the request resumes from the earlier, smaller prefix, which is still a warm cache hit. The mistaken turn's cost is spent, but it never inflates any later request.",
|
|
135
|
+
"Normal turn on the corrected branch: the mistaken detour never appears in this or any later request."
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "session-forking-multi-branch",
|
|
3
|
+
"title": "Forking Twice: A Nested Branch from Within a Branch",
|
|
4
|
+
"category": "Forking",
|
|
5
|
+
"harnesses": ["vscode-local", "copilot-agent-host", "claude-code"],
|
|
6
|
+
"sessionKind": "main",
|
|
7
|
+
"staticPrefix": {
|
|
8
|
+
"toolsTokens": 1800,
|
|
9
|
+
"systemTokens": 1200
|
|
10
|
+
},
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"index": 1,
|
|
14
|
+
"userMessage": "Let's plan out the caching layer for the API.",
|
|
15
|
+
"assistantResponse": "Sure, exploring the code to plan it out.",
|
|
16
|
+
"toolCalls": [],
|
|
17
|
+
"explanation": "Normal first turn: writes the static prefix plus this turn's own content. This starts the shared trunk every branch inherits.",
|
|
18
|
+
"newContent": {
|
|
19
|
+
"userTokens": 800,
|
|
20
|
+
"toolResultTokens": 0,
|
|
21
|
+
"reasoningTokens": 150,
|
|
22
|
+
"outputTokens": 150
|
|
23
|
+
},
|
|
24
|
+
"events": []
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"index": 2,
|
|
28
|
+
"userMessage": "Sounds good, go ahead.",
|
|
29
|
+
"assistantResponse": "Continuing with the plan.",
|
|
30
|
+
"toolCalls": [
|
|
31
|
+
{
|
|
32
|
+
"name": "read_file",
|
|
33
|
+
"argsSummary": "src/api/handlers.ts"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"explanation": "Normal turn on the shared trunk; reads and extends the cache from the first turn.",
|
|
37
|
+
"newContent": {
|
|
38
|
+
"userTokens": 150,
|
|
39
|
+
"toolResultTokens": 100,
|
|
40
|
+
"reasoningTokens": 120,
|
|
41
|
+
"outputTokens": 180
|
|
42
|
+
},
|
|
43
|
+
"events": []
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"index": 3,
|
|
47
|
+
"userMessage": "I want to compare two caching strategies before committing to one \u2014 fork here so we can try both.",
|
|
48
|
+
"assistantResponse": "Forking the session here. I'll try a Redis-based approach in one branch and an in-memory LRU approach in the other.",
|
|
49
|
+
"toolCalls": [],
|
|
50
|
+
"explanation": "First fork point: a second, independent continuation starts from this exact prefix. This branch carries on, and may fork again later.",
|
|
51
|
+
"newContent": {
|
|
52
|
+
"userTokens": 120,
|
|
53
|
+
"toolResultTokens": 0,
|
|
54
|
+
"reasoningTokens": 140,
|
|
55
|
+
"outputTokens": 160
|
|
56
|
+
},
|
|
57
|
+
"events": []
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"index": 4,
|
|
61
|
+
"userMessage": "(Branch A) Try the Redis-based caching strategy.",
|
|
62
|
+
"assistantResponse": "Implementing a Redis-based caching strategy.",
|
|
63
|
+
"toolCalls": [
|
|
64
|
+
{
|
|
65
|
+
"name": "replace_string_in_file",
|
|
66
|
+
"argsSummary": "add Redis-backed cache client to src/api/cache.ts"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"explanation": "Reads the shared trunk as a cache hit, then diverges with its own content. The other branch reads the same trunk independently.",
|
|
70
|
+
"newContent": {
|
|
71
|
+
"userTokens": 150,
|
|
72
|
+
"toolResultTokens": 500,
|
|
73
|
+
"reasoningTokens": 160,
|
|
74
|
+
"outputTokens": 190
|
|
75
|
+
},
|
|
76
|
+
"events": [
|
|
77
|
+
{
|
|
78
|
+
"type": "fork",
|
|
79
|
+
"branch": "B",
|
|
80
|
+
"fromStep": 3
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"index": 5,
|
|
86
|
+
"userMessage": "(Branch A) Before finalizing, let's fork again here to compare write-through vs write-back caching for the Redis layer.",
|
|
87
|
+
"assistantResponse": "Forking again from this point \u2014 I'll try write-through in one branch and write-back in the other.",
|
|
88
|
+
"toolCalls": [],
|
|
89
|
+
"explanation": "A second fork, from inside this branch. The nested fork point is itself a shared trunk for two new sub-branches, with the same mechanics one level deeper; the first fork's branch is unaffected.",
|
|
90
|
+
"newContent": {
|
|
91
|
+
"userTokens": 140,
|
|
92
|
+
"toolResultTokens": 0,
|
|
93
|
+
"reasoningTokens": 130,
|
|
94
|
+
"outputTokens": 150
|
|
95
|
+
},
|
|
96
|
+
"events": []
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"index": 6,
|
|
100
|
+
"userMessage": "(Branch A.1 \u2014 write-through) Implement the write-through variant.",
|
|
101
|
+
"assistantResponse": "Implementing the write-through caching variant.",
|
|
102
|
+
"toolCalls": [
|
|
103
|
+
{
|
|
104
|
+
"name": "replace_string_in_file",
|
|
105
|
+
"argsSummary": "src/api/cache.ts (write-through variant)"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"explanation": "Reads the full nested trunk as a cache hit, then diverges with its own content. The parallel sub-branch reads the same trunk independently, so the trunk is paid for once, not once per branch.",
|
|
109
|
+
"newContent": {
|
|
110
|
+
"userTokens": 90,
|
|
111
|
+
"toolResultTokens": 300,
|
|
112
|
+
"reasoningTokens": 100,
|
|
113
|
+
"outputTokens": 140
|
|
114
|
+
},
|
|
115
|
+
"events": [
|
|
116
|
+
{
|
|
117
|
+
"type": "fork",
|
|
118
|
+
"branch": "A.2",
|
|
119
|
+
"fromStep": 5
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "session-forking",
|
|
3
|
+
"title": "Session Forking",
|
|
4
|
+
"category": "Forking",
|
|
5
|
+
"harnesses": ["vscode-local", "copilot-agent-host", "claude-code"],
|
|
6
|
+
"sessionKind": "main",
|
|
7
|
+
"staticPrefix": {
|
|
8
|
+
"toolsTokens": 1800,
|
|
9
|
+
"systemTokens": 1200
|
|
10
|
+
},
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"index": 1,
|
|
14
|
+
"userMessage": "Let's plan out the caching layer for the API.",
|
|
15
|
+
"assistantResponse": "Sure, exploring the code to plan it out.",
|
|
16
|
+
"toolCalls": [],
|
|
17
|
+
"explanation": "Normal first turn: writes the static prefix and this turn's own content. This is the start of the shared trunk both branches inherit.",
|
|
18
|
+
"newContent": {
|
|
19
|
+
"userTokens": 1000,
|
|
20
|
+
"toolResultTokens": 0,
|
|
21
|
+
"reasoningTokens": 150,
|
|
22
|
+
"outputTokens": 150
|
|
23
|
+
},
|
|
24
|
+
"events": []
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"index": 2,
|
|
28
|
+
"userMessage": "Sounds good, go ahead.",
|
|
29
|
+
"assistantResponse": "Continuing with the plan.",
|
|
30
|
+
"toolCalls": [
|
|
31
|
+
{
|
|
32
|
+
"name": "read_file",
|
|
33
|
+
"argsSummary": "src/api/handlers.ts"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"explanation": "Normal turn on the shared trunk: reads and extends the cache built by the first turn.",
|
|
37
|
+
"newContent": {
|
|
38
|
+
"userTokens": 50,
|
|
39
|
+
"toolResultTokens": 100,
|
|
40
|
+
"reasoningTokens": 120,
|
|
41
|
+
"outputTokens": 180
|
|
42
|
+
},
|
|
43
|
+
"events": []
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"index": 3,
|
|
47
|
+
"userMessage": "I want to compare two caching strategies before committing to one — fork here so we can try both.",
|
|
48
|
+
"assistantResponse": "Forking the session here. I'll try a Redis-based approach in one branch and an in-memory LRU approach in the other.",
|
|
49
|
+
"toolCalls": [],
|
|
50
|
+
"explanation": "Fork point: the user decides to compare two strategies. Nothing is invalidated; the next step starts a second, independent continuation from this exact prefix.",
|
|
51
|
+
"newContent": {
|
|
52
|
+
"userTokens": 360,
|
|
53
|
+
"toolResultTokens": 0,
|
|
54
|
+
"reasoningTokens": 140,
|
|
55
|
+
"outputTokens": 160
|
|
56
|
+
},
|
|
57
|
+
"events": []
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"index": 4,
|
|
61
|
+
"userMessage": "(Branch A) Try the Redis-based caching strategy.",
|
|
62
|
+
"assistantResponse": "Implementing a Redis-based caching strategy.",
|
|
63
|
+
"toolCalls": [
|
|
64
|
+
{
|
|
65
|
+
"name": "replace_string_in_file",
|
|
66
|
+
"argsSummary": "add Redis-backed cache client to src/api/cache.ts"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"explanation": "Branch A reads the shared trunk as a cache hit, then diverges with its own content. A parallel branch would read the same trunk independently, and neither branch sees the other's later writes. Forking pays for the trunk once instead of rebuilding it in a second session.",
|
|
70
|
+
"newContent": {
|
|
71
|
+
"userTokens": 270,
|
|
72
|
+
"toolResultTokens": 500,
|
|
73
|
+
"reasoningTokens": 160,
|
|
74
|
+
"outputTokens": 190
|
|
75
|
+
},
|
|
76
|
+
"events": [
|
|
77
|
+
{
|
|
78
|
+
"type": "fork",
|
|
79
|
+
"branch": "A",
|
|
80
|
+
"fromStep": 3
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"index": 5,
|
|
86
|
+
"userMessage": "(Branch A) Looks good, that's the approach we'll go with.",
|
|
87
|
+
"assistantResponse": "Great — the Redis-based caching strategy is in place.",
|
|
88
|
+
"toolCalls": [],
|
|
89
|
+
"explanation": "Normal follow-up in branch A, building on that branch's own cache.",
|
|
90
|
+
"newContent": {
|
|
91
|
+
"userTokens": 30,
|
|
92
|
+
"toolResultTokens": 0,
|
|
93
|
+
"reasoningTokens": 90,
|
|
94
|
+
"outputTokens": 120
|
|
95
|
+
},
|
|
96
|
+
"events": []
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "silent-instructions-pullin",
|
|
3
|
+
"title": "A New File Type Silently Changes the Prompt",
|
|
4
|
+
"category": "Instructions change",
|
|
5
|
+
"harnesses": ["vscode-local", "copilot-agent-host", "claude-code"],
|
|
6
|
+
"sessionKind": "main",
|
|
7
|
+
"staticPrefix": {
|
|
8
|
+
"toolsTokens": 1800,
|
|
9
|
+
"systemTokens": 1200
|
|
10
|
+
},
|
|
11
|
+
"steps": [
|
|
12
|
+
{
|
|
13
|
+
"index": 1,
|
|
14
|
+
"userMessage": "Let's build a new REST endpoint for exporting reports.",
|
|
15
|
+
"assistantResponse": "Sure, looking at the API layer.",
|
|
16
|
+
"toolCalls": [],
|
|
17
|
+
"explanation": "Normal first turn: writes the static system prompt and instructions plus this turn's own content. No path-scoped instruction file applies yet, because no matching file type has been touched.",
|
|
18
|
+
"newContent": {
|
|
19
|
+
"userTokens": 1000,
|
|
20
|
+
"toolResultTokens": 0,
|
|
21
|
+
"reasoningTokens": 150,
|
|
22
|
+
"outputTokens": 150
|
|
23
|
+
},
|
|
24
|
+
"events": []
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"index": 2,
|
|
28
|
+
"userMessage": "Use the existing pagination helper for the export list.",
|
|
29
|
+
"assistantResponse": "Sure, reusing the existing pagination helper.",
|
|
30
|
+
"toolCalls": [
|
|
31
|
+
{
|
|
32
|
+
"name": "read_file",
|
|
33
|
+
"argsSummary": "src/api/pagination.ts"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"explanation": "Normal turn: reads and extends the cache built by the first turn. Still no matching file touched.",
|
|
37
|
+
"newContent": {
|
|
38
|
+
"userTokens": 50,
|
|
39
|
+
"toolResultTokens": 100,
|
|
40
|
+
"reasoningTokens": 120,
|
|
41
|
+
"outputTokens": 180
|
|
42
|
+
},
|
|
43
|
+
"events": []
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"index": 3,
|
|
47
|
+
"userMessage": "Also add a migration for the new export_jobs table.",
|
|
48
|
+
"assistantResponse": "Adding the migration — I'll follow the SQL migration conventions.",
|
|
49
|
+
"toolCalls": [
|
|
50
|
+
{
|
|
51
|
+
"name": "create_file",
|
|
52
|
+
"argsSummary": "migrations/0042_export_jobs.sql"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"explanation": "The first turn to touch a matching file type silently pulls in a path-scoped instruction block that earlier turns never loaded. Nothing in the user's message looks like a configuration change, but the block sits near the top of the prompt, so inserting it breaks the prefix match there and invalidates everything cached after it, including conversation that did not change. The turn carries no visible trigger, which is the danger: it looks ordinary yet costs far more.",
|
|
56
|
+
"newContent": {
|
|
57
|
+
"userTokens": 120,
|
|
58
|
+
"toolResultTokens": 150,
|
|
59
|
+
"reasoningTokens": 210,
|
|
60
|
+
"outputTokens": 200
|
|
61
|
+
},
|
|
62
|
+
"events": [
|
|
63
|
+
{
|
|
64
|
+
"type": "system-changed",
|
|
65
|
+
"deltaTokens": 400,
|
|
66
|
+
"cause": "applyTo"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"index": 4,
|
|
72
|
+
"userMessage": "Add an index on export_jobs.created_at too.",
|
|
73
|
+
"assistantResponse": "Adding the index to the migration.",
|
|
74
|
+
"toolCalls": [
|
|
75
|
+
{
|
|
76
|
+
"name": "replace_string_in_file",
|
|
77
|
+
"argsSummary": "migrations/0042_export_jobs.sql"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"explanation": "Normal turn under the newly included instruction block: the cache rebuilds under the new prefix.",
|
|
81
|
+
"newContent": {
|
|
82
|
+
"userTokens": 60,
|
|
83
|
+
"toolResultTokens": 200,
|
|
84
|
+
"reasoningTokens": 130,
|
|
85
|
+
"outputTokens": 160
|
|
86
|
+
},
|
|
87
|
+
"events": []
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"index": 5,
|
|
91
|
+
"userMessage": "Great, that's everything.",
|
|
92
|
+
"assistantResponse": "Sounds good, let me know if you need anything else.",
|
|
93
|
+
"toolCalls": [],
|
|
94
|
+
"explanation": "The cache keeps growing normally; nothing in the session ever flagged the earlier spike.",
|
|
95
|
+
"newContent": {
|
|
96
|
+
"userTokens": 60,
|
|
97
|
+
"toolResultTokens": 0,
|
|
98
|
+
"reasoningTokens": 70,
|
|
99
|
+
"outputTokens": 100
|
|
100
|
+
},
|
|
101
|
+
"events": []
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|