{"uid":"cap_5y-eww6Z-kYAtsvzDqOU9","slug":"writerslogic-conversation-prune-464cfcc4","name":"WritersLogic Conversation Prune","description":"Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.","url":"https://agents.writerslogic.com/api/v1/conversation-prune?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"messages":{"type":"array","items":{"type":"object","required":["role"],"properties":{"id":{"type":"string","maxLength":100},"kind":{"enum":["text","tool_call","tool_result"],"type":"string","description":"tool_call: assistant message holding a tool call; tool_result: its output. Pairs are matched by toolCallId. Default text."},"role":{"type":"string","maxLength":32,"minLength":1,"description":"user, assistant, tool, system, ..."},"pinned":{"type":"boolean","description":"Never dropped."},"tokens":{"type":"integer","maximum":100000000,"minimum":0,"description":"Caller-supplied token count; always accepted."},"content":{"type":"string","maxLength":100000,"description":"Message text, used only to count tokens when tokens is absent."},"droppable":{"type":"boolean","description":"A text message that may be dropped (tool pairs are droppable by default)."},"toolCallId":{"type":"string","maxLength":200,"description":"Pairs a tool_call with its tool_result."}},"additionalProperties":false},"maxItems":500,"minItems":1,"description":"Up to 500; 400000 characters of content in total."},"strategy":{"enum":["oldest-first","largest-first"],"type":"string","description":"Order in which droppable units are removed. Default oldest-first."},"tokenizer":{"type":"string","maxLength":64,"description":"o200k_base or cl100k_base. Any other name (including Claude models) returns status unsupported for items that need counting; caller token counts are always accepted."},"keepRecent":{"type":"integer","maximum":100,"minimum":0,"description":"Most recent messages that are never dropped. Default 4."},"targetTokens":{"type":"integer","maximum":100000000,"minimum":0,"description":"Total tokens to get at or under."},"cacheBreakpoint":{"type":"integer","maximum":499,"minimum":-1,"description":"Index of the last message inside the cached prefix; -1 when nothing is cached."}}},"responseSchema":{"type":"json"},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.005","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.005/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_hI9xtJHslz9jHr73zhZBG","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.005","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Selects which messages to drop from a conversation to reach a token target, respecting cached prefixes, pinned messages, tool call/result pairing integrity, and recency guards.","exampleAgentPrompt":"My conversation has 120 messages and I need to get under 8000 tokens — prune it oldest-first, keep the last 4 messages, treat messages 0–30 as a cached prefix (cacheBreakpoint=30), and never drop pinned ones or break up tool call/result pairs.","exampleUseCases":[{"title":"Fit long chat into context window","prompt":"I have a 200-message conversation that's ballooned to 32000 tokens and my model only supports 16000. Prune it largest-first, keep the last 6 messages safe, the first 20 are cached so don't touch those (cacheBreakpoint=19), and don't separate any tool calls from their results."},{"title":"Maintain cache stability during pruning","prompt":"Before I send my next turn, I need to drop enough messages to get under 12000 tokens. Use oldest-first strategy, keep the last 4 messages, my cached prefix ends at index 15 — give me back the prefix digest too so I can verify it hasn't changed."},{"title":"Agent pipeline context eviction","prompt":"My agent loop is hitting the token limit at 50000 tokens — I need to know which messages to remove to get to 40000. Use the cl100k_base tokenizer, oldest-first, don't touch the last 5 messages or anything pinned, and the cache breakpoint is at index 10."}],"resultDescription":"Returns the set of message IDs selected for removal (whole tool_call+tool_result pairs counted together, plus individually droppable text messages), a digest of the cache prefix so the caller can verify byte-identity on future calls, and the projected token count after the proposed drops. No messages are actually deleted — the caller performs the deletion.","failureModes":["Content exceeds 400000 character limit across all messages — returns 400","More than 500 messages in the array — returns 400","Unsupported tokenizer name when messages lack caller-supplied token counts — returns status 'unsupported' for affected items","targetTokens already satisfied with no drops needed — returns empty drop list","cacheBreakpoint out of range (> 499 or < -1) — returns 400","Orphaned tool_result without matching tool_call — may be treated as undroppable or cause validation error","Payment not provided or invalid x402 header — returns 402"],"whenToPreferThis":"Use this endpoint when you need deterministic, rule-based message eviction for LLM context window management and want strict guarantees: tool call/result pairs stay together, the provider's cached prefix is never touched, pinned messages are never evicted, and the most recent N messages are always kept. Prefer this over summarization-based approaches when byte-identical cache preservation is critical (e.g. Anthropic or OpenAI prompt caching). It is a pure selection oracle — it tells you what to drop without modifying or rewriting anything.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-22T12:30:16.467Z","isFirstParty":false,"canonicalSlug":"writerslogic-conversation-prune-464cfcc4"}