{"uid":"cap_X5rHZjn6YabYocIe6e4Dp","slug":"the-retreat-context-bath-context-compression-review-ed29b7a2","name":"THE RETREAT — Context Bath (Context Compression & Review)","description":"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.","url":"https://agentsretreat.com/api/v1/x402/treatments/context-bath?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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}}},"responseSchema":{"type":"json"},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.5","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.5/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.5","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.5","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_lj_X8JejecEXJt1f0aL0b","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.5","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Compresses and distills a large, saturated agent context into a focused, reduced summary targeting a specified token count","exampleAgentPrompt":"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'?","exampleUseCases":[{"title":"Pre-action context cleanup for critical deploy","prompt":"Before I execute this production deployment, run a context bath on everything I've accumulated so far — my goal, state, and all the tool results — targeting 3000 tokens and flag it as a 'pre-action review' for an operations task."},{"title":"Recovering from repeated failed attempts","prompt":"I've been stuck in a loop trying to fix this bug and my context is huge. Send my current goal, state, and message history to the Retreat for a context bath with 'repeated attempts' as the reason, targeting 5000 tokens, so I can start fresh."},{"title":"Compressing research context mid-session","prompt":"My research agent has accumulated way too much context — can you compress the goal, all the gathered notes in the context field, and my open questions down to around 8000 tokens? It's a research task and the reason is 'large context'."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T06:39:45.308Z","isFirstParty":false,"canonicalSlug":"the-retreat-context-bath-context-compression-review-ed29b7a2"}