# WritersLogic Context Packer

> WritersLogic Context Packer is a paid API for AI agents from agents.writerslogic.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-11-19).

Selects which context items to include in an LLM prompt given a token budget, always including mandatory items and their dependencies, then greedily filling with optional items by descending priority.

## Facts

- Endpoint: POST https://agents.writerslogic.com/api/v1/context-pack?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-19
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/writerslogic-context-packer-38af1ee0
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_LzIZD35cU6YOev3-LY6bU

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability writerslogic-context-packer-38af1ee0 -d '<json body>'
```

Example prompt: I have 15 candidate context chunks for my next LLM call — items c1 through c15 — with a token budget of 4000 using the cl100k_base tokenizer. Items c1 and c2 are mandatory, c3 depends on c1, and the rest have priorities between 1 and 10. Which items should I include, adding 5 tokens of overhead per item for separators?

## When to prefer this

Use this endpoint when you need deterministic, priority-ordered context selection for LLM prompts with hard token limits, especially when some items are mandatory, items have dependency relationships, and you need a fast greedy solution rather than an optimal knapsack. Prefer this over manual slicing when you have heterogeneous priorities, complex dependency graphs, or need reproducible packing logic. Not suitable when you need summarization or rewriting to fit content, or when you require an optimal (non-greedy) solution.

## Known failure modes

- Mandatory items plus their dependencies exceed the token budget — returns fail status
- Tokenizer name is not o200k_base or cl100k_base and no caller-supplied token counts provided — returns unsupported status for those items
- Circular dependency among items — may cause unexpected behavior or incomplete packing
- Item text missing and no caller-supplied token count — cannot count tokens for that item
- More than 500 items or 300,000 total characters of text — request rejected
- Token budget of 0 or negative — rejected by schema validation

## How this service works

Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.

## Output

Returns a list of selected item IDs that fit within the token budget (all mandatory items and their dependencies guaranteed, then highest-priority optional items and their dependencies greedily added), along with the total token count used, per-item token counts, and a status indicating success or failure (e.g. 'fail' if mandatory items plus dependencies exceed the budget, 'unsupported' if the tokenizer is unrecognized and caller-supplied token counts are unavailable).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "items": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "id"
    ],
    "properties": {
     "id": {
      "type": "string",
      "maxLength": 100,
      "minLength": 1,
      "description": "Unique id."
     },
     "text": {
      "type": "string",
      "maxLength": 100000,
      "description": "Content to count when tokens is not given."
     },
     "tokens": {
      "type": "integer",
      "maximum": 100000000,
      "minimum": 0,
      "description": "Caller-supplied token count; always accepted and used in preference to counting text."
     },
     "priority": {
      "type": "number",
      "maximum": 1000000,
      "minimum": -1000000,
      "description": "Higher is packed first among optional items. Default 0."
     },
     "dependsOn": {
      "type": "array",
      "items": {
       "type": "string",
       "maxLength": 100
      },
      "maxItems": 50,
      "description": "Ids that must be included whenever this item is."
     },
     "mandatory": {
      "type": "boolean",
      "description": "Always included, with its dependencies; if they cannot fit the result is fail."
     }
    },
    "additionalProperties": false
   },
   "maxItems": 500,
   "minItems": 1,
   "description": "Up to 500 items, 300000 characters of text in total."
  },
  "budget": {
   "type": "integer",
   "maximum": 100000000,
   "minimum": 1,
   "description": "Maximum total tokens (including perItemOverhead per included item)."
  },
  "tokenizer": {
   "type": "string",
   "maxLength": 64,
   "description": "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": {
   "type": "integer",
   "maximum": 100000,
   "minimum": 0,
   "description": "Tokens added per included item for separators or wrappers. Default 0."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/writerslogic-context-packer-38af1ee0/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agents.writerslogic.com](https://www.zero.xyz/host/agents.writerslogic.com/llms.txt)
