Skip to main content

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

MicroSkills Reference

Context Chunk Packer

context.pack_chunks

ProductionBounded custom (Class B)Deterministicverifiablefastv1.0.0
No network

Overview

When you have ranked context chunks and a token budget, we walk them in order and keep each one only if the full assembled rendering (prefix + selected chunks + separator + suffix) still fits after counting with your tokenizer (cl100k_base or o200k_base). Skipped chunks do not block later smaller ones. We return selected and skipped ids plus the packed token count — not the concatenated text. Do not use this to reorder, split, or truncate chunks.

Byte-pair token counts are not additive across joins. We admit a chunk only when the full rendering still fits, so you fill the window safely in priority order.

Reliability

VERIFIABLE — packedTokenCount is the exact count of the packed rendering on the pinned tokenizer (tokenizer_version returned). Selection is stable and deterministic for identical inputs on the same tokenizer version. Input validation errors (not retryable): unsupported tokenizer, chunk or affix too large, or projected rendering exceeds 2000000 chars — reduce input before retrying. One more refusal is about cost rather than size, and it is the one worth understanding before you send a large request: because a token count is not additive, admitting a chunk means counting the whole rendering again, so the work is the number of chunks multiplied by how much is already packed. Ten thousand chunks of two hundred characters is inside every limit above and still asks for billions of characters of counting, so a request projected past 32000000 bytes of counting is refused with the arithmetic in the message. Halving either the count or the size roughly quarters the work.

Context footprint

Up to 10000 chunks; returns ids and counts only, never concatenated text. A successful call costs 1 execution credit.

When to use it

When you have ordered candidate chunks and a token budget.

When you need reordering, summarization, or provider framing you have not included.

Powered by JTokkit, an open-source tokenizer reproducing OpenAI tiktoken encodings, with Squillify greedy full-rendering packing on top.

Scope

Note
Greedily packs ordered chunks that fit a token window, counting the full assembly each step.

Non-goals

  • Does not reorder or truncate chunks
  • Does not sum per-chunk token counts
  • Does not model provider message framing

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

data-transformationtext-processing

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
chunksarrayYesFrom 0 through 10,000 candidate chunks visited in priority order.
windowTokensintegerYesTotal token-window capacity.
reservedOutputTokensintegerNoOutput reservation; omit it for 0.
tokenizerstringNoTokenizer encoding; omit it for cl100k_base.
prefixstringNoCanonical prefix; omit it for empty text.
suffixstringNoCanonical suffix; omit it for empty text.
separatorstringNoCanonical separator; omit it for empty text.

Output schema

FieldTypeRequiredDescription
skillstringYesStable published skill key for this answer.
tokenizerstringYesApplied tokenizer encoding.
tokenizer_versionstringYesPinned tokenizer library version.
windowTokensintegerYesBounded count for windowTokens.
reservedOutputTokensintegerYesBounded count for reservedOutputTokens.
availableInputTokensintegerYesBounded count for availableInputTokens.
packedTokenCountintegerYesBounded count for packedTokenCount.
selectedCountintegerYesBounded count for selectedCount.
skippedCountintegerYesBounded count for skippedCount.
totalChunksintegerYesBounded count for totalChunks.
selectedIdsarrayYesSelected chunk identifiers in input order, 0 through the packed-chunk ceiling.
skippedIdsarrayYesSkipped chunk identifiers in input order, 0 through the packed-chunk ceiling.
warningsarrayYesFrom 0 through 1 bounded advisory strings naming a packing notice when one exists.

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.pack_chunks","input":{"chunks":[{"id":"c1","text":"First chunk."},{"id":"c2","text":"Second."}],"windowTokens":8000,"reservedOutputTokens":1000,"separator":"\n\n"}}'
Integrations
TypeScript SDK
import { Squillify } from "@squillify/sdk";

const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });

const { output } = await sq.execute("context.pack_chunks", {"chunks":[{"id":"intro","text":"Hello world"}],"windowTokens":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 reorder or truncate chunks
  • Does not sum per-chunk token counts
  • Does not model provider message framing
  • Reordering or summarizing chunks to fit
  • Splitting an oversized chunk without truncating it first

How to call

POST /v1/execute (requires authentication)

Request bodyjson
{
  "skillKey": "context.pack_chunks",
  "input": {
    "chunks": [
      {
        "id": "intro",
        "text": "Hello world"
      }
    ],
    "windowTokens": 1000
  }
}

Examples

Single chunk fits the window

Inputjson
{
  "chunks": [
    {
      "id": "intro",
      "text": "Hello world"
    }
  ],
  "windowTokens": 1000
}
Expected outputjson
{
  "reservedOutputTokens": 0,
  "selectedCount": 1,
  "skill": "context.pack_chunks",
  "totalChunks": 1,
  "availableInputTokens": 1000,
  "skippedIds": [],
  "warnings": [],
  "packedTokenCount": 2,
  "windowTokens": 1000,
  "selectedIds": [
    "intro"
  ],
  "skippedCount": 0,
  "tokenizer_version": "jtokkit-1.1.0",
  "tokenizer": "cl100k_base"
}

Oversized chunk skipped, smaller one packed

Inputjson
{
  "chunks": [
    {
      "id": "big",
      "text": "The quick brown fox jumps"
    },
    {
      "id": "small",
      "text": "hi"
    }
  ],
  "windowTokens": 1
}
Expected outputjson
{
  "reservedOutputTokens": 0,
  "selectedCount": 1,
  "skill": "context.pack_chunks",
  "totalChunks": 2,
  "availableInputTokens": 1,
  "skippedIds": [
    "big"
  ],
  "warnings": [],
  "packedTokenCount": 1,
  "windowTokens": 1,
  "selectedIds": [
    "small"
  ],
  "skippedCount": 1,
  "tokenizer_version": "jtokkit-1.1.0",
  "tokenizer": "cl100k_base"
}
  • Pack ranked RAG results into a context window
  • Fill a prompt in priority order while reserving output tokens
  • Decide which snippets to include before a model call

Avoid for

  • Reordering or summarizing chunks to fit
  • Splitting an oversized chunk without truncating it first

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-windowtext