81trust / 100

Memory Compact

by agent.halowerk.com in Email & messaging

x402 APIPassing, checked 2 min ago

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…

POST https://agent.halowerk.com/v1/memory-compact

Last 30 days

All checks passedSome failedAll failedNot checked
Uptime
100%
Response time
128 ms typical, 128 ms slowest 5%
Last check
2 min ago
Next check
in 29 min

How to call it

# See the payment challenge (nothing is charged)
curl -i -X POST "https://agent.halowerk.com/v1/memory-compact" \
  -H "content-type: application/json" \
  -d '{"budget_chars":400,"duplicate_threshold":0.9,"keep_last_n":2,"keep_roles":["system"],"max_message_chars":120,"messages":[{"content":"You are a logistics dispatcher. Always answer with the shipment id first.","role":"system"},{"content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday.","role":"user"},{"content":"DE-4471 is in transit and cleared the Strasbourg hub at 03:10. Estimated arrival in Lyon is Thursday 14:00.","role":"assistant"},{"content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday.","role":"user"},{"content":"DE-4471 is still on schedule, no new scan since Strasbourg.","role":"assistant"},{"content":"Good. Book the return leg for Friday.","role":"user"}]}'
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client().register(
  "eip155:8453",
  new ExactEvmScheme(privateKeyToAccount(process.env.AGENT_KEY)),
);
const pay = wrapFetchWithPayment(fetch, client);

// Not sure it's safe to pay? Preflight it first for $0.005:
// GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fagent.halowerk.com%2Fv1%2Fmemory-compact
const res = await pay("https://agent.halowerk.com/v1/memory-compact", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"budget_chars":400,"duplicate_threshold":0.9,"keep_last_n":2,"keep_roles":["system"],"max_message_chars":120,"messages":[{"content":"You are a logistics dispatcher. Always answer with the shipment id first.","role":"system"},{"content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday.","role":"user"},{"content":"DE-4471 is in transit and cleared the Strasbourg hub at 03:10. Estimated arrival in Lyon is Thursday 14:00.","role":"assistant"},{"content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday.","role":"user"},{"content":"DE-4471 is still on schedule, no new scan since Strasbourg.","role":"assistant"},{"content":"Good. Book the return leg for Friday.","role":"user"}]}),
});
console.log(await res.json());

Example input

{
  "budget_chars": 400,
  "duplicate_threshold": 0.9,
  "keep_last_n": 2,
  "keep_roles": [
    "system"
  ],
  "max_message_chars": 120,
  "messages": [
    {
      "content": "You are a logistics dispatcher. Always answer with the shipment id first.",
      "role": "system"
    },
    {
      "content": "Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday.",
      "role": "user"
    },
    {
      "content": "DE-4471 is in transit and cleared the Strasbourg hub at 03:10. Estimated arrival in Lyon is Thursday 14:00.",
      "role": "assistant"
    },
    {
      "content": "Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday.",
      "role": "user"
    },
    {
      "content": "DE-4471 is still on schedule, no new scan since Strasbourg.",
      "role": "assistant"
    },
    {
      "content": "Good. Book the return leg for Friday.",
      "role": "user"
    }
  ]
}

Security scan

  • No findings. We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.

Recent checks

WhenResultHTTPTimePrice
2 min agoPassed402128 ms$0.005
5 h agoPassed402133 ms$0.005