The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
test: split Sonnet model pricing cases
Santhi Prakash64f0acf60e77
diff --git a/tests/hooks/cost-tracker.test.js b/tests/hooks/cost-tracker.test.jsindex af6ee8671..20054d782 100644--- a/tests/hooks/cost-tracker.test.js+++ b/tests/hooks/cost-tracker.test.js@@ -467,11 +467,10 @@ function runTests() {}}) ? passed++ : failed++);- // 10b. Dated Sonnet 5 IDs and near-misses are matched correctly.- (test('prices dated Sonnet 5 IDs at $12 and rejects claude-sonnet-50 near-miss', () => {+ // 10b. Dated Sonnet 5 IDs are matched correctly.+ (test('prices dated Sonnet 5 IDs at $12', () => {const tmpHome = makeTempDir();const sessionId = `sonnet5-dated-${process.pid}-${Date.now()}`;- const nearMissSessionId = `sonnet50-near-miss-${process.pid}-${Date.now()}`;const transcriptPath = path.join(tmpHome, 'session.jsonl');writeTranscript(transcriptPath, [{@@ -486,7 +485,6 @@ function runTests() {try {removeHarnessCostCache(sessionId);- removeHarnessCostCache(nearMissSessionId);const result = runScript({ session_id: sessionId, transcript_path: transcriptPath },withTempHome(tmpHome)@@ -496,32 +494,41 @@ function runTests() {const metricsFile = path.join(tmpHome, '.claude', 'metrics', 'costs.jsonl');const row = JSON.parse(fs.readFileSync(metricsFile, 'utf8').trim());assert.strictEqual(row.estimated_cost_usd, 12, 'Expected dated Sonnet 5 1M/1M to cost $12.00');+ } finally {+ removeHarnessCostCache(sessionId);+ fs.rmSync(tmpHome, { recursive: true, force: true });+ }+ }) ? passed++ : failed++);- // Near-miss `claude-sonnet-50` must fall through to the standard Sonnet rate.- const nearMissPath = path.join(tmpHome, 'near-miss.jsonl');- writeTranscript(nearMissPath, [- {- type: 'assistant',- message: {- id: 'msg_sonnet50',- model: 'claude-sonnet-50',- usage: { input_tokens: 1_000_000, output_tokens: 1_000_000 },- },+ // 10c. Near-miss Sonnet 5 IDs fall back to standard Sonnet rates.+ (test('rejects claude-sonnet-50 as a Sonnet 5 near-miss', () => {+ const tmpHome = makeTempDir();+ const sessionId = `sonnet50-near-miss-${process.pid}-${Date.now()}`;+ const transcriptPath = path.join(tmpHome, 'session.jsonl');+ writeTranscript(transcriptPath, [+ {+ type: 'assistant',+ message: {+ id: 'msg_sonnet50',+ model: 'claude-sonnet-50',+ usage: { input_tokens: 1_000_000, output_tokens: 1_000_000 },},- ]);+ },+ ]);- const nearResult = runScript(- { session_id: nearMissSessionId, transcript_path: nearMissPath },+ try {+ removeHarnessCostCache(sessionId);+ const result = runScript(+ { session_id: sessionId, transcript_path: transcriptPath },withTempHome(tmpHome));- assert.strictEqual(nearResult.code, 0, `Expected exit code 0, got ${nearResult.code}`);+ assert.strictEqual(result.code, 0, `Expected exit code 0, got ${result.code}`);- const lines = fs.readFileSync(metricsFile, 'utf8').trim().split('\n');- const nearRow = JSON.parse(lines[lines.length - 1]);- assert.strictEqual(nearRow.estimated_cost_usd, 18, 'Expected claude-sonnet-50 near-miss to fall back to $18.00 Sonnet rate');+ const metricsFile = path.join(tmpHome, '.claude', 'metrics', 'costs.jsonl');+ const row = JSON.parse(fs.readFileSync(metricsFile, 'utf8').trim());+ assert.strictEqual(row.estimated_cost_usd, 18, 'Expected claude-sonnet-50 near-miss to fall back to $18.00 Sonnet rate');} finally {removeHarnessCostCache(sessionId);- removeHarnessCostCache(nearMissSessionId);fs.rmSync(tmpHome, { recursive: true, force: true });}}) ? passed++ : failed++);