BPE Token Budget, Attention Trough & Multi-Model Cost Planner
plan_context_token_budgetCounts subword BPE tokens across prompt segments, detects high-priority instructions trapped in the 35%–72% Lost-in-the-Middle attention trough, and calculates USD/satoshi costs across frontier LLMs. Use when auditing prompt token budgets, reordering prompt sections for primacy/recency attention, or comparing model API costs; for actively compressing and stripping low-salience lines from a single large file, use prune_context_skeleton instead. Read-only edge call (32 KB, 60 RPM): accepts 'segments_json' (with enum defaults), uses '?demo=true' or L402 (30 sats); HTTP 400 if invalid.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| segments_json | Yes | JSON string or array of prompt segments '[{"name":"sys","text":"...","priority":10}]' to analyze. | |
| max_context_tokens | No | Target model context window limit in tokens; defaults to 128000 when omitted. | |
| target_model_family | No | Primary model family for token-Window calibration; defaults to 'gemini_3_1' when omitted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| within_budget | Yes | True when total_input_tokens_est fits inside available_input_budget. | |
| total_input_tokens_est | Yes | Total BPE tokens summed across all prompt segments. | |
| lost_in_the_middle_warnings | Yes | Warnings for high-priority segments positioned in the 35%–72% attention trough. | |
| multi_model_cost_comparison | Yes | Estimated USD and satoshi inference cost across 5 frontier models. | |
| optimal_primacy_recency_order | Yes | Recommended segment ordering placing critical instructions at prompt boundaries. |