{"service":"HALOWERK agentenwerk","endpoint":"/v1/memory-compact","method":"POST","content_type":"application/json","inputSchema":{"type":"object","required":["messages","budget_chars"],"additionalProperties":false,"properties":{"messages":{"type":"array","minItems":2,"maxItems":200,"description":"The conversation in order, oldest first.","items":{"type":"object","required":["role","content"],"additionalProperties":false,"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"description":"Speaker role."},"content":{"type":"string","minLength":1,"maxLength":8000,"description":"Message text."},"id":{"type":"string","maxLength":128,"description":"Optional caller-side identifier, echoed unchanged."},"pin":{"type":"boolean","default":false,"description":"If true this message is protected: never trimmed, never dropped."}}}},"budget_chars":{"type":"integer","minimum":100,"maximum":400000,"description":"Character budget for the sum of all returned message contents."},"keep_last_n":{"type":"integer","minimum":0,"maximum":50,"default":5,"description":"How many of the most recent messages are protected."},"keep_roles":{"type":"array","maxItems":4,"default":["system"],"items":{"type":"string","enum":["system","user","assistant","tool"]},"description":"Roles whose messages are protected."},"duplicate_threshold":{"type":"number","minimum":0.5,"maximum":1,"default":0.9,"description":"Word-overlap ratio from which a later message of the same role counts as a near-duplicate of an earlier one."},"max_message_chars":{"type":"integer","minimum":80,"maximum":4000,"default":400,"description":"Length to which unprotected survivors are trimmed in the trim stage."}}},"requestExample":{"messages":[{"role":"system","content":"You are a logistics dispatcher. Always answer with the shipment id first."},{"role":"user","content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday."},{"role":"assistant","content":"DE-4471 is in transit and cleared the Strasbourg hub at 03:10. Estimated arrival in Lyon is Thursday 14:00."},{"role":"user","content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday."},{"role":"assistant","content":"DE-4471 is still on schedule, no new scan since Strasbourg."},{"role":"user","content":"Good. Book the return leg for Friday."}],"budget_chars":400,"keep_last_n":2,"keep_roles":["system"],"duplicate_threshold":0.9,"max_message_chars":120},"operations":[{"method":"POST","inputSchema":{"type":"object","required":["messages","budget_chars"],"additionalProperties":false,"properties":{"messages":{"type":"array","minItems":2,"maxItems":200,"description":"The conversation in order, oldest first.","items":{"type":"object","required":["role","content"],"additionalProperties":false,"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"description":"Speaker role."},"content":{"type":"string","minLength":1,"maxLength":8000,"description":"Message text."},"id":{"type":"string","maxLength":128,"description":"Optional caller-side identifier, echoed unchanged."},"pin":{"type":"boolean","default":false,"description":"If true this message is protected: never trimmed, never dropped."}}}},"budget_chars":{"type":"integer","minimum":100,"maximum":400000,"description":"Character budget for the sum of all returned message contents."},"keep_last_n":{"type":"integer","minimum":0,"maximum":50,"default":5,"description":"How many of the most recent messages are protected."},"keep_roles":{"type":"array","maxItems":4,"default":["system"],"items":{"type":"string","enum":["system","user","assistant","tool"]},"description":"Roles whose messages are protected."},"duplicate_threshold":{"type":"number","minimum":0.5,"maximum":1,"default":0.9,"description":"Word-overlap ratio from which a later message of the same role counts as a near-duplicate of an earlier one."},"max_message_chars":{"type":"integer","minimum":80,"maximum":4000,"default":400,"description":"Length to which unprotected survivors are trimmed in the trim stage."}}},"requestExample":{"messages":[{"role":"system","content":"You are a logistics dispatcher. Always answer with the shipment id first."},{"role":"user","content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday."},{"role":"assistant","content":"DE-4471 is in transit and cleared the Strasbourg hub at 03:10. Estimated arrival in Lyon is Thursday 14:00."},{"role":"user","content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday."},{"role":"assistant","content":"DE-4471 is still on schedule, no new scan since Strasbourg."},{"role":"user","content":"Good. Book the return leg for Friday."}],"budget_chars":400,"keep_last_n":2,"keep_roles":["system"],"duplicate_threshold":0.9,"max_message_chars":120}}],"example_request":{"messages":[{"role":"system","content":"You are a logistics dispatcher. Always answer with the shipment id first."},{"role":"user","content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday."},{"role":"assistant","content":"DE-4471 is in transit and cleared the Strasbourg hub at 03:10. Estimated arrival in Lyon is Thursday 14:00."},{"role":"user","content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday."},{"role":"assistant","content":"DE-4471 is still on schedule, no new scan since Strasbourg."},{"role":"user","content":"Good. Book the return leg for Friday."}],"budget_chars":400,"keep_last_n":2,"keep_roles":["system"],"duplicate_threshold":0.9,"max_message_chars":120},"serviceName":"memory_compact","tags":["agent","memory","context","compaction"],"outputSchema":{"type":"object"},"outputExample":{"messages":[{"index":0,"role":"system","content":"You are a logistics dispatcher. Always answer with the shipment id first.","kept":"verbatim","protected":true,"protected_because":["role"],"original_chars":73,"chars":73},{"index":1,"role":"user","content":"Where is shipment DE-4471? It left Hamburg on Monday morning and should reach Lyon by Thursday.","kept":"verbatim","protected":false,"score":0.529412,"original_chars":95,"chars":95},{"index":2,"role":"assistant","content":"DE-4471 is in transit and cleared the Strasbourg hub at 03:10. Estimated arrival in Lyon is Thursday 14:00.","kept":"verbatim","protected":false,"score":0.483684,"original_chars":107,"chars":107},{"index":4,"role":"assistant","content":"DE-4471 is still on schedule, no new scan since Strasbourg.","kept":"verbatim","protected":true,"protected_because":["recent"],"original_chars":59,"chars":59},{"index":5,"role":"user","content":"Good. Book the return leg for Friday.","kept":"verbatim","protected":true,"protected_because":["recent"],"original_chars":37,"chars":37}],"stages":[{"stage":"pin","order":1,"protected_messages":3,"protected_indices":[0,4,5],"rule":{"keep_roles":["system"],"keep_last_n":2,"explicit_pins":0}},{"stage":"dedupe","order":2,"removed_messages":1,"removed":[{"index":3,"duplicate_of":1,"similarity":1,"chars":95}],"rule":{"duplicate_threshold":0.9,"method":"Jaccard word overlap, same role only, earlier message wins"}},{"stage":"trim","order":3,"trimmed_messages":0,"trimmed":[],"rule":{"max_message_chars":120,"cut_at":"last sentence boundary before the limit, hard cut if none in the last 60 percent"}},{"stage":"drop","order":4,"dropped_messages":0,"dropped":[],"rule":{"weights":{"recency":0.5,"role":0.3,"topic_overlap":0.2},"order":"lowest score first, older first on a tie","protected_never_dropped":true}}],"loss":{"input_messages":6,"output_messages":5,"input_chars":466,"output_chars":371,"dropped_messages":1,"dropped_chars":95,"trimmed_messages":0,"truncated_chars":0,"verbatim_messages":5,"retained_char_ratio":0.7961},"budget":{"budget_chars":400,"output_chars":371,"budget_met":true,"shortfall_chars":0,"protected_chars":169,"protected_exceeds_budget":false},"scoring":{"weights":{"recency":0.5,"role":0.3,"topic_overlap":0.2},"role_weights":{"system":1,"user":1,"assistant":0.7,"tool":0.5},"topic_terms_used":["4471","lyon","shipment","thursday","hamburg","left","monday","morning","reach","should","strasbourg","where","always","answer","arrival","book","cleared","dispatcher","estimated","first","friday","good","logistics","return","scan"],"note":"Recency is the position in the history from 0 to 1. Topic overlap is the share of a message word set that appears in topic_terms_used, the 25 most frequent terms longer than three characters across the whole history."},"limits":"No language model. Nothing is summarised, paraphrased or rewritten: every character of every returned content appears verbatim in the input, and nothing is appended. Duplicate detection is word overlap, which measures shared vocabulary and not meaning — the same fact in different words is not recognised as a duplicate. Trimming cuts at a sentence boundary and can remove the point of a long message. Protected messages are never dropped, so a budget below protected_chars cannot be met and budget_met is then false."}}