Pick context blocks that fit a token budget, keeping mandatory blocks and their dependencies
Chooses which context items an agent should put into a prompt without exceeding a token budget: every mandatory item and everything it depends on is always included, then optional items by descending priority (each with the dependencies it pulls in) while they fit. Token counts come from the caller or from o200k_base / cl100k_base; any other tokenizer name returns unsupported (there is no Claude tokenizer, so nothing is estimated). Greedy by priority, not an optimal knapsack; per-item counts are summed and do not model merges across item boundaries (use perItemOverhead for separators). Does not summarize or rewrite items.
What you get
Stops context overflow and dropped dependencies before the model call. 500 items per $0.005 call.
Call it
Send the JSON body below to https://agents.writerslogic.com/api/v1/context-pack. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.
curl -i -X POST https://agents.writerslogic.com/api/v1/context-pack \
-H 'content-type: application/json' \
-d '{"items":[{"id":"system","tokens":300,"mandatory":true},{"id":"schema","tokens":500,"dependsOn":["system"],"priority":5},{"id":"history","tokens":4000,"priority":1},{"id":"notes","text":"Customer prefers email.","priority":3}],"budget":1000,"tokenizer":"o200k_base"}'
Input
| Field | Type | Required | Description |
|---|---|---|---|
items | array<object>; max 500 items | yes | Up to 500 items, 300000 characters of text in total. |
budget | integer; 1..100000000 | yes | Maximum total tokens (including perItemOverhead per included item). |
tokenizer | string; length 0..64 | no | o200k_base or cl100k_base. Any other name (including Claude models) returns status unsupported for items that need counting; caller token counts are always accepted. |
perItemOverhead | integer; 0..100000 | no | Tokens added per included item for separators or wrappers. Default 0. |
Example request body
{
"items": [
{
"id": "system",
"tokens": 300,
"mandatory": true
},
{
"id": "schema",
"tokens": 500,
"dependsOn": [
"system"
],
"priority": 5
},
{
"id": "history",
"tokens": 4000,
"priority": 1
},
{
"id": "notes",
"text": "Customer prefers email.",
"priority": 3
}
],
"budget": 1000,
"tokenizer": "o200k_base"
}
Result
The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass. |
budget | integer | no | |
usedTokens | integer | no | Total of included items; never above budget when status is pass. |
remainingTokens | integer | no | |
included | array<object>; max 500 items | no | In input order. |
excluded | array<object>; max 500 items | no | |
mandatoryTokens | integer | no | Cost of the mandatory items and their dependencies. |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always true: pure code, no model. |
Pay and connect
Available through: x402 (USDC on Base), MCP. MCP clients reach it through the context-evidence-kit package.
Machine-readable
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent