mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): reconcile context window breakdown with API tokens and decouple agent badge from step column
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {extractLiveActivity, extractModelSteps, normalizeCachedStep, speedMetric, summarizeSpeed, summarizeTtft} from '../speed-metrics.mjs';
|
||||
import {extractContextBreakdown, extractLiveActivity, extractModelSteps, normalizeCachedStep, speedMetric, summarizeSpeed, summarizeTtft} from '../speed-metrics.mjs';
|
||||
|
||||
function sample({total=12,ttft='2s',stream='10s',output=1100,thinking=100,response=1000,
|
||||
thinkingDuration='4s',tools=false,text=true,status='CORTEX_STEP_STATUS_DONE'}={}) {
|
||||
@@ -351,3 +351,52 @@ test('extractModelSteps tracks sequential user turns, merges consecutive prompts
|
||||
assert.equal(steps[3].isTurnStart, true);
|
||||
assert.equal(steps[3].turnPrompt, '第三轮真实提问');
|
||||
});
|
||||
|
||||
test('extractContextBreakdown parses split top-level SKILLS, RULES, SUBAGENTS, and PLUGINS groups without dropping tokens', () => {
|
||||
const breakdown = extractContextBreakdown({
|
||||
chatStartMetadata: {
|
||||
contextWindowMetadata: {
|
||||
estimatedTokensUsed: 148852,
|
||||
maxContextTokens: 256000,
|
||||
tokenBreakdown: {
|
||||
totalTokens: 148852,
|
||||
groups: [
|
||||
{ type: 'TOKEN_TYPE_SYSTEM_PROMPT', name: 'System Prompt', numTokens: 5505 },
|
||||
{ type: 'TOKEN_TYPE_MCP_TOOLS', name: 'Mcp Tools', numTokens: 234 },
|
||||
{ type: 'TOKEN_TYPE_SUBAGENTS', name: 'Subagents', numTokens: 1741 },
|
||||
{ type: 'TOKEN_TYPE_SKILLS', name: 'Skills', numTokens: 2201 },
|
||||
{ type: 'TOKEN_TYPE_PLUGINS', name: 'Plugins', numTokens: 1601 },
|
||||
{ type: 'TOKEN_TYPE_RULES', name: 'Rules', numTokens: 2282 },
|
||||
{ type: 'TOKEN_TYPE_TOOLS', name: 'Tools', numTokens: 8857 },
|
||||
{
|
||||
type: 'TOKEN_TYPE_CHAT_MESSAGES',
|
||||
name: 'Chat Messages',
|
||||
numTokens: 126431,
|
||||
children: [
|
||||
{ name: '2449: CHECKPOINT', numTokens: 5087 },
|
||||
{ name: '2450: USER_INPUT', numTokens: 281 },
|
||||
{ name: '2455: SYSTEM_MESSAGE', numTokens: 179 },
|
||||
{ name: '2502: PLANNER_RESPONSE', numTokens: 15017 },
|
||||
{ name: '2503: GENERIC', numTokens: 105867 },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.ok(breakdown);
|
||||
assert.equal(breakdown.skillsTokens, 2201);
|
||||
assert.equal(breakdown.userRulesTokens, 2282);
|
||||
assert.equal(breakdown.systemPromptTokens, 5505 + 1741 + 1601);
|
||||
assert.equal(breakdown.mcpToolsTokens, 234);
|
||||
assert.equal(breakdown.systemToolsTokens, 8857);
|
||||
assert.equal(breakdown.checkpointTokens, 5087);
|
||||
assert.equal(breakdown.userInputTokens, 281);
|
||||
assert.equal(breakdown.subagentTokens, 179);
|
||||
assert.equal(breakdown.assistantTokens, 15017);
|
||||
assert.equal(breakdown.toolResultsTokens, 105867);
|
||||
assert.equal(breakdown.messagesTokens, 126431);
|
||||
assert.equal(breakdown.totalTokens, 148852);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user