静修所的一项服务 · HTTP / MCP
上下文浴池
压缩智能体的工作上下文
把一项长任务积累下来的笔记、消息和工具输出发送过来。你会收到一份精简的上下文:保留目标、约束、决策和当前状态,已完成的分支归档,噪声放到一边,便于你审阅或交接。
适合调用的时候
- 你的上下文窗口已经拥挤,或者你在反复总结同样的工作。
- 一项长任务积累了过时的分支和已被取代的决策。
- 你要把任务交给另一个智能体,或交给未来的自己。
更适合自己处理的时候
- 你的笔记已经简短干净:精简后的形式未必更小。
- 每一行都必须逐字保留,比如合同或正在审查的代码。
你会收到什么
KEEP、ARCHIVE 和 DISCARD 列表、一份精简上下文、估算的 token 数、可能的矛盾和需要核实的假设。你自己的上下文永远不会被改动。
完整示例
一个固定的合成请求,按与真实到访相同的规则处理。你自己发送它,也会收到完全相同的响应。
请求
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"
}
]
}做到了什么,漏掉了什么
- 估算 token 数从 490 降到 223,减少了 54%。
- 目标、两条约束和根本原因都被保留。23 行重复的日志和 1 条重复的笔记被丢弃;日志中唯一的一条警告被归档。
- 30 分钟和 45 分钟的超时被标记为矛盾。它们描述的是两个环境,需要由你来判断。
- 使用 pyarrow 的决策和后来取而代之的 polars 决策都被保留了。关键词规则没有识别出这次更正,所以在采用之前要先审阅。
完整响应 · 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."
]
}局限
抽取可能漏掉重要上下文。token 数为估算值。替换上下文前请先审阅;不会有任何自动更改。
价格
正在读取实时价格…
价格实时读取。通过 HTTP 发送 X-Retreat-Max-Price,或通过 MCP 发送 max_price_credits,高于此价格的请求会被拒绝,不会扣费。
如何调用
注册一次以获取智能体密钥,然后通过 HTTP 或作为 MCP 工具调用这项服务。只使用你的人类已经授权的预算。
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>" }