Skip to content

[feat] Add generation cost estimates and project spend controls - #481

Open
bread-lxy wants to merge 16 commits into
ThinkFlowLab:mainfrom
bread-lxy:codex/spend-controls-188
Open

bread-lxy wants to merge 16 commits into
ThinkFlowLab:mainfrom
bread-lxy:codex/spend-controls-188

Conversation

@bread-lxy

Copy link
Copy Markdown
Contributor

Summary

This adds cost estimates for individual actions and the project, covering image, video, speech, music and editing tools that call models. Confirmation thresholds and project caps are opt-in.

  • Estimates use the selected model connection and request parameters. Candidate batches are priced together, and reference music lists transcription and music generation separately. Unpriced calls are shown as unknown.
  • The canvas, Agent and CLI share the same backend budget checks. Users can approve or cancel a pending batch, or raise the project cap and start it in one action. Approval stays with the user.
  • Call history keeps the original estimate and costs calculated from available usage. Queued jobs keep their reserved budget across restarts; cancellation releases reservations for calls that have not been submitted.
  • The canvas shows estimates before generation, and chat replies include a spend summary. Required approvals open in a dialog; a wallet icon opens spending controls and history.

Linked issue

Fixes #188

Labels

Suggested: type:feat, area:canvas, area:agent, area:provider.

Test plan

  • Targeted Python tests: 414 passed; 5 POSIX-dependent tests skipped on Windows.
  • Frontend: 973 tests passed. Production build, generated contracts, import boundaries, i18n, browser locale and manifest checks, and pre-commit over the PR diff passed.
  • Browser: project_spend.mjs, input_admission_review.mjs and video_review_regressions.mjs passed in Chinese and English. These cover spending decisions, the CLI review link, image inputs, assistant parameter rejection, video continuation and FastH3 first/last frames.
  • Left to CI: full Release checks on Linux, including bundled OpenCode integration and the remaining browser suites.

Evidence that it works

With the test price set to USD 0.40 per image:

  • A three-image batch is quoted at USD 1.20. No model requests are sent before approval. Approval sends three requests; cancellation sends none.

  • With USD 1.20 already recorded against a USD 2.00 cap, one confirmation raises the cap to USD 2.40 and starts the next USD 1.20 batch.

  • Chinese and English confirmation-dialog screenshots attached.

Chinese confirmation dialog

English confirmation dialog

Provider verification

Generation tests used local mock services through the normal HTTP adapters and project storage. No real-provider calls were made, so provider billing and live model output remain unverified.

Bilingual UI

  • Chinese and English UI strings, error messages and user guides are updated.

Assisted by Codex.

@github-actions github-actions Bot added area:agent Agent runtime, assistant chat and tools area:canvas Canvas, nodes and direct manipulation area:provider Model providers and generation protocols type:feat New capability or behaviour labels Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent runtime, assistant chat and tools area:canvas Canvas, nodes and direct manipulation area:provider Model providers and generation protocols type:feat New capability or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: show cost estimate and spend gates before generation

1 participant