Skip to content

fix: sf nodes extend price calculation#253

Merged
sigmachirality merged 2 commits into
mainfrom
cursor/node-extension-price-calculation-597f
May 27, 2026
Merged

fix: sf nodes extend price calculation#253
sigmachirality merged 2 commits into
mainfrom
cursor/node-extension-price-calculation-597f

Conversation

@sigmachirality
Copy link
Copy Markdown
Member

Fixes sf nodes extend command showing 10x inflated prices by correcting quote API parameters and price calculation logic.

The previous implementation incorrectly passed quantity: 8 (GPUs per node) to the quote API's quantity parameter (number of nodes), inflating each quote by 8x. Additionally, the multi-node total summed raw quote prices, which included an extra hour for duration flexibility, leading to a further ~1.25x overestimation. These compounded to a ~10x error.


Slack Thread

Open in Web Open in Cursor 

@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 26, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Feb 26, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  src/lib/nodes/extend.ts  24% smaller
  src/helpers/test/quote.test.ts  0% smaller

Two bugs caused the multi-node extend confirmation to display ~10x the
correct price:

1. The quote API was called with quantity=8 (GPUs per node) instead of
   quantity=1 (one node per quote). The API's quantity parameter means
   'number of nodes', not GPUs. This inflated each quote's total price
   by 8x.

2. The multi-node total was computed by summing raw quote prices, which
   include the full quoted duration. Because the quote request adds
   flexibility (up to +1 hour), a 4-hour request could yield 5-hour
   quotes, adding another ~1.25x. Combined: 8 * 1.25 = 10x.

Fix:
- Change quantity from 8 to 1 in the per-node getQuote call
- Normalize multi-node total using per-node-hour rates (via
  getPricePerGpuHourFromQuote) multiplied by the actual requested
  duration, matching the single-node code path

Co-authored-by: Daniel Tao <danieltaox@gmail.com>
@indent indent Bot force-pushed the cursor/node-extension-price-calculation-597f branch from 00d5889 to 713954d Compare May 27, 2026 00:34
@sigmachirality sigmachirality marked this pull request as ready for review May 27, 2026 00:39
@indent
Copy link
Copy Markdown
Contributor

indent Bot commented May 27, 2026

PR Summary

Fixes the sf nodes extend confirmation total, which displayed ~10× the actual extend cost for multi-node extends. Two stacking bugs caused the inflation: each per-node getQuote was called with quantity: 8 (the API param means nodes, not GPUs/node), and the multi-node total summed raw quote prices that included the quote's flexible duration window (+1h slack). After this PR the displayed estimate matches what the backend extend call will actually charge, and partial-liquidity cases are explicitly surfaced to the user.

  • src/lib/nodes/extend.ts: change per-node getQuote(quantity: 8) to quantity: 1 so each quote represents one node.
  • src/lib/nodes/extend.ts: rewrite the multi-node total to sum per-node-hour rates (via getPricePerGpuHourFromQuote * GPUS_PER_NODE / 100) and multiply by the user's requested duration, mirroring the single-node display path. Uses .toFixed(2) for consistency with the per-node-hr branch.
  • src/lib/nodes/extend.ts: when some per-node quotes return null (no liquidity), append (estimate covers N of M nodes; remaining nodes will extend up to --max-price) so the displayed total isn't silently understated when the extend loop still attempts every node.
  • src/helpers/test/quote.test.ts: new vitest coverage for getPricePerGpuHourFromQuote quantity-invariance, the corrected multi-node total, duration-flexibility safety, and a documenting test for the historical ~10× bug shape.

Issues

All clear! No issues remaining. 🎉

2 issues already resolved
  • totalEstimate.toFixed(0) rounds the multi-node total to whole dollars, dropping cents the old totalPrice / 100 would have printed (e.g. a $76.80 estimate now reads ~$77); reasonable for an "~$" preview, but confirm this precision loss is intentional. (fixed by commit 61cb8e5)
  • Null-valued quotes silently understate the multi-node total: getQuote can resolve to null (no liquidity for that node), and those fulfilled-but-null entries are skipped by the new reducer, while the extend loop still attempts every node up to --max-price — so partial-capacity scenarios will display a price for fewer nodes than the user actually pays for. Triggers whenever any per-node quote returns null. (fixed by commit 61cb8e5)

CI Checks

All CI checks pass for commit 61cb8e5.

@sigmachirality sigmachirality changed the title Node extension price calculation fix: Node extension price calculation May 27, 2026
@sigmachirality sigmachirality self-assigned this May 27, 2026
Comment thread src/lib/nodes/extend.ts Outdated
Comment thread src/lib/nodes/extend.ts Outdated
- Surface "estimate covers N of M nodes" when any per-node getQuote returns
  null so the displayed total doesn't silently understate the bill when some
  nodes hit no-liquidity but the extend loop still attempts them up to
  --max-price.
- Switch the multi-node total from .toFixed(0) to .toFixed(2) to match the
  single-node /node/hr display.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 27, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@sigmachirality sigmachirality changed the title fix: Node extension price calculation fix: sf nodes extend price calculation May 27, 2026
@sigmachirality sigmachirality merged commit b7c118c into main May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants