Repository navigation
fix(modal): sandbox lifetimes up to 24 h, never sign above the expected price (v3.49.28) - #248
Merged
Merged
Conversation
added 2 commits
November 13, 2026 23:28
…ve the expected price The gateways accept create timeouts from 10 to 86400 s (probed 2026-11-13: 86400 -> 402 quote, 86401 -> 400 on sol.blockrun.ai and blockrun.ai), but ModalCreate refused anything above 300 s and told the model the gateway would 400 it. - Lift the client cap to 86400 s (min 10, integer, cpu >= 0.125); default 300. - Tool text explains timeout is the BILLED lifetime: flat only at <= 300 s, <= 1 CPU and <= 1024 MB; otherwise hourly x the full requested lifetime, upfront, never below flat, no refund on early terminate. - modalCreatePricing mirrors getModalCreatePricing: the lifetime now decides flat vs hourly, and CPU sandboxes bill $0.25/h (a 24 h CPU create was priced $0.01 against a $6.00 quote). - postWithPayment takes the expected list price and refuses to sign a 402 quote above list + Base fee (or an unreadable one); all Modal calls pass it. ModalCreate reserves that same ceiling.
…e the expected price
VickyXAI
added a commit
that referenced
this pull request
Nov 14, 2026
…erminate refunds nothing (v3.49.29) (#249) * fix(modal): fail closed without a price, report the settled amount, terminate refunds nothing Follow-ups from the GLM 5.3 review of #248. - ModalTerminate's text said Modal bills wall-clock GPU time until terminate. The whole lifetime is charged upfront at create and terminate refunds nothing; the text now says so, and drops the claim that session-end cleanup terminates forgotten sandboxes (terminateAllSessionSandboxes has no caller). Same fix in the tool-guard and tracker comments. - gpu "" (or blank / null) priced tier "" as undefined: the confirm dialog threw, and headless the hold threw inside a swallowed catch, so the call ran with no reservation and no quote ceiling. Blank gpu is now CPU; a non-string or unknown gpu is rejected. modalCreatePricing throws on an unknown tier, maxSignableAtomic on a non-finite or negative price, hold() on a non-finite amount (a NaN hold was granted and poisoned the reserved total), ModalCreate computes price and ceiling before the dialog and refuses if either fails, and postWithPayment requires maxPriceUsd and refuses to sign without a computable ceiling. - The "charged:" line and recordUsage reported the sol list price. They now use x-blockrun-cost-usd, else the 402 quote that was signed, else the list price labeled as an estimate (Base A100 600 s: $0.667667, not $1.17). - exec / status / terminate hold the ceiling the guard may sign (list + fee + 1 unit), as create does. - A create that is not flat-eligible but priced at the flat floor says "flat floor" instead of quoting the flat-eligibility rule it breaks. - A 402 (quote refusal, failed signing) or 5xx on ModalTerminate is an error and the sandbox stays tracked; other 4xx stay benign. * chore: release v3.49.29 — Modal: fail closed without a price, report the settled charge, terminate refunds nothing --------- Co-authored-by: 1bcMax <viewitter@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ModalCreaterefused anytimeoutabove 300 s and told the model "Gateway rejects values > 300 with HTTP 400". That is false: the gateways accept 10 to 86400 s and bill longer lifetimes hourly. Also:Verified max lifetime (unpaid probes, 2026-11-13)
{"timeout":86400}{"timeout":86401}too_big, maximum 86400too_big, maximum 86400{"timeout":5}minimum 10minimum 10{"cpu":0.1}minimum 0.125Arc and nano carry the same schema (
MODAL_MAX_CREATE_TIMEOUT_SECONDS = 86_400) and the same rates as sol.Changes
timeoutis the billed lifetime: flat only at <= 300 s, <= 1 CPU and <= 1024 MB. Anything else pays hourly x the full requested lifetime, upfront, never below flat, with no refund on early terminate. Examples: 600 s A100 = $1.17, 1200 s H100 = $3.00, 86400 s H100 = $216. The ModalExec text no longer says the sandbox dies at 300 s.modalCreatePricingmirrors the gateway'sgetModalCreatePricing: the lifetime is part of flat eligibility, and CPU bills $0.25/h. Rates are sol/arc/nano's. Base's rates are lower, so these never under-reserve there.postWithPayment(…, maxPriceUsd)reads the 402 amount before signing. If it is abovelist + $0.001 Base fee(rounded up, +1 atomic unit for the gateway's hourly round-up), or unreadable, nothing is signed or sent, and the call returns 402quote_exceeds_expected. Create, exec, status, terminate and the session cleanup all pass their price.hourly: $9.00/h x 24.00 h, upfront, no refund…).maxTimeoutSecondsin the signer is the x402 authorization window, not the sandbox lifetime, so it is unchanged. A comment now says so.Tests
test/reservation.local.mjs(+10 tests): ceiling arithmetic; a quote over the ceiling is refused with no signer call and no paid request; refused at ceiling+1 and signed at the ceiling; the live sol and base quotes above all pass; an unreadable 402 is refused; ModalCreate sendstimeout: 86400unclamped and signs a $216 H100 quote; ModalCreate refuses a $6 quote for a default flat create; the reservation holds the hourly ceiling (a balance of $7.0005 refuses a $7 A100 hour); out-of-range timeout and cpu are rejected before any request.test/local.mjs: hourly-at-any-size pricing, CPU included, and the flat floor.npx tsc --noEmit: clean.npm test: 970 pass, 0 fail. The root package has no lint script.