Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## Franklin Agent 3.49.29 — Modal: no signing without a price, the real charge in the result, terminate refunds nothing

Upgrade if you use Modal sandboxes. Follow-ups to 3.49.28.

- **ModalTerminate no longer implies it saves money.** Its tool text said Modal
bills GPU time until the sandbox is terminated. ModalCreate charges the whole
requested `timeout` upfront and terminating early refunds nothing, so a model
reading the old text could pick a 24 h lifetime expecting to stop the meter
early. It now says terminate stops the sandbox and frees resources, refunds
nothing, and that the timeout should be chosen at create. It also no longer
claims that sandboxes are terminated automatically at session end.
- **`gpu: ""` cannot bypass the quote check.** An empty gpu priced as nothing:
the confirm dialog crashed, and with no dialog the call went out with no
wallet reservation and no quote ceiling. A blank gpu now means CPU, and any
other value must name a GPU tier. Every Modal call now refuses to sign when
Franklin cannot compute the expected price, instead of signing whatever the
gateway asks.
- **The "charged:" line shows what was paid.** It showed Franklin's list price,
which is the Solana rate; the Base gateway's hourly rates are lower (A100 for
600 s: $0.667667 on Base, shown as $1.17). Franklin now reports the gateway's
stated charge, or else the exact quote it signed, and labels the list price
as an estimate when neither is available. `franklin stats` records the same
figure.
- **Exec, status and terminate reserve what they may sign**: the price plus the
Base $0.001 fee, as create already did.
- **"flat floor" wording.** A large or long create whose hourly price is below
the flat rate now says it is charged the flat floor, instead of quoting the
flat-rate conditions it does not meet.
- **A refused ModalTerminate is an error.** When the quote check refuses a
terminate, or the gateway answers 5xx, the result is an error and the
sandbox stays in the session's list instead of being reported as done.

## Franklin Agent 3.49.28 — Modal sandboxes can live up to 24 hours, and Franklin never signs more than it expected

Upgrade if you use Modal sandboxes.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockrun/franklin",
"version": "3.49.28",
"version": "3.49.29",
"description": "Franklin Agent — The AI agent with a wallet. Spends USDC autonomously to get real work done. Pay per action, no subscriptions.",
"type": "module",
"exports": {
Expand Down
9 changes: 5 additions & 4 deletions src/agent/tool-guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,11 @@ export class SessionToolGuard {
scope: ExecutionScope
): Promise<CapabilityResult | null> {
// Hard-block tools that have failed too many times this session.
// Modal lifecycle tools are exempt: orphan sandboxes keep billing
// GPU time, and ModalTerminate is the only way to recover from
// agent-side. Auto-disabling it after 3 transient errors would
// strand a $0.40/hr H100 until the session ends. Same logic for
// Modal lifecycle tools are exempt: ModalTerminate is the only way to
// stop a sandbox agent-side. A sandbox's whole lifetime is charged
// upfront at create (terminating refunds nothing), but auto-disabling
// ModalTerminate after 3 transient errors would leave a GPU sandbox
// running, holding resources, until its timeout. Same logic for
// media-gen tools: failures are usually transient (gateway hiccup,
// prompt rejection) and the user often wants to retry.
const FAILURE_EXEMPT = new Set([
Expand Down
296 changes: 218 additions & 78 deletions src/tools/modal.ts

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/wallet/reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,15 @@ class WalletReservationManager {
* Try to reserve `amountUsd`. Returns a token on success, or null if
* insufficient (balance - already-reserved < amountUsd). Caller MUST
* release the token after the actual payment resolves, success or fail.
*
* Throws on an amount that is not a finite number. A NaN hold used to be
* granted (every comparison with NaN is false) and then poisoned the
* reserved total, so every later hold passed whatever the balance.
*/
async hold(amountUsd: number): Promise<ReservationToken | null> {
if (typeof amountUsd !== 'number' || !Number.isFinite(amountUsd)) {
throw new RangeError(`cannot reserve a non-finite amount (${String(amountUsd)})`);
}
if (amountUsd <= 0) {
// Free / zero-cost calls don't need accounting.
return { id: `free-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, amountUsd: 0 };
Expand Down
14 changes: 8 additions & 6 deletions test/local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3511,13 +3511,13 @@ test('paid media and Modal tools pass measured latency to recordUsage', async ()
'all four Modal paid calls must capture start time');
assert.equal((modal.match(/latencyMs = Date\.now\(\) - callStartedAt/g) ?? []).length, 4,
'all four Modal paid calls must compute latency');
assert.match(modal, /recordUsage\(`modal\/\$\{tier\}`, 0, 0, price, latencyMs\)/,
assert.match(modal, /recordUsage\(`modal\/\$\{tier\}`, 0, 0, charge\.usd, latencyMs, false, charge\.estimated\)/,
'ModalCreate recordUsage must receive latencyMs');
assert.match(modal, /recordUsage\('modal\/exec', 0, 0, EXEC_PRICE_USD, latencyMs\)/,
assert.match(modal, /recordUsage\('modal\/exec', 0, 0, charge\.usd, latencyMs, false, charge\.estimated\)/,
'ModalExec recordUsage must receive latencyMs');
assert.match(modal, /recordUsage\('modal\/status', 0, 0, STATUS_PRICE_USD, latencyMs\)/,
assert.match(modal, /recordUsage\('modal\/status', 0, 0, charge\.usd, latencyMs, false, charge\.estimated\)/,
'ModalStatus recordUsage must receive latencyMs');
assert.match(modal, /recordUsage\('modal\/terminate', 0, 0, TERMINATE_PRICE_USD, latencyMs\)/,
assert.match(modal, /recordUsage\('modal\/terminate', 0, 0, charge\.usd, latencyMs, false, charge\.estimated\)/,
'ModalTerminate recordUsage must receive latencyMs');
});

Expand Down Expand Up @@ -13109,6 +13109,8 @@ test('modalCreatePriceUsd bills a lifetime above 300 s hourly at any size, CPU i
assert.equal(h.model, 'hourly');
assert.equal(h.hourlyRateUsd, 9);
assert.ok(close(h.priceUsd, 9 * 301 / 3600));
// Hourly-eligible (8 cores) but below the flat floor: the floor wins and the model says flat.
assert.deepEqual(modalCreatePricing('T4', 8, undefined, 10), { priceUsd: 0.05, model: 'flat' });
// Hourly-eligible (8 cores) but below the flat floor: the floor wins, the model
// says flat, and flatFloor marks that the flat-eligibility rule does not apply.
assert.deepEqual(modalCreatePricing('T4', 8, undefined, 10), { priceUsd: 0.05, model: 'flat', flatFloor: true });
assert.deepEqual(modalCreatePricing('T4', 1, 1024, 300), { priceUsd: 0.05, model: 'flat' }, 'genuinely flat-eligible: no floor flag');
});
Loading
Loading