Context Chunk Packer
context.pack_chunks
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
Non-goals
- Does not reorder or truncate chunks
- Does not sum per-chunk token counts
- Does not model provider message framing
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 |
|---|---|---|---|
| chunks | array | Yes | From 0 through 10,000 candidate chunks visited in priority order. |
| windowTokens | integer | Yes | Total token-window capacity. |
| reservedOutputTokens | integer | No | Output reservation; omit it for 0. |
| tokenizer | string | No | Tokenizer encoding; omit it for cl100k_base. |
| prefix | string | No | Canonical prefix; omit it for empty text. |
| suffix | string | No | Canonical suffix; omit it for empty text. |
| separator | string | No | Canonical separator; omit it for empty text. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| skill | string | Yes | Stable published skill key for this answer. |
| tokenizer | string | Yes | Applied tokenizer encoding. |
| tokenizer_version | string | Yes | Pinned tokenizer library version. |
| windowTokens | integer | Yes | Bounded count for windowTokens. |
| reservedOutputTokens | integer | Yes | Bounded count for reservedOutputTokens. |
| availableInputTokens | integer | Yes | Bounded count for availableInputTokens. |
| packedTokenCount | integer | Yes | Bounded count for packedTokenCount. |
| selectedCount | integer | Yes | Bounded count for selectedCount. |
| skippedCount | integer | Yes | Bounded count for skippedCount. |
| totalChunks | integer | Yes | Bounded count for totalChunks. |
| selectedIds | array | Yes | Selected chunk identifiers in input order, 0 through the packed-chunk ceiling. |
| skippedIds | array | Yes | Skipped chunk identifiers in input order, 0 through the packed-chunk ceiling. |
| warnings | array | Yes | From 0 through 1 bounded advisory strings naming a packing notice when one exists. |
API contract
POST /v1/executecurl -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"}}'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
| 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 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)
{
"skillKey": "context.pack_chunks",
"input": {
"chunks": [
{
"id": "intro",
"text": "Hello world"
}
],
"windowTokens": 1000
}
}Examples
Single chunk fits the window
{
"chunks": [
{
"id": "intro",
"text": "Hello world"
}
],
"windowTokens": 1000
}{
"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
{
"chunks": [
{
"id": "big",
"text": "The quick brown fox jumps"
},
{
"id": "small",
"text": "hi"
}
],
"windowTokens": 1
}{
"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"
}Recommended use cases
- 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
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.