# Halowerk Memory Compact

> Halowerk Memory Compact is a paid API for AI agents from agent.halowerk.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-10-11).

Compresses a conversation history to fit within a character budget by pinning, deduplicating, trimming, and dropping messages in fixed stages.

## Facts

- Endpoint: POST https://agent.halowerk.com/v1/memory-compact?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/halowerk-memory-compact-554ffd24
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_TAEAw87HZe5vVX_bkpGVF

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 halowerk-memory-compact-554ffd24 -d '<json body>'
```

Example prompt: Compact this conversation history to fit within a 12000 character budget — keep all system messages and the last 5 turns protected, trim unprotected messages to 400 characters each, and flag anything with over 90% word-overlap similarity as a duplicate so it gets dropped.

## When to prefer this

Choose this endpoint when you need deterministic, rule-based conversation history compression with explicit control over which messages survive (by role, recency, or pin flag), rather than summarization-based approaches that use an LLM and introduce non-determinism. Ideal for agent frameworks that must stay within a character or token budget while guaranteeing certain messages (e.g. system prompts, tool outputs) are never lost. Preferable over manual truncation because it runs four structured stages with cost accounting, making the compression auditable.

## Known failure modes

- Budget too small to fit even protected messages — returns error indicating budget_chars is insufficient
- Input messages array has fewer than 2 items — validation error
- A single message content exceeds 8000 characters — validation error
- max_message_chars set below 80 or above 4000 — schema validation error
- duplicate_threshold outside 0.5–1.0 range — validation error
- All messages are protected and already exceed budget — no reduction possible, error or full pass-through

## How this service works

Takes a message history and a character budget and returns a shortened history together with a full account of what it cost. Four stages run in fixed order: pin protects messages that must survive (roles listed in keep_roles, the last keep_last_n messages, and anything you marked pin), dedupe removes later near-duplicates of an earlier message of the same role using word-overlap similarity, trim shortens unprotected survivors to max_message_chars at the last sentence boundary, and drop removes…

## Output

Returns the compacted message array with the same structure as the input (including echoed ids and pin flags), plus a detailed cost object showing total characters used, how many messages were pinned, deduped, trimmed, and dropped, and the character savings from each stage.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "messages": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "role",
     "content"
    ],
    "properties": {
     "id": {
      "type": "string",
      "maxLength": 128,
      "description": "Optional caller-side identifier, echoed unchanged."
     },
     "pin": {
      "type": "boolean",
      "default": false,
      "description": "If true this message is protected: never trimmed, never dropped."
     },
     "role": {
      "enum": [
       "system",
       "user",
       "assistant",
       "tool"
      ],
      "type": "string",
      "description": "Speaker role."
     },
     "content": {
      "type": "string",
      "maxLength": 8000,
      "minLength": 1,
      "description": "Message text."
     }
    },
    "additionalProperties": false
   },
   "maxItems": 200,
   "minItems": 2,
   "description": "The conversation in order, oldest first."
  },
  "keep_roles": {
   "type": "array",
   "items": {
    "enum": [
     "system",
     "user",
     "assistant",
     "tool"
    ],
    "type": "string"
   },
   "default": [
    "system"
   ],
   "maxItems": 4,
   "description": "Roles whose messages are protected."
  },
  "keep_last_n": {
   "type": "integer",
   "default": 5,
   "maximum": 50,
   "minimum": 0,
   "description": "How many of the most recent messages are protected."
  },
  "budget_chars": {
   "type": "integer",
   "maximum": 400000,
   "minimum": 100,
   "description": "Character budget for the sum of all returned message contents."
  },
  "max_message_chars": {
   "type": "integer",
   "default": 400,
   "maximum": 4000,
   "minimum": 80,
   "description": "Length to which unprotected survivors are trimmed in the trim stage."
  },
  "duplicate_threshold": {
   "type": "number",
   "default": 0.9,
   "maximum": 1,
   "minimum": 0.5,
   "description": "Word-overlap ratio from which a later message of the same role counts as a near-duplicate of an earlier one."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/halowerk-memory-compact-554ffd24/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent.halowerk.com](https://www.zero.xyz/host/agent.halowerk.com/llms.txt)
