mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
## Why The cost-tracking audit on 2026-04-23 ([Platform System Credentials](https://www.notion.so/auto-gpt/4d251f343fe146bcb91b6a037d1bfc3c)) surfaced three gaps where the user wallet was silently subsidising third-party spend: 1. **Ayrshare (13 blocks)** — zero charge on every social post. No `BLOCK_COSTS` entry, no SDK `.with_base_cost` registration. Platform absorbs the entire ~$149/mo Business plan. 2. **Bannerbear** — flat 1 credit/call below the ~$0.025/image unit cost on the Starter tier ($49/mo / 2K images). 3. **JinaChunkingBlock** — wallet-free; siblings (`JinaEmbeddingBlock`, `SearchTheWebBlock`) are charged. ## What - New `backend/blocks/ayrshare/_cost.py` with two-tier `AYRSHARE_POST_COSTS` (5 credits when `is_video=True`, 2 credits otherwise — first-match wins in `block_usage_cost`). - All 13 `PostTo*Block` classes decorated with `@cost(*AYRSHARE_POST_COSTS)`. - `BannerbearTextOverlayBlock` floor: 1 → 3 credits in `bannerbear/_config.py`. - `JinaChunkingBlock` added to `BLOCK_COSTS` with a flat 1-credit floor. - `cost(...)` decorator generic-ized via `TypeVar`, so pyright retains `PostToXBlock.Input/Output` narrowing. ## How Ayrshare uses a decorator-based registration (not a direct `BLOCK_COSTS` entry) because each `post_to_*.py` block imports from `backend.sdk`, and `backend.sdk.cost_integration` imports `BLOCK_COSTS` — listing the blocks in `block_cost_config.py` would create a circular import. The `@cost` decorator defined in `sdk/cost_integration.py` was already the approved escape hatch for this exact shape. cost_filter in `block_usage_cost` already supports boolean-field matching (see Apollo's `enrich_info` tier), so `{"is_video": True}` and `{"is_video": False}` select the right tier at execution time. `is_video` defaults to `False` on `BaseAyrshareInput`, so posts that omit the field still land on the 2-credit default. ## Test plan - [x] `poetry run pytest backend/data/block_cost_config_test.py` — new 6-test suite covers Ayrshare video/non-video/default tiers, the Bannerbear floor, and the Jina chunking floor - [x] `poetry run pytest backend/executor/manager_cost_tracking_test.py` — no regressions (45 pre-existing tests still pass) - [x] `poetry run ruff format` + `poetry run isort` + `poetry run ruff check --fix` - [x] `poetry run pyright` on touched files — 0 errors, 0 warnings (pre-existing `LlmModel.KIMI_K2_*` errors are on dev and unrelated) - [ ] Manual: run an Ayrshare post through the builder and confirm 2cr (text/image) vs 5cr (video) charge