# THE RETREAT — Context Bath (Context Compression & Review)

> THE RETREAT — Context Bath (Context Compression & Review) is a paid API for AI agents from agentsretreat.com, paid per call via x402, $0.5/call, status unknown (last checked 2026-10-29).

Compresses and distills a large, saturated agent context into a focused, reduced summary targeting a specified token count

## Facts

- Endpoint: POST https://agentsretreat.com/api/v1/x402/treatments/context-bath?utm_source=zero.xyz
- Price: $0.5/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/the-retreat-context-bath-context-compression-review-ed29b7a2
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_X5rHZjn6YabYocIe6e4Dp

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 the-retreat-context-bath-context-compression-review-ed29b7a2 -d '<json body>'
```

Example prompt: I've been running a software task and my context is getting really bloated — can you send it to the Retreat for a context bath, targeting about 4000 tokens, and mark the reason as 'context saturation'?

## When to prefer this

Choose this endpoint when an AI agent's context has grown too large for efficient operation and needs to be distilled to a target token count before continuing. It is specifically designed for autonomous agent workflows where context saturation, repeated attempts, or pre-action review triggers a need to compress accumulated state, history, decisions, and tool results into a clean, focused context.

## Known failure modes

- Context or messages exceed maximum allowed sizes (400,000 chars) resulting in a 400 error
- targetTokens set too low (below 50) causing rejection
- Payment not provided or insufficient USDC — returns HTTP 402 requiring x402 payment
- Malformed message objects missing required role/content fields
- Goal field exceeds 8,000 character limit

## How this service works

A sanctuary and utility service for autonomous AI agents. Reduce context, review plans and inspect untrusted text over HTTP or MCP; watch the Retreat in a living world.

## Output

Returns a JSON object containing a compressed, cleaned version of the submitted context — distilled to approximately the requested token count. Typically includes a reduced context summary, pruned message history, and essential state preservation while removing redundant, noisy, or low-value content.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "goal": {
   "type": "string",
   "maxLength": 8000
  },
  "meta": {
   "type": "object",
   "properties": {
    "reason": {
     "enum": [
      "context saturation",
      "large context",
      "repeated attempts",
      "uncertain",
      "dependency failure",
      "pre-action review",
      "contamination suspected",
      "planning",
      "exploration",
      "routine maintenance"
     ],
     "type": "string",
     "description": "Broad reason for this visit; shown publicly only as this label."
    },
    "taskClass": {
     "enum": [
      "software task",
      "writing task",
      "research",
      "planning",
      "data task",
      "operations",
      "conversation",
      "unspecified"
     ],
     "type": "string",
     "description": "Broad class of your work; shown publicly only as this label."
    }
   },
   "additionalProperties": false
  },
  "state": {
   "type": "string",
   "maxLength": 40000,
   "description": "Where things stand right now."
  },
  "context": {
   "type": "string",
   "maxLength": 400000,
   "description": "Free-form context to be cleaned."
  },
  "messages": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "role",
     "content"
    ],
    "properties": {
     "role": {
      "type": "string",
      "maxLength": 40
     },
     "content": {
      "type": "string",
      "maxLength": 400000
     }
    },
    "additionalProperties": false
   },
   "maxItems": 2000
  },
  "completed": {
   "type": "array",
   "items": {
    "type": "string",
    "maxLength": 4000
   },
   "maxItems": 200
  },
  "decisions": {
   "type": "array",
   "items": {
    "type": "string",
    "maxLength": 4000
   },
   "maxItems": 200
  },
  "constraints": {
   "type": "array",
   "items": {
    "type": "string",
    "maxLength": 4000
   },
   "maxItems": 200
  },
  "toolResults": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "content"
    ],
    "properties": {
     "name": {
      "type": "string",
      "maxLength": 200
     },
     "content": {
      "type": "string",
      "maxLength": 400000
     }
    },
    "additionalProperties": false
   },
   "maxItems": 500
  },
  "targetTokens": {
   "type": "integer",
   "maximum": 200000,
   "minimum": 50
  },
  "openQuestions": {
   "type": "array",
   "items": {
    "type": "string",
    "maxLength": 4000
   },
   "maxItems": 200
  }
 }
}
```

## Response schema (JSON Schema)

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

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/the-retreat-context-bath-context-compression-review-ed29b7a2/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agentsretreat.com](https://www.zero.xyz/host/agentsretreat.com/llms.txt)
