agent-cost-analyzer 0.0.0-stage → 0.16.0

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -2
  3. package/THIRD-PARTY-NOTICES.md +3510 -0
  4. package/bin/agent-cost-analyzer.js +22 -0
  5. package/bin/node-gate.js +41 -0
  6. package/dist/cli.js +315313 -0
  7. package/dist/data/learn-scripts/cache-basics.json +163 -0
  8. package/dist/data/learn-scripts/cache-ttl-1-hour-breakpoint.json +176 -0
  9. package/dist/data/learn-scripts/cache-ttl-smoke-break.json +190 -0
  10. package/dist/data/learn-scripts/cascading-model-switch-then-ttl-lapse.json +121 -0
  11. package/dist/data/learn-scripts/clear.json +133 -0
  12. package/dist/data/learn-scripts/compaction.json +98 -0
  13. package/dist/data/learn-scripts/image-attachment-invalidation.json +108 -0
  14. package/dist/data/learn-scripts/inline-exploration-bloat.json +115 -0
  15. package/dist/data/learn-scripts/instructions-edit.json +99 -0
  16. package/dist/data/learn-scripts/mcp-tool-change.json +93 -0
  17. package/dist/data/learn-scripts/model-switch.json +88 -0
  18. package/dist/data/learn-scripts/reasoning-budget-toggle.json +98 -0
  19. package/dist/data/learn-scripts/rewind.json +139 -0
  20. package/dist/data/learn-scripts/session-forking-multi-branch.json +124 -0
  21. package/dist/data/learn-scripts/session-forking.json +99 -0
  22. package/dist/data/learn-scripts/silent-instructions-pullin.json +104 -0
  23. package/dist/data/learn-scripts/subagent-cheaper-model.json +70 -0
  24. package/dist/data/learn-scripts/subagent-session.json +70 -0
  25. package/dist/data/price-book/anthropic-api.json +662 -0
  26. package/dist/data/price-book/github-copilot.json +1402 -0
  27. package/dist/data/price-book/google-api.json +507 -0
  28. package/dist/data/price-book/openai-api.json +1184 -0
  29. package/dist/data/vendor-profiles/anthropic.json +568 -0
  30. package/dist/data/vendor-profiles/google.json +190 -0
  31. package/dist/data/vendor-profiles/microsoft.json +96 -0
  32. package/dist/data/vendor-profiles/moonshot.json +115 -0
  33. package/dist/data/vendor-profiles/openai.json +442 -0
  34. package/dist/data/vendor-profiles/xai.json +217 -0
  35. package/dist/mcp-apps/views.html +124 -0
  36. package/dist/web/assets/commit-mono-latin-400-normal-s0S3qwFW.woff +0 -0
  37. package/dist/web/assets/commit-mono-latin-400-normal-wzhe4RuD.woff2 +0 -0
  38. package/dist/web/assets/commit-mono-latin-700-normal-1-GU0IUE.woff +0 -0
  39. package/dist/web/assets/commit-mono-latin-700-normal-DU8mrtj2.woff2 +0 -0
  40. package/dist/web/assets/index-DeqVluBu.js +76 -0
  41. package/dist/web/assets/index-EJpifWDV.css +1 -0
  42. package/dist/web/assets/source-serif-4-latin-400-normal-C1O10bxN.woff +0 -0
  43. package/dist/web/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
  44. package/dist/web/assets/source-serif-4-latin-600-normal-DeJomR3S.woff +0 -0
  45. package/dist/web/assets/source-serif-4-latin-600-normal-DouSKlru.woff2 +0 -0
  46. package/dist/web/index.html +32 -0
  47. package/package.json +23 -4
@@ -0,0 +1,133 @@
1
+ {
2
+ "id": "clear",
3
+ "title": "Claude Code's /clear",
4
+ "category": "Clear",
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 fix the flaky login test.",
15
+ "assistantResponse": "Sure, looking into the flaky login test now.",
16
+ "toolCalls": [],
17
+ "explanation": "Normal first turn: writes the static prefix plus this turn's own content.",
18
+ "newContent": {
19
+ "userTokens": 500,
20
+ "toolResultTokens": 0,
21
+ "reasoningTokens": 150,
22
+ "outputTokens": 150
23
+ },
24
+ "events": []
25
+ },
26
+ {
27
+ "index": 2,
28
+ "userMessage": "It looks like a timing issue in the test setup.",
29
+ "assistantResponse": "Agreed, that lines up with what I'm seeing in the test file.",
30
+ "toolCalls": [
31
+ {
32
+ "name": "read_file",
33
+ "argsSummary": "tests/login.spec.ts"
34
+ }
35
+ ],
36
+ "explanation": "Normal turn that reads and extends the cache built by the first turn.",
37
+ "newContent": {
38
+ "userTokens": 200,
39
+ "toolResultTokens": 100,
40
+ "reasoningTokens": 120,
41
+ "outputTokens": 180
42
+ },
43
+ "events": []
44
+ },
45
+ {
46
+ "index": 3,
47
+ "userMessage": "/clear — let's start something completely different: add rate limiting to the API.",
48
+ "assistantResponse": "Starting fresh. Looking at the API layer to plan rate limiting.",
49
+ "toolCalls": [],
50
+ "explanation": "/clear drops only the conversation history. The static prefix (instructions and tool definitions) is reloaded unchanged and still matches the cache, so it is read rather than rewritten. Nothing is summarised and no extra output is paid: the old turns are simply never sent again.",
51
+ "newContent": {
52
+ "userTokens": 300,
53
+ "toolResultTokens": 0,
54
+ "reasoningTokens": 130,
55
+ "outputTokens": 170
56
+ },
57
+ "events": [
58
+ {
59
+ "type": "clear"
60
+ }
61
+ ]
62
+ },
63
+ {
64
+ "index": 4,
65
+ "userMessage": "Add a token-bucket limiter to the request middleware.",
66
+ "assistantResponse": "Adding a token-bucket rate limiter to the request middleware now.",
67
+ "toolCalls": [
68
+ {
69
+ "name": "replace_string_in_file",
70
+ "argsSummary": "add token-bucket limiter to src/api/middleware.ts"
71
+ }
72
+ ],
73
+ "explanation": "Normal turn on the new task; the cache builds up again from the post-clear baseline, far smaller than the old conversation would have grown to.",
74
+ "newContent": {
75
+ "userTokens": 120,
76
+ "toolResultTokens": 0,
77
+ "reasoningTokens": 90,
78
+ "outputTokens": 110
79
+ },
80
+ "events": []
81
+ },
82
+ {
83
+ "index": 5,
84
+ "userMessage": "Looks good, thanks.",
85
+ "assistantResponse": "Glad it's working well.",
86
+ "toolCalls": [],
87
+ "explanation": "The cache keeps growing normally under the new, unrelated task, still far smaller than the discarded conversation would have reached.",
88
+ "newContent": {
89
+ "userTokens": 70,
90
+ "toolResultTokens": 0,
91
+ "reasoningTokens": 60,
92
+ "outputTokens": 90
93
+ },
94
+ "events": []
95
+ }
96
+ ],
97
+ "textByHarness": {
98
+ "vscode-local": {
99
+ "title": "Starting a New Chat",
100
+ "userMessages": [
101
+ "Let's fix the flaky login test.",
102
+ "It looks like a timing issue in the test setup.",
103
+ "(new chat) Let's start something completely different: add rate limiting to the API.",
104
+ "Add a token-bucket limiter to the request middleware.",
105
+ "Looks good, thanks."
106
+ ],
107
+ "explanations": [
108
+ "Normal first turn: writes the static prefix plus this turn's own content.",
109
+ "Normal turn that reads and extends the cache built by the first turn.",
110
+ "Starting a new chat drops only the conversation history. The static prefix (instructions and tool definitions) is resent unchanged and still matches the cache, so it is read rather than rewritten. Nothing is summarised and no extra output is paid: the old turns are simply never sent again.",
111
+ "Normal turn on the new task; the cache builds up again from the new chat's baseline, far smaller than the old conversation would have grown to.",
112
+ "The cache keeps growing normally under the new, unrelated task, still far smaller than the discarded conversation would have reached."
113
+ ]
114
+ },
115
+ "copilot-agent-host": {
116
+ "title": "Starting a New Chat",
117
+ "userMessages": [
118
+ "Let's fix the flaky login test.",
119
+ "It looks like a timing issue in the test setup.",
120
+ "(new chat) Let's start something completely different: add rate limiting to the API.",
121
+ "Add a token-bucket limiter to the request middleware.",
122
+ "Looks good, thanks."
123
+ ],
124
+ "explanations": [
125
+ "Normal first turn: writes the static prefix plus this turn's own content.",
126
+ "Normal turn that reads and extends the cache built by the first turn.",
127
+ "Starting a new chat drops only the conversation history. The static prefix (instructions and tool definitions) is resent unchanged and still matches the cache, so it is read rather than rewritten. Nothing is summarised and no extra output is paid: the old turns are simply never sent again.",
128
+ "Normal turn on the new task; the cache builds up again from the new chat's baseline, far smaller than the old conversation would have grown to.",
129
+ "The cache keeps growing normally under the new, unrelated task, still far smaller than the discarded conversation would have reached."
130
+ ]
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "id": "compaction",
3
+ "title": "Context Compaction Mid-Session",
4
+ "category": "Compaction",
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 start refactoring the auth module.",
15
+ "assistantResponse": "Sure, exploring the auth module now.",
16
+ "toolCalls": [],
17
+ "explanation": "Normal first turn: writes the static prefix plus this turn's own content.",
18
+ "newContent": {
19
+ "userTokens": 500,
20
+ "toolResultTokens": 0,
21
+ "reasoningTokens": 150,
22
+ "outputTokens": 150
23
+ },
24
+ "events": []
25
+ },
26
+ {
27
+ "index": 2,
28
+ "userMessage": "Continue with the next file.",
29
+ "assistantResponse": "Looking at the session handling file next.",
30
+ "toolCalls": [
31
+ {
32
+ "name": "read_file",
33
+ "argsSummary": "src/auth/session.ts"
34
+ }
35
+ ],
36
+ "explanation": "Normal turn that reads and extends the existing cache.",
37
+ "newContent": {
38
+ "userTokens": 200,
39
+ "toolResultTokens": 100,
40
+ "reasoningTokens": 120,
41
+ "outputTokens": 180
42
+ },
43
+ "events": []
44
+ },
45
+ {
46
+ "index": 3,
47
+ "userMessage": "(automatic) context nearing the model's window limit.",
48
+ "assistantResponse": "Compacting the conversation history into a summary before continuing.",
49
+ "toolCalls": [],
50
+ "explanation": "Compaction: this request reads the entire prior history once more from the cache and produces a much smaller summary. It costs extra output, but the summary replaces the history as the new conversation prefix.",
51
+ "newContent": {
52
+ "userTokens": 150,
53
+ "toolResultTokens": 0,
54
+ "reasoningTokens": 300,
55
+ "outputTokens": 400
56
+ },
57
+ "events": [
58
+ {
59
+ "type": "compaction",
60
+ "summaryTokens": 400
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "index": 4,
66
+ "userMessage": "Continue with the next file.",
67
+ "assistantResponse": "Looking at the token handling file next.",
68
+ "toolCalls": [
69
+ {
70
+ "name": "read_file",
71
+ "argsSummary": "src/auth/token.ts"
72
+ }
73
+ ],
74
+ "explanation": "Builds on the much smaller post-compaction conversation. The summary differs from the raw history it replaced, so the old cached conversation no longer matches and is written again as a fresh, smaller prefix.",
75
+ "newContent": {
76
+ "userTokens": 80,
77
+ "toolResultTokens": 0,
78
+ "reasoningTokens": 100,
79
+ "outputTokens": 120
80
+ },
81
+ "events": []
82
+ },
83
+ {
84
+ "index": 5,
85
+ "userMessage": "Looks good, thanks.",
86
+ "assistantResponse": "Glad it's working well.",
87
+ "toolCalls": [],
88
+ "explanation": "The cache stays small compared to what it would have been without compaction; that is the point of the trade-off.",
89
+ "newContent": {
90
+ "userTokens": 60,
91
+ "toolResultTokens": 0,
92
+ "reasoningTokens": 60,
93
+ "outputTokens": 90
94
+ },
95
+ "events": []
96
+ }
97
+ ]
98
+ }
@@ -0,0 +1,108 @@
1
+ {
2
+ "id": "image-attachment-invalidation",
3
+ "title": "An Image Attachment Invalidates the Cache",
4
+ "category": "Vision tokens",
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 improve the error messages on the upload form.",
15
+ "assistantResponse": "Sure, looking at the upload form's error handling.",
16
+ "toolCalls": [],
17
+ "explanation": "Normal first turn: writes the static prefix plus this turn's own content. No image has appeared in the conversation yet.",
18
+ "newContent": {
19
+ "userTokens": 800,
20
+ "toolResultTokens": 0,
21
+ "reasoningTokens": 150,
22
+ "outputTokens": 150
23
+ },
24
+ "events": []
25
+ },
26
+ {
27
+ "index": 2,
28
+ "userMessage": "Make the file-too-large message mention the actual size limit.",
29
+ "assistantResponse": "Got it, updating that message.",
30
+ "toolCalls": [
31
+ {
32
+ "name": "read_file",
33
+ "argsSummary": "src/upload/errors.ts"
34
+ }
35
+ ],
36
+ "explanation": "Normal turn; reads and extends the cache built by the first turn.",
37
+ "newContent": {
38
+ "userTokens": 200,
39
+ "toolResultTokens": 300,
40
+ "reasoningTokens": 120,
41
+ "outputTokens": 180
42
+ },
43
+ "events": []
44
+ },
45
+ {
46
+ "index": 3,
47
+ "userMessage": "Here's what the error looks like right now — [screenshot attached].",
48
+ "assistantResponse": "Thanks, I can see the message is truncated in the toast — let me widen it.",
49
+ "toolCalls": [],
50
+ "explanation": "An image appearing in the conversation invalidates the cache from the message content on, because it changes the shape of the content, not just its size. The old conversation cache is resent uncached and rewritten, on top of the image's own tokens.",
51
+ "newContent": {
52
+ "userTokens": 100,
53
+ "toolResultTokens": 0,
54
+ "reasoningTokens": 180,
55
+ "outputTokens": 190,
56
+ "images": [
57
+ {
58
+ "width": 1280,
59
+ "height": 800
60
+ }
61
+ ]
62
+ },
63
+ "events": [
64
+ {
65
+ "type": "image-added"
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ "index": 4,
71
+ "userMessage": "That's better, thanks.",
72
+ "assistantResponse": "Glad that's clearer now.",
73
+ "toolCalls": [],
74
+ "explanation": "Normal turn; the image is now part of the cached content, with no further disruption.",
75
+ "newContent": {
76
+ "userTokens": 70,
77
+ "toolResultTokens": 0,
78
+ "reasoningTokens": 60,
79
+ "outputTokens": 90
80
+ },
81
+ "events": []
82
+ },
83
+ {
84
+ "index": 5,
85
+ "userMessage": "Actually one more thing — here's the same error on mobile [screenshot attached].",
86
+ "assistantResponse": "I see — the toast is even more cramped on the narrow viewport, let me adjust the breakpoint too.",
87
+ "toolCalls": [],
88
+ "explanation": "A second image later in the same session triggers the same invalidation again. The cost is per occurrence, so a session that attaches several screenshots pays it each time.",
89
+ "newContent": {
90
+ "userTokens": 100,
91
+ "toolResultTokens": 0,
92
+ "reasoningTokens": 160,
93
+ "outputTokens": 170,
94
+ "images": [
95
+ {
96
+ "width": 390,
97
+ "height": 844
98
+ }
99
+ ]
100
+ },
101
+ "events": [
102
+ {
103
+ "type": "image-added"
104
+ }
105
+ ]
106
+ }
107
+ ]
108
+ }
@@ -0,0 +1,115 @@
1
+ {
2
+ "id": "inline-exploration-bloat",
3
+ "title": "Exploring Inline vs. Isolating in a Subagent",
4
+ "category": "Subagents",
5
+ "harnesses": ["vscode-local", "copilot-agent-host", "claude-code"],
6
+ "sessionKind": "main",
7
+ "staticPrefix": {
8
+ "toolsTokens": 2400,
9
+ "systemTokens": 1600
10
+ },
11
+ "steps": [
12
+ {
13
+ "index": 1,
14
+ "userMessage": "Add a caching layer to the API and write tests for it.",
15
+ "assistantResponse": "I'll start by exploring the repository structure and the existing API code to plan the caching layer.",
16
+ "toolCalls": [
17
+ {
18
+ "name": "read_file",
19
+ "argsSummary": "src/api/handlers.ts"
20
+ },
21
+ {
22
+ "name": "grep_search",
23
+ "argsSummary": "existing cache usage across src/"
24
+ }
25
+ ],
26
+ "explanation": "Same task and starting point as the cache-basics scenario. The difference begins in the next step.",
27
+ "newContent": {
28
+ "userTokens": 50,
29
+ "toolResultTokens": 1400,
30
+ "reasoningTokens": 300,
31
+ "outputTokens": 250
32
+ },
33
+ "events": []
34
+ },
35
+ {
36
+ "index": 2,
37
+ "userMessage": "Here's a screenshot of the bug I'm seeing.",
38
+ "assistantResponse": "Let me search the codebase directly and read the matched files to find the root cause.",
39
+ "toolCalls": [
40
+ {
41
+ "name": "grep_search",
42
+ "argsSummary": "error message from the screenshot across src/"
43
+ },
44
+ {
45
+ "name": "semantic_search",
46
+ "argsSummary": "related handling code near the failing feature"
47
+ },
48
+ {
49
+ "name": "read_file",
50
+ "argsSummary": "full contents of the matched files"
51
+ }
52
+ ],
53
+ "explanation": "The investigation runs inline instead of in a subagent, so the whole search-and-read trajectory is written into this session's own context and cache. It is a one-off cost for the turn, but it also becomes a permanent part of the prefix that every later turn must read.",
54
+ "newContent": {
55
+ "userTokens": 50,
56
+ "toolResultTokens": 6140,
57
+ "reasoningTokens": 200,
58
+ "outputTokens": 180
59
+ },
60
+ "events": []
61
+ },
62
+ {
63
+ "index": 3,
64
+ "userMessage": "Great, please implement the fix using that root cause.",
65
+ "assistantResponse": "Applying the fix to the affected files based on what I found.",
66
+ "toolCalls": [
67
+ {
68
+ "name": "replace_string_in_file",
69
+ "argsSummary": "apply fix to src/api/cache.ts"
70
+ }
71
+ ],
72
+ "explanation": "Implements the fix, but the cached prefix is now much larger than it would have been had the exploration been isolated, because the inline exploration is baked into it.",
73
+ "newContent": {
74
+ "userTokens": 350,
75
+ "toolResultTokens": 400,
76
+ "reasoningTokens": 250,
77
+ "outputTokens": 280
78
+ },
79
+ "events": []
80
+ },
81
+ {
82
+ "index": 4,
83
+ "userMessage": "Now run the test suite.",
84
+ "assistantResponse": "Running the test suite now.",
85
+ "toolCalls": [
86
+ {
87
+ "name": "run_in_terminal",
88
+ "argsSummary": "npm test (verbose output)"
89
+ }
90
+ ],
91
+ "explanation": "Runs a verbose test suite. Every turn from here on inherits the extra context the inline exploration added, so cache reads stay permanently higher.",
92
+ "newContent": {
93
+ "userTokens": 220,
94
+ "toolResultTokens": 1800,
95
+ "reasoningTokens": 150,
96
+ "outputTokens": 300
97
+ },
98
+ "events": []
99
+ },
100
+ {
101
+ "index": 5,
102
+ "userMessage": "Thanks, that's everything!",
103
+ "assistantResponse": "You're welcome \u2014 let me know if you need anything else.",
104
+ "toolCalls": [],
105
+ "explanation": "Final turn. The inline path's running total ends noticeably higher than the isolated-subagent path through the same steps: the isolated version's exploration cost is bounded to one call, while the inline version taxes every later turn.",
106
+ "newContent": {
107
+ "userTokens": 60,
108
+ "toolResultTokens": 0,
109
+ "reasoningTokens": 30,
110
+ "outputTokens": 90
111
+ },
112
+ "events": []
113
+ }
114
+ ]
115
+ }
@@ -0,0 +1,99 @@
1
+ {
2
+ "id": "instructions-edit",
3
+ "title": "Editing Custom Instructions Mid-Session",
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 add input validation to the signup form.",
15
+ "assistantResponse": "Sure, looking at the signup form now.",
16
+ "toolCalls": [],
17
+ "explanation": "Normal first turn: writes the static system prompt and instructions plus this turn's own content.",
18
+ "newContent": {
19
+ "userTokens": 1000,
20
+ "toolResultTokens": 0,
21
+ "reasoningTokens": 150,
22
+ "outputTokens": 150
23
+ },
24
+ "events": []
25
+ },
26
+ {
27
+ "index": 2,
28
+ "userMessage": "Validate email format and require a password of at least 8 characters.",
29
+ "assistantResponse": "Got it, adding those validation rules.",
30
+ "toolCalls": [
31
+ {
32
+ "name": "read_file",
33
+ "argsSummary": "src/forms/signup.ts"
34
+ }
35
+ ],
36
+ "explanation": "Normal turn: 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 just added a note to copilot-instructions.md: always write a Zod schema for new form fields. Continue with that in mind.",
48
+ "assistantResponse": "Understood — I'll add a Zod schema for the new signup fields going forward.",
49
+ "toolCalls": [],
50
+ "explanation": "Editing the custom instructions file changes the system prompt, which sits right after the tool definitions. The match breaks there, and all earlier conversation, though unchanged, can no longer match either, because a prefix match cannot skip a changed block and resume later. Only the tool definitions ahead of the change can still be read, and only if a breakpoint caches them alone. A new cache is then written under the updated instructions.",
51
+ "newContent": {
52
+ "userTokens": 100,
53
+ "toolResultTokens": 0,
54
+ "reasoningTokens": 200,
55
+ "outputTokens": 220
56
+ },
57
+ "events": [
58
+ {
59
+ "type": "system-changed",
60
+ "deltaTokens": 150,
61
+ "cause": "edit"
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ "index": 4,
67
+ "userMessage": "Apply the schema to the login form too.",
68
+ "assistantResponse": "Adding the same Zod-schema convention to the login form.",
69
+ "toolCalls": [
70
+ {
71
+ "name": "replace_string_in_file",
72
+ "argsSummary": "src/forms/login.ts"
73
+ }
74
+ ],
75
+ "explanation": "Normal turn on the post-edit baseline: the cache rebuilds under the updated instructions.",
76
+ "newContent": {
77
+ "userTokens": 60,
78
+ "toolResultTokens": 300,
79
+ "reasoningTokens": 140,
80
+ "outputTokens": 170
81
+ },
82
+ "events": []
83
+ },
84
+ {
85
+ "index": 5,
86
+ "userMessage": "Looks good, thanks.",
87
+ "assistantResponse": "Glad it's working well.",
88
+ "toolCalls": [],
89
+ "explanation": "The cache keeps growing normally under the new instructions.",
90
+ "newContent": {
91
+ "userTokens": 60,
92
+ "toolResultTokens": 0,
93
+ "reasoningTokens": 60,
94
+ "outputTokens": 90
95
+ },
96
+ "events": []
97
+ }
98
+ ]
99
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "id": "mcp-tool-change",
3
+ "title": "MCP Tool Change Mid-Session",
4
+ "category": "Tool change",
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: writes the static prefix, including the currently enabled toolset, plus this turn's own content.",
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 cache.",
32
+ "newContent": {
33
+ "userTokens": 200,
34
+ "toolResultTokens": 100,
35
+ "reasoningTokens": 120,
36
+ "outputTokens": 180
37
+ },
38
+ "events": []
39
+ },
40
+ {
41
+ "index": 3,
42
+ "userMessage": "I just enabled a new MCP server — use its tools from now on.",
43
+ "assistantResponse": "Understood, I'll use the newly enabled tools going forward.",
44
+ "toolCalls": [],
45
+ "explanation": "The tool definitions come first in the prompt, so changing the enabled toolset invalidates everything after them: the prior cache no longer matches and the whole history is resent uncached. Prices stay the same, so this spike is smaller than a model switch's.",
46
+ "newContent": {
47
+ "userTokens": 150,
48
+ "toolResultTokens": 0,
49
+ "reasoningTokens": 200,
50
+ "outputTokens": 220
51
+ },
52
+ "events": [
53
+ {
54
+ "type": "tools-changed",
55
+ "deltaTokens": 1500
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ "index": 4,
61
+ "userMessage": "Use the new tool to fetch the latest schema.",
62
+ "assistantResponse": "Fetching the latest schema with the newly enabled tool.",
63
+ "toolCalls": [
64
+ {
65
+ "name": "newMcpTool.fetchSchema",
66
+ "argsSummary": "fetch latest API schema via the newly enabled MCP tool"
67
+ }
68
+ ],
69
+ "explanation": "Normal turn under the new toolset; it actually calls one of the newly enabled tools.",
70
+ "newContent": {
71
+ "userTokens": 110,
72
+ "toolResultTokens": 400,
73
+ "reasoningTokens": 130,
74
+ "outputTokens": 160
75
+ },
76
+ "events": []
77
+ },
78
+ {
79
+ "index": 5,
80
+ "userMessage": "Great, that's all for now.",
81
+ "assistantResponse": "Sounds good, let me know if you need anything else.",
82
+ "toolCalls": [],
83
+ "explanation": "The cache continues building normally under the new toolset, with no further disruption.",
84
+ "newContent": {
85
+ "userTokens": 70,
86
+ "toolResultTokens": 0,
87
+ "reasoningTokens": 70,
88
+ "outputTokens": 100
89
+ },
90
+ "events": []
91
+ }
92
+ ]
93
+ }