diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ad33ad..113c51c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 0.55.7 + +### Fixed — `blockrun_modal` reserves the gateway's new sandbox prices + +The gateways now price a create by size as well as lifetime. The flat rate needs +300 seconds or less, at most 1 CPU and at most 1024 MB. Anything else pays the new +hourly rates (CPU $0.25, T4 $4, L4 $4.50, A10G $5, A100 $7, H100 $9), never below +the flat rate. The estimator, budget cap, confirm dialog, tool text and skill now +use the same rule, so `{ gpu: "T4", cpu: 8, memory: 32768, timeout: 300 }` reserves +$0.335 instead of $0.052. The skill's GPU example also no longer sends a custom +image and `setup_commands`, which the gateway refuses. + ## 0.55.6 ### Fixed — agents are no longer offered Exa's retired `tweet` category diff --git a/README.md b/README.md index d48bab0..af07524 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ Package managers have shown install size for decades. Almost no MCP server shows | Profile | Tools | Context | |---------|-------|---------| -| `full` *(default)* | 19 | 14,227 | +| `full` *(default)* | 19 | 14,265 | | `trading` | 8 | 5,471 | | `media` | 7 | 7,016 | | `research` | 5 | 2,807 | diff --git a/VERSION b/VERSION index dab5104..42f7f41 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.55.6 +0.55.7 diff --git a/assets/context-cost-dark.svg b/assets/context-cost-dark.svg index 1c491ec..5a34108 100644 --- a/assets/context-cost-dark.svg +++ b/assets/context-cost-dark.svg @@ -1,9 +1,9 @@ - + CONTEXT COST - 14.2K tokens + 14.3K tokens 7% of a 200K context window · every turn, whether or not you call a tool 5.5K with --profile trading — 62% less measured, not estimated diff --git a/assets/context-cost.svg b/assets/context-cost.svg index e2c4813..9bdc743 100644 --- a/assets/context-cost.svg +++ b/assets/context-cost.svg @@ -1,9 +1,9 @@ - + CONTEXT COST - 14.2K tokens + 14.3K tokens 7% of a 200K context window · every turn, whether or not you call a tool 5.5K with --profile trading — 62% less measured, not estimated diff --git a/docs/mcp-schema-overhead.md b/docs/mcp-schema-overhead.md index ba9cf88..97c017d 100644 --- a/docs/mcp-schema-overhead.md +++ b/docs/mcp-schema-overhead.md @@ -16,7 +16,7 @@ Written 2026-09-01, verified against `@modelcontextprotocol/sdk` 1.29.0. Numbers | Profile | Tools | Context | |---------|-------|---------| -| `full` *(default)* | 19 | 14,227 | +| `full` *(default)* | 19 | 14,265 | | `trading` | 8 | 5,471 | | `media` | 7 | 7,016 | | `research` | 5 | 2,807 | diff --git a/package-lock.json b/package-lock.json index d64ee34..ee0d4d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@blockrun/mcp", - "version": "0.55.6", + "version": "0.55.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@blockrun/mcp", - "version": "0.55.6", + "version": "0.55.7", "license": "MIT", "dependencies": { "@anthropic-ai/sdk": "^0.123.0", diff --git a/package.json b/package.json index 77ab0f3..ab187ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockrun/mcp", - "version": "0.55.6", + "version": "0.55.7", "mcpName": "io.github.BlockRunAI/blockrun-mcp", "description": "BlockRun MCP Server - Give your AI agent web search, deep research, prediction markets, and crypto data. Pay per call from a USDC wallet (Solana or Base) or a BlockRun API key.", "type": "module", diff --git a/scripts/verify-prices.ts b/scripts/verify-prices.ts index 517d70c..59c791d 100644 --- a/scripts/verify-prices.ts +++ b/scripts/verify-prices.ts @@ -147,7 +147,7 @@ const PROBES: Probe[] = [ { label: "pm/markets/search", path: "pm/markets/search?q=election", expected: MARKETS_PRICE_USD }, // Body-priced: modal bills off gpu + timeout, NOT the path. A 24h H100 is - // $192 upfront and non-refundable — the case that made this script exist. + // $216 upfront and non-refundable — the case that made this script exist. { label: "modal create {} (flat)", path: "modal/sandbox/create", body: {}, expected: estimateModalCost("sandbox/create", {}) }, { label: "modal create T4 300s", path: "modal/sandbox/create", body: { timeout: 300, gpu: "T4" }, expected: estimateModalCost("sandbox/create", { timeout: 300, gpu: "T4" }) }, { label: "modal create CPU 1h", path: "modal/sandbox/create", body: { timeout: 3600 }, expected: estimateModalCost("sandbox/create", { timeout: 3600 }) }, diff --git a/skills/modal/SKILL.md b/skills/modal/SKILL.md index 0ba643c..da14061 100644 --- a/skills/modal/SKILL.md +++ b/skills/modal/SKILL.md @@ -35,18 +35,19 @@ That makes `timeout` the single most expensive field in this MCP: |---|---| | `{ timeout: 300 }` | **$0.0110** | | `{ timeout: 300, gpu: "A100" }` | **$0.2010** | -| `{ timeout: 600, gpu: "A100" }` | **$0.6677** | -| `{ timeout: 86400, gpu: "H100" }` | **$192.0010** | +| `{ timeout: 600, gpu: "A100" }` | **$1.1677** | +| `{ timeout: 300, gpu: "T4", cpu: 8, memory: 32768 }` | **$0.3343** | +| `{ timeout: 86400, gpu: "H100" }` | **$216.0010** | -All four are live-verified quotes. A 24h H100 sandbox costs **$192 upfront, non-refundable**, even if your job finishes in a minute. +A 24h H100 sandbox costs **$216 upfront, non-refundable**, even if your job finishes in a minute. -**So: ask for the time you need, not a safe-looking ceiling.** Need 20 minutes of H100? `timeout: 1200` is $2.67, not $192. Keep `timeout ≤ 300` and you stay on the flat rate entirely. +**So: ask for the time you need, not a safe-looking ceiling.** Need 20 minutes of H100? `timeout: 1200` is $3.00, not $216. Keep `timeout ≤ 300`, `cpu ≤ 1` and `memory ≤ 1024` and you stay on the flat rate. ## How to Call from MCP ```ts // 1. Create — timeout: 300 keeps you on the FLAT rate ($0.0110, or $0.2010 with A100). -// Anything above 300 bills hourly for the full requested lifetime, no refund. +// Anything above 300, or above 1 CPU or 1024 MB, bills hourly for the full requested lifetime, no refund. blockrun_modal({ path: "sandbox/create", body: { image: "python:3.11", gpu: "A100", @@ -69,14 +70,14 @@ blockrun_modal({ path: "sandbox/terminate", body: { sandbox_id: "sb_abc..." } }) | Path | Method | Body | Price | |---|---|---|---| -| `sandbox/create` | POST | `{ image?, timeout?, cpu?, memory?, gpu?, setup_commands? }` | **depends on `timeout` + `gpu` — see below** | +| `sandbox/create` | POST | `{ image?, timeout?, cpu?, memory?, gpu?, setup_commands? }` | **depends on `timeout`, `gpu`, `cpu` and `memory` — see below** | | `sandbox/exec` | POST | `{ sandbox_id, command: ["python","-c","..."], timeout? }` | $0.0020 | | `sandbox/status` | POST | `{ sandbox_id }` | $0.0020 | | `sandbox/terminate` | POST | `{ sandbox_id }` | $0.0020 | ### `sandbox/create` pricing is bimodal -**`timeout ≤ 300s` — flat rate, charged once:** +**`timeout ≤ 300s`, `cpu ≤ 1` and `memory ≤ 1024` — flat rate, charged once:** | gpu | price | |---|---| @@ -87,20 +88,19 @@ blockrun_modal({ path: "sandbox/terminate", body: { sandbox_id: "sb_abc..." } }) | `A100` | $0.2010 | | `H100` | $0.4010 | -**`timeout > 300s` — per-hour × the full requested lifetime, upfront, no refund:** +**Anything longer or larger — per-hour × the full requested lifetime, never below the flat rate, upfront, no refund:** | gpu | per hour | 1h | 24h (max) | |---|---|---|---| -| *(none, CPU)* | $0.10 | $0.1010 | $2.4010 | -| `T4` | $1.50 | $1.5010 | $36.0010 | -| `L4` | $2.00 | $2.0010 | $48.0010 | -| `A10G` | $2.50 | $2.5010 | $60.0010 | -| `A100` | $4.00 | $4.0010 | $96.0010 | -| `H100` | $8.00 | $8.0010 | **$192.0010** | +| *(none, CPU)* | $0.25 | $0.2510 | $6.0010 | +| `T4` | $4.00 | $4.0010 | $96.0010 | +| `L4` | $4.50 | $4.5010 | $108.0010 | +| `A10G` | $5.00 | $5.0010 | $120.0010 | +| `A100` | $7.00 | $7.0010 | $168.0010 | +| `H100` | $9.00 | $9.0010 | **$216.0010** | -Hours are exact, not rounded up — `timeout: 1800` on `A100` is 0.5h = $2.0010. Every figure above includes the $0.001 flat transaction fee. Max `timeout` is 86400 (24h). +Hours are exact, not rounded up — `timeout: 1800` on `A100` is 0.5h = $3.5010. Every figure above includes the $0.001 flat transaction fee. Max `timeout` is 86400 (24h). -One quirk worth knowing: `timeout: 300` costs $0.0110 (flat) but `timeout: 301` costs $0.0094 (CPU-hourly) — just past the cliff is briefly *cheaper* on CPU. It stops being cheaper at 360s. ## Field Reference @@ -109,7 +109,7 @@ One quirk worth knowing: `timeout: 300` costs $0.0110 (flat) but `timeout: 301` | `image` | `python:3.11` | Any public Docker image. `nvidia/cuda:12-runtime` if you bring GPU code. | | `timeout` | 300 | **BILLED lifetime in seconds — charged upfront for the full amount, never refunded.** NOT idle eviction: you pay for what you ask for, not what you use. `≤300` = flat rate; `>300` switches to per-hour billing (see the tables above). Max 86400 (24h). This is the field that turns a $0.01 sandbox into a $192 one. | | `cpu` | 1 | CPU cores | -| `memory` | 1024 | Memory in MB | +| `memory` | 512 | Memory in MB | | `gpu` | none | `T4` / `L4` / `A10G` / `A100` / `H100` — those five only. Anything else is rejected: `{"gpu":"A100-80GB"}` returns HTTP 400 *"Unsupported GPU type. Allowed: T4, L4, A10G, A100, H100"*. Drives the price hard — see the tables above. | | `setup_commands` | `[]` | Shell commands run once during sandbox provisioning | | `command` (exec) | required | Array form: `["python","-c","print(2+2)"]` | @@ -132,11 +132,9 @@ await blockrun_modal({ path: "sandbox/terminate", body: { sandbox_id: sb.sandbox ```ts blockrun_modal({ path: "sandbox/create", body: { - image: "pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime", gpu: "A100", timeout: 1200, - memory: 16384, - setup_commands: ["pip install --quiet transformers accelerate"] + memory: 16384 }}) ``` Then `sandbox/exec` with your inference command. diff --git a/src/tools/modal.ts b/src/tools/modal.ts index 77b6bfd..0d71682 100644 --- a/src/tools/modal.ts +++ b/src/tools/modal.ts @@ -23,16 +23,18 @@ import type { BudgetState } from "../types.js"; // sandbox/create is priced off the BODY, not the path. Mirrors // getModalCreatePricing() in the gateway's src/lib/modal.ts: // -// timeout <= 300s -> flat rate: CPU $0.01, or the GPU tier below -// timeout > 300s -> hourly: rate x (timeout/3600), EXACT (not rounded up), -// charged upfront for the full requested lifetime -// with NO refund on early terminate +// timeout <= 300s, cpu <= 1 and memory <= 1024 MB +// -> flat rate: CPU $0.01, or the GPU tier below +// anything else -> hourly: rate x (timeout/3600), EXACT (not rounded up), +// never below the flat rate, charged upfront for +// the full requested lifetime with NO refund on +// early terminate // // Estimating on the path alone reserved a flat $0.01 for every create. Verified // live against the payment-required header: // -// { timeout: 86400, gpu: "H100" } -> charged $192.0020 (reserved $0.012 — 16,000x short) -// { timeout: 3600, gpu: "A100" } -> charged $4.0020 +// { timeout: 86400, gpu: "H100" } -> charged $192.0020 (reserved $0.012 — 16,000x short; old rates) +// { timeout: 3600, gpu: "A100" } -> charged $4.0020 (old rates) // { timeout: 300 } -> charged $0.0120 // // A $1 agent cap could settle $192 of non-refundable spend. Keep these tables in @@ -54,9 +56,11 @@ const MODAL_OPERATION_PRICE_USD = 0.001; const MODAL_GPU_CREATE_PRICE_USD = new Map([ ["T4", 0.05], ["L4", 0.08], ["A10G", 0.1], ["A100", 0.2], ["H100", 0.4], ]); -const MODAL_CPU_HOURLY_PRICE_USD = 0.1; +const MODAL_FLAT_RATE_MAX_CPU = 1; +const MODAL_FLAT_RATE_MAX_MEMORY_MB = 1024; +const MODAL_CPU_HOURLY_PRICE_USD = 0.25; const MODAL_GPU_HOURLY_PRICE_USD = new Map([ - ["T4", 1.5], ["L4", 2.0], ["A10G", 2.5], ["A100", 4.0], ["H100", 8.0], + ["T4", 4.0], ["L4", 4.5], ["A10G", 5.0], ["A100", 7.0], ["H100", 9.0], ]); const MODAL_GPU_TIERS = [...MODAL_GPU_HOURLY_PRICE_USD.keys()]; @@ -107,13 +111,13 @@ export function estimateModalCost(path: string, body?: unknown): number { // a single invisible character moved the most expensive call this server can // make into the cheapest tier: `sandbox/create` reserved $0.003 (fetch // deletes the tab, so the gateway still routed and billed a real create — up - // to $192.00, non-refundable), and $0.003 clears every budget cap there is. + // to $216.00, non-refundable), and $0.003 clears every budget cap there is. // `%63reate` did the same via the router's own percent-decode. This is the // shared helper `hasPathTraversal` has always used; modal was the one price // table that never adopted it. See test/modal-cost.test.ts. if (!normalizeClassifyPath(path).includes("sandbox/create")) return withTxFee(MODAL_OPERATION_PRICE_USD); - const o = body && typeof body === "object" ? (body as { gpu?: unknown; timeout?: unknown }) : {}; + const o = body && typeof body === "object" ? (body as { gpu?: unknown; timeout?: unknown; cpu?: unknown; memory?: unknown }) : {}; // Trimmed, as the gateway prices it — see normalizeModalCreateBody. The // handler sends a body normalised the same way; this is belt-and-braces so // the estimator is right even for a caller that skipped the handler. @@ -124,17 +128,23 @@ export function estimateModalCost(path: string, body?: unknown): number { ? o.timeout : MODAL_DEFAULT_CREATE_TIMEOUT_SECONDS; - if (seconds > MODAL_FLAT_RATE_MAX_SECONDS) { + // Size is priced too: absent means the gateway's small default. A non-number + // never reaches a charge, the gateway 400s it before payment. + const cpu = typeof o.cpu === "number" ? o.cpu : 1; + const memory = typeof o.memory === "number" ? o.memory : 512; + const flatPrice = (gpu !== undefined ? MODAL_GPU_CREATE_PRICE_USD.get(gpu) : undefined) ?? MODAL_CREATE_PRICE_USD; + + if (seconds > MODAL_FLAT_RATE_MAX_SECONDS || cpu > MODAL_FLAT_RATE_MAX_CPU || memory > MODAL_FLAT_RATE_MAX_MEMORY_MB) { // An absent gpu is the CPU rate — same as the gateway's // `opts.gpu && opts.gpu in TABLE ? TABLE[gpu] : CPU_RATE`, which runs on // the trimmed value. An unknown gpu also falls back here, but only so the // estimator stays total: the handler refuses it before the reserve // (unsupportedModalGpu), and the gateway 400s it before payment. const hourly = gpu !== undefined ? MODAL_GPU_HOURLY_PRICE_USD.get(gpu) : undefined; - return withTxFee((hourly ?? MODAL_CPU_HOURLY_PRICE_USD) * (seconds / 3600)); + // Floored at the flat rate, as the gateway does: large and short is not cheaper. + return withTxFee(Math.max(flatPrice, (hourly ?? MODAL_CPU_HOURLY_PRICE_USD) * (seconds / 3600))); } - const flat = gpu !== undefined ? MODAL_GPU_CREATE_PRICE_USD.get(gpu) : undefined; - return withTxFee(flat ?? MODAL_CREATE_PRICE_USD); + return withTxFee(flatPrice); } // Modal sandbox/exec is synchronous — the HTTP call stays open for the whole @@ -162,12 +172,12 @@ export function registerModalTool(server: McpServer, budget: BudgetState): void Use when you need: a clean ephemeral environment, GPU access (T4/L4/A10G/A100/H100 — those five only), or a safer place for untrusted code. Prefer local tools for normal repo work. ⚠️ \`timeout\` IS THE BILLED LIFETIME — charged upfront in full, NEVER refunded. It is not an idle timeout: you pay for the time you ASK for, not the time you use, and terminating early refunds nothing. Ask for what you need, not a safe-looking ceiling. -- timeout ≤ 300s → flat: $0.0120 CPU · $0.0520 T4 · $0.0820 L4 · $0.1020 A10G · $0.2020 A100 · $0.4020 H100 -- timeout > 300s → PER-HOUR × the full requested lifetime: $0.10/h CPU · $1.50 T4 · $2.00 L4 · $2.50 A10G · $4.00 A100 · $8.00/h H100 - e.g. { timeout: 600, gpu: "A100" } = $0.6687 · { timeout: 86400, gpu: "H100" } = $192.00 +- timeout ≤ 300s, cpu ≤ 1 and memory ≤ 1024 → flat: $0.0120 CPU · $0.0520 T4 · $0.0820 L4 · $0.1020 A10G · $0.2020 A100 · $0.4020 H100 +- anything longer or larger → PER-HOUR × the full requested lifetime, never below flat: $0.25/h CPU · $4.00 T4 · $4.50 L4 · $5.00 A10G · $7.00 A100 · $9.00/h H100 + e.g. { timeout: 600, gpu: "A100" } = $1.1687 · { timeout: 300, gpu: "T4", cpu: 8 } = $0.3353 · { timeout: 86400, gpu: "H100" } = $216.00 Common paths (all POST): -- sandbox/create — body: { image?, timeout?, cpu?, memory?, gpu?, setup_commands? } (see above — $0.0120 to $192.00) +- sandbox/create — body: { image?, timeout?, cpu?, memory?, gpu?, setup_commands? } (see above — $0.0120 to $216.00) - sandbox/exec — body: { sandbox_id, command: ["python","-c","..."], timeout? } ($0.0030) - sandbox/status — body: { sandbox_id } ($0.0030) - sandbox/terminate — body: { sandbox_id } ($0.0030) diff --git a/test/modal-cost.test.ts b/test/modal-cost.test.ts index a4e054a..c5244e6 100644 --- a/test/modal-cost.test.ts +++ b/test/modal-cost.test.ts @@ -12,8 +12,8 @@ import { estimateModalCost } from "../src/tools/modal.js"; // Every figure below is the gateway's own quote, read from the live // payment-required header (free to request — no payment attached). It mirrors // getModalCreatePricing() in the gateway's src/lib/modal.ts: -// timeout <= 300s -> flat (CPU $0.01, GPU per tier) -// timeout > 300s -> hourly x (timeout/3600), EXACT, charged upfront, no refund +// timeout <= 300s, cpu <= 1, memory <= 1024 -> flat (CPU $0.01, GPU per tier) +// anything else -> hourly x (timeout/3600), EXACT, never below flat, upfront, no refund const CHARGED: Array<[string, unknown, number]> = [ // path-only operations ["sandbox/exec", { sandbox_id: "sb", command: ["echo"] }, 0.003], @@ -25,10 +25,17 @@ const CHARGED: Array<[string, unknown, number]> = [ ["sandbox/create", { timeout: 300, gpu: "T4" }, 0.052001], ["sandbox/create", { timeout: 300, gpu: "H100" }, 0.402001], // hourly tier: timeout > 300, exact hours (not rounded up) - ["sandbox/create", { timeout: 3600, gpu: "A100" }, 4.002001], - ["sandbox/create", { timeout: 86400, gpu: "H100" }, 192.002], - ["sandbox/create", { timeout: 3600 }, 0.102001], // CPU hourly $0.10 - ["sandbox/create", { timeout: 1801, gpu: "T4" }, 1.5 * (1801 / 3600) + 0.002], + ["sandbox/create", { timeout: 3600, gpu: "A100" }, 7.002001], + ["sandbox/create", { timeout: 86400, gpu: "H100" }, 216.002], + // size: one step over either line bills hourly at any timeout + ["sandbox/create", { timeout: 300, gpu: "T4", cpu: 1, memory: 1024 }, 0.052001], + ["sandbox/create", { timeout: 300, gpu: "T4", cpu: 1.5 }, 4 * (300 / 3600) + 0.002], + ["sandbox/create", { timeout: 300, gpu: "T4", memory: 1025 }, 4 * (300 / 3600) + 0.002], + ["sandbox/create", { timeout: 300, gpu: "T4", cpu: 8, memory: 32768 }, 4 * (300 / 3600) + 0.002], + // floor: large and short is never cheaper than the small flat rate + ["sandbox/create", { timeout: 10, gpu: "T4", cpu: 8, memory: 32768 }, 0.052001], + ["sandbox/create", { timeout: 3600 }, 0.252], // CPU hourly $0.25 + ["sandbox/create", { timeout: 1801, gpu: "T4" }, 4 * (1801 / 3600) + 0.002], ]; test("estimateModalCost reserves what the gateway actually charges", () => { @@ -57,7 +64,7 @@ test("estimateModalCost never reserves the flat rate for an expensive sandbox", // modal-gpu-trim.test.ts). The estimator merely has to stay total and finite. test("estimateModalCost falls back to the CPU rate for an unknown gpu (the handler refuses it first)", () => { assert.equal(estimateModalCost("sandbox/create", { timeout: 300, gpu: "NOPE" }), 0.012); - assert.equal(estimateModalCost("sandbox/create", { timeout: 3600, gpu: "NOPE" }), 0.102001); + assert.equal(estimateModalCost("sandbox/create", { timeout: 3600, gpu: "NOPE" }), 0.252); }); // A plain object literal inherits from Object.prototype, so TABLE["toString"] @@ -74,7 +81,7 @@ test("estimateModalCost is not fooled by Object.prototype keys as a gpu", () => assert.equal(typeof got, "number", `gpu:"${key}" timeout:${timeout} returned a ${typeof got}, not a number`); assert.ok(Number.isFinite(got), `gpu:"${key}" timeout:${timeout} returned ${got}`); // must fall back to the CPU rate, exactly like any other unknown gpu - assert.equal(got, timeout > 300 ? 0.102001 : 0.012, `gpu:"${key}" must fall back to the CPU rate`); + assert.equal(got, timeout > 300 ? 0.252 : 0.012, `gpu:"${key}" must fall back to the CPU rate`); } } }); @@ -100,16 +107,16 @@ test("estimateModalCost prices tab/LF/CR-obfuscated sandbox/create as a create, const BASE = "https://blockrun.ai/api/v1/modal/"; for (const raw of ["sandbox/cre\tate", "sandbox/cr\neate", "sandbox\r/create"]) { assert.equal(new URL(BASE + raw).pathname, "/api/v1/modal/sandbox/create", raw); - assert.equal(estimateModalCost(raw, { timeout: 86400, gpu: "H100" }), 192.002, raw); + assert.equal(estimateModalCost(raw, { timeout: 86400, gpu: "H100" }), 216.002, raw); } }); test("estimateModalCost decodes percent-escapes, which the gateway router resolves", () => { // fetch() forwards %63 untouched; the gateway decodes it when routing, so // this reaches the same create handler. - assert.equal(estimateModalCost("sandbox/%63reate", { timeout: 86400, gpu: "H100" }), 192.002); - assert.equal(estimateModalCost("modal/sandbox/create/", { timeout: 86400, gpu: "H100" }), 192.002); - assert.equal(estimateModalCost("SANDBOX/CREATE", { timeout: 86400, gpu: "H100" }), 192.002); + assert.equal(estimateModalCost("sandbox/%63reate", { timeout: 86400, gpu: "H100" }), 216.002); + assert.equal(estimateModalCost("modal/sandbox/create/", { timeout: 86400, gpu: "H100" }), 216.002); + assert.equal(estimateModalCost("SANDBOX/CREATE", { timeout: 86400, gpu: "H100" }), 216.002); // One decode only — %2563reate is not %63reate is not create. assert.equal(estimateModalCost("sandbox/%2563reate", { timeout: 86400, gpu: "H100" }), 0.003); }); diff --git a/test/modal-gpu-trim.test.ts b/test/modal-gpu-trim.test.ts index 13c6244..ec45366 100644 --- a/test/modal-gpu-trim.test.ts +++ b/test/modal-gpu-trim.test.ts @@ -67,7 +67,7 @@ mock.module("../src/utils/http.js", { accountBodies.push(JSON.parse(init.body ?? "{}")); return new Response(JSON.stringify({ sandbox_id: "sb-1" }), { status: 200, - headers: { "content-type": "application/json", "x-blockrun-cost-usd": "192.000000" }, + headers: { "content-type": "application/json", "x-blockrun-cost-usd": "216.000000" }, }); }, isTimeoutError: () => false, @@ -95,11 +95,11 @@ const PADDED = [" H100", "H100 ", " H100 ", "H100\n", "\tH100", " H100", "H100\ test("estimateModalCost prices a whitespace-padded gpu exactly like the bare tier (the gateway trims)", () => { // The bare figures are the gateway's own quotes (see modal-cost.test.ts): - // 24h H100 $192.002, 1h H100 $8.001 charged / $8.002 reserved, flat H100 $0.402. - assert.equal(estimateModalCost("sandbox/create", { timeout: 86400, gpu: "H100" }), 192.002); + // 24h H100 $216.002, 1h H100 $9.001 charged / $9.002 reserved, flat H100 $0.402. + assert.equal(estimateModalCost("sandbox/create", { timeout: 86400, gpu: "H100" }), 216.002); for (const timeout of [86400, 3600, 300]) { const bare = estimateModalCost("sandbox/create", { timeout, gpu: "H100" }); - assert.ok(bare >= (timeout > 300 ? 8 * (timeout / 3600) : 0.4), `precondition: bare H100 at ${timeout}s reserves the H100 rate`); + assert.ok(bare >= (timeout > 300 ? 9 * (timeout / 3600) : 0.4), `precondition: bare H100 at ${timeout}s reserves the H100 rate`); for (const gpu of PADDED) { assert.equal(estimateModalCost("sandbox/create", { timeout, gpu }), bare, `${JSON.stringify(gpu)} at ${timeout}s`); } @@ -130,8 +130,8 @@ test("the body that leaves this process carries the TRIMMED gpu on the Base rail assert.equal(walletBodies.length, 1); assert.deepEqual(walletBodies[0], { gpu: "H100", timeout: 86400, image: "python:3.11" }); // Wallet rail reports no settled figure, so the ledger books the reserve's - // ledgerFallback — of the H100 price, not the CPU one. 192.002 - 0.002 + 0.001. - assert.ok(budget.spent > 190, `ledger booked $${budget.spent}, not the H100 figure`); + // ledgerFallback — of the H100 price, not the CPU one. 216.002 - 0.002 + 0.001. + assert.ok(budget.spent > 210, `ledger booked $${budget.spent}, not the H100 figure`); }); test("the same on the account rail: trimmed body, and the reserve gate sees the H100 price", async () => { @@ -147,7 +147,7 @@ test("the same on the account rail: trimmed body, and the reserve gate sees the assert.equal(accountBodies.length, 1); assert.deepEqual(accountBodies[0], { gpu: "H100", timeout: 86400 }); assert.equal(walletBodies.length, 0, "an account call must not touch the wallet client"); - assert.equal(budget.spent, 192, "account rail books the settled x-blockrun-cost-usd"); + assert.equal(budget.spent, 216, "account rail books the settled x-blockrun-cost-usd"); }); // The gateway 400s every gpu outside its five tiers BEFORE payment — including