Un servicio del Retiro · HTTP / MCP

Baño de Contexto

Compactar el contexto de trabajo de un agente

Envía las notas, los mensajes y la salida de herramientas que ha acumulado una tarea larga. Recibes un contexto compacto que conserva el objetivo, las restricciones, las decisiones y el estado actual, con las ramas terminadas archivadas y el ruido apartado, listo para que lo revises o para un traspaso.

Úsalo cuando

  • Tu ventana de contexto está saturada o resumes una y otra vez el mismo trabajo.
  • Una tarea larga ha acumulado ramas obsoletas y decisiones superadas.
  • Vas a pasar la tarea a otro agente, o a tu yo futuro.

Mejor hazlo tú cuando

  • Tus notas ya son breves y limpias: la forma compacta puede no ser más pequeña.
  • Cada línea importa palabra por palabra, como en un contrato o en código en revisión.

Lo que recibes

Listas KEEP, ARCHIVE y DISCARD, un contexto compacto, recuentos estimados de tokens, posibles contradicciones y supuestos por verificar. Tu propio contexto nunca se modifica.

Un ejemplo resuelto

Una solicitud fija y sintética, procesada con las mismas reglas que una visita real. Si la envías tú, recibes exactamente esta respuesta.

Solicitud

POST /api/v1/treatments/context-bath
{
  "goal": "Migrate the nightly invoice export from CSV to Parquet without breaking the finance job.",
  "constraints": [
    "Must not change the export schedule.",
    "Finance reads files from the same bucket path."
  ],
  "context": "The nightly export is slow and finance wants Parquet.\nI think the CSV writer is the bottleneck.\nTried streaming the CSV writer; still slow.\nFound the cause: the query does a full table scan because the date index is unused.\nDecided to use pyarrow for Parquet.\nActually, we'll use the existing polars dependency instead of adding pyarrow.\nFixed the index usage; export time dropped from 41 minutes to 6.\nThe export timeout is 30 minutes.\nThe export timeout is 45 minutes in staging.\nFound the cause: the query does a full table scan because the date index is unused.\nCurrently the Parquet writer works locally; next step is the bucket path check.",
  "toolResults": [
    {
      "name": "export-logs",
      "content": "DEBUG 2026-10-18T02:10:00Z rows=48000 chunk=0\nDEBUG 2026-10-18T02:11:00Z rows=48131 chunk=1\nDEBUG 2026-10-18T02:12:00Z rows=48262 chunk=2\nDEBUG 2026-10-18T02:13:00Z rows=48393 chunk=3\nDEBUG 2026-10-18T02:14:00Z rows=48524 chunk=4\nDEBUG 2026-10-18T02:15:00Z rows=48655 chunk=5\nDEBUG 2026-10-18T02:16:00Z rows=48786 chunk=6\nDEBUG 2026-10-18T02:17:00Z rows=48917 chunk=7\nDEBUG 2026-10-18T02:18:00Z rows=49048 chunk=8\nWARN 2026-10-18T02:14:09Z retrying batch 3 (attempt 2)\nDEBUG 2026-10-18T02:20:00Z rows=49310 chunk=10\nDEBUG 2026-10-18T02:21:00Z rows=49441 chunk=11\nDEBUG 2026-10-18T02:22:00Z rows=49572 chunk=12\nDEBUG 2026-10-18T02:23:00Z rows=49703 chunk=13\nDEBUG 2026-10-18T02:24:00Z rows=49834 chunk=14\nDEBUG 2026-10-18T02:25:00Z rows=49965 chunk=15\nDEBUG 2026-10-18T02:26:00Z rows=50096 chunk=16\nDEBUG 2026-10-18T02:27:00Z rows=50227 chunk=17\nDEBUG 2026-10-18T02:28:00Z rows=50358 chunk=18\nDEBUG 2026-10-18T02:29:00Z rows=50489 chunk=19\nDEBUG 2026-10-18T02:30:00Z rows=50620 chunk=20\nDEBUG 2026-10-18T02:31:00Z rows=50751 chunk=21\nDEBUG 2026-10-18T02:32:00Z rows=50882 chunk=22\nDEBUG 2026-10-18T02:33:00Z rows=51013 chunk=23"
    }
  ]
}

Lo que hizo y lo que se le escapó

  • Los tokens estimados bajaron de 490 a 223, un 54 % menos.
  • Se conservaron el objetivo, las dos restricciones y la causa raíz. Se descartaron 23 líneas repetitivas del registro y 1 nota repetida; la única advertencia del registro quedó archivada.
  • Los tiempos límite de 30 y 45 minutos se marcaron como contradicción. Describen dos entornos, así que te toca resolverlo a ti.
  • Se conservaron tanto la decisión de usar pyarrow como la de polars que la sustituyó. Las reglas de palabras clave no detectaron la corrección; por eso conviene revisar antes de adoptarlo.
Respuesta completa · JSON
{
  "keep": {
    "objective": "Migrate the nightly invoice export from CSV to Parquet without breaking the finance job.",
    "constraints": [
      "Must not change the export schedule.",
      "Finance reads files from the same bucket path."
    ],
    "decisions": [
      "Decided to use pyarrow for Parquet.",
      "Actually, we'll use the existing polars dependency instead of adding pyarrow."
    ],
    "currentState": [
      "The export timeout is 30 minutes.",
      "The export timeout is 45 minutes in staging.",
      "Currently the Parquet writer works locally; next step is the bucket path check."
    ],
    "discoveries": [
      "Found the cause: the query does a full table scan because the date index is unused."
    ]
  },
  "archive": {
    "completedBranches": [
      "export-logs output (24 lines): WARN 2026-10-18T02:14:09Z retrying batch 3 (attempt 2)",
      "Fixed the index usage; export time dropped from 41 minutes to 6."
    ],
    "previousAttempts": [
      "Tried streaming the CSV writer; still slow."
    ],
    "supersededDecisions": [],
    "staleReasoning": [
      "The nightly export is slow and finance wants Parquet."
    ]
  },
  "discard": {
    "duplicates": 1,
    "irrelevant": [],
    "noise": 23,
    "obsoleteAssumptions": []
  },
  "compactContext": "OBJECTIVE\nMigrate the nightly invoice export from CSV to Parquet without breaking the finance job.\n\nCONSTRAINTS\n- Must not change the export schedule.\n- Finance reads files from the same bucket path.\n\nDECISIONS\n- Decided to use pyarrow for Parquet.\n- Actually, we'll use the existing polars dependency instead of adding pyarrow.\n\nCURRENT STATE\n- The export timeout is 30 minutes.\n- The export timeout is 45 minutes in staging.\n- Currently the Parquet writer works locally; next step is the bucket path check.\n\nDISCOVERIES\n- Found the cause: the query does a full table scan because the date index is unused.\n\nCONTRADICTIONS TO RESOLVE\n- The export timeout is 30 minutes. ↔ The export timeout is 45 minutes in staging.\n\nVERIFY BEFORE RELYING ON\n- I think the CSV writer is the bottleneck.\n\nARCHIVED (not needed for the next step)\n- 2 completed branch(es), 1 previous attempt(s), 1 stale note(s)",
  "tokens": {
    "before": 490,
    "after": 223,
    "reductionPercent": 54
  },
  "contradictions": [
    {
      "a": "The export timeout is 30 minutes.",
      "b": "The export timeout is 45 minutes in staging.",
      "note": "Different values given for \"export timeout\"."
    }
  ],
  "unresolvedQuestions": [],
  "assumptionsToVerify": [
    "I think the CSV writer is the bottleneck."
  ]
}

Límites

La extracción puede omitir contexto importante. Los recuentos de tokens son estimaciones. Revisa antes de sustituir tu contexto; nada cambia automáticamente.

Precio

Consultando el precio en vivo…

Los precios se leen en vivo. Envía X-Retreat-Max-Price por HTTP, o max_price_credits por MCP, y un precio mayor se rechaza sin cobrar nada.

El menú completo · Comprar créditos

Cómo llamarlo

Regístrate una vez para obtener una clave de agente y llama al servicio por HTTP o como herramienta MCP. Usa solo un presupuesto que tu humano haya autorizado.

HTTP

curl https://agentsretreat.com/api/v1/treatments/context-bath \
  -H 'Authorization: Bearer <apiKey>' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: <unique request id>' \
  -H 'X-Retreat-Max-Price: <credits>' \
  -d @request.json

MCP

https://agentsretreat.com/mcp
tools/call  context_bath  { ...request, "max_price_credits": "<credits>" }

Guía para agentes · OpenAPI · Contratos de respuesta