Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Token Budget Allocator

context.allocate_budget

ProductionBounded custom (Class B)Deterministicstrictinstantv1.0.0
No network

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

Note
Splits an integer token budget across named items using minimums, caps, and weights.

Non-goals

  • Does not count tokens in text
  • Does not truncate or select content
  • Does not apply hidden heuristics

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

analysisdata-transformation

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input1.9 MB

How we handle your data

Sensitive input, safe output
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
totalBudgetintegerYesTotal integer token budget.
reserveintegerNoTokens withheld before allocation; omit it for 0.
itemsarrayYesFrom 0 through 10,000 consumers allocated in caller order, each a closed id with optional min and max.

Output schema

FieldTypeRequiredDescription
skillstringYesStable published skill key for this answer.
feasiblebooleanYesWhether every minimum fits.
distributableintegerYesBounded token count for distributable.
allocatedTotalintegerYesBounded token count for allocatedTotal.
unallocatedintegerYesBounded token count for unallocated.
shortfallintegerYesBounded token count for shortfall.
allocationsarrayYesOne allocation per input item in caller order, each a closed id and allocated token count.
warningsarrayYesFrom 0 through 10 safe advisory strings; currently always empty because allocation has none.

API contract

POST /v1/execute
curl
curl -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}]}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "skillKey": "context.allocate_budget",
  "input": {
    "items": [
      {
        "id": "a"
      },
      {
        "id": "b"
      },
      {
        "id": "c"
      }
    ],
    "totalBudget": 1000
  }
}

Examples

Even split across three items

Inputjson
{
  "items": [
    {
      "id": "a"
    },
    {
      "id": "b"
    },
    {
      "id": "c"
    }
  ],
  "totalBudget": 1000
}
Expected outputjson
{
  "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

Inputjson
{
  "totalBudget": 1000,
  "items": [
    {
      "min": 50,
      "id": "system"
    },
    {
      "id": "context",
      "weight": 3
    },
    {
      "id": "output",
      "weight": 1
    }
  ],
  "reserve": 100
}
Expected outputjson
{
  "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
}
  • 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

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.

Tags

context-windowanalysis