Token Budget Allocator
context.allocate_budget
Overview
When you already know your total token budget and how important each section is, we split it across named items — honouring per-item minimums, optional maximums, and weights. Minimums are satisfied first; if they cannot all fit we return feasible=false with a shortfall instead of throwing. The remainder is shared by weight, capped at each item's max, with leftover whole tokens assigned by largest-remainder rounding (ties break in input order). Pure integer math — no tokenizer — do not use this to count tokens in text or to trim content.
Dividing a fixed context window by hand is error-prone. We apply one deterministic rule so your floors, caps, and weights stay consistent.
Reliability
STRICT and deterministic — identical inputs always yield identical allocations. When feasible=false, allocations are all zero and shortfall tells you how many tokens you are short; fix minimums, reserve, or totalBudget before retrying. Input validation errors (not retryable; unchanged retry will not succeed): out-of-range budget or reserve, duplicate item ids, max below min, or more than 10000 items — correct the input fields and retry.
Context footprint
Up to 10000 items; budgets, mins, and maxes in [0, 1000000000]. No text processed. A successful call costs 1 execution credit.
When to use it
When you know the total budget and how to split it across named consumers.
When you still need to measure token cost in text — count first, then allocate.
Squillify deterministic allocator (minimums-first, cap-aware weighting, largest-remainder rounding).
Scope
Non-goals
- Does not count tokens in text
- Does not truncate or select content
- Does not apply hidden heuristics
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response does not contain submitted content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| totalBudget | integer | Yes | Total integer token budget. |
| reserve | integer | No | Tokens withheld before allocation; omit it for 0. |
| items | array | Yes | From 0 through 10,000 consumers allocated in caller order, each a closed id with optional min and max. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| skill | string | Yes | Stable published skill key for this answer. |
| feasible | boolean | Yes | Whether every minimum fits. |
| distributable | integer | Yes | Bounded token count for distributable. |
| allocatedTotal | integer | Yes | Bounded token count for allocatedTotal. |
| unallocated | integer | Yes | Bounded token count for unallocated. |
| shortfall | integer | Yes | Bounded token count for shortfall. |
| allocations | array | Yes | One allocation per input item in caller order, each a closed id and allocated token count. |
| warnings | array | Yes | From 0 through 10 safe advisory strings; currently always empty because allocation has none. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"context.allocate_budget","input":{"totalBudget":128000,"reserve":8000,"items":[{"id":"system","min":500},{"id":"history","weight":2,"max":40000},{"id":"retrieval","weight":3}]}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("context.allocate_budget", {"items":[{"id":"a"},{"id":"b"},{"id":"c"}],"totalBudget":1000});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not count tokens in text
- Does not truncate or select content
- Does not apply hidden heuristics
- Measuring how many tokens text actually needs
- Non-integer or probabilistic allocation
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "context.allocate_budget",
"input": {
"items": [
{
"id": "a"
},
{
"id": "b"
},
{
"id": "c"
}
],
"totalBudget": 1000
}
}Examples
Even split across three items
{
"items": [
{
"id": "a"
},
{
"id": "b"
},
{
"id": "c"
}
],
"totalBudget": 1000
}{
"warnings": [],
"allocatedTotal": 1000,
"distributable": 1000,
"unallocated": 0,
"skill": "context.allocate_budget",
"feasible": true,
"allocations": [
{
"id": "a",
"allocated": 334
},
{
"id": "b",
"allocated": 333
},
{
"id": "c",
"allocated": 333
}
],
"shortfall": 0
}Minimums and weights with a reservation
{
"totalBudget": 1000,
"items": [
{
"min": 50,
"id": "system"
},
{
"id": "context",
"weight": 3
},
{
"id": "output",
"weight": 1
}
],
"reserve": 100
}{
"warnings": [],
"allocatedTotal": 900,
"distributable": 900,
"unallocated": 0,
"skill": "context.allocate_budget",
"feasible": true,
"allocations": [
{
"id": "system",
"allocated": 220
},
{
"id": "context",
"allocated": 510
},
{
"id": "output",
"allocated": 170
}
],
"shortfall": 0
}Recommended use cases
- Divide a context window across system, history, retrieval, and output roles
- Give each RAG source a weighted share with guaranteed floors
- Reserve output tokens before splitting the remainder
Avoid for
- Measuring how many tokens text actually needs
- Non-integer or probabilistic allocation
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.