Trimwise · LLM context compression
Fit long documents
into your AI prompt budget.
Trimwise picks useful excerpts from your documents and returns them within the token, word, or character limit you set. It keeps the original wording and order.
Without a question, it keeps a broad overview; add one for query-aware extraction to make it focus on your task. You can trim one document or share a budget across several retrieved sources before assembling your prompt.
Image delivery
incident review
- 01Openingcut
- 02Timelinecut
- 03Causekept
- 04Recoverykept
- 05Follow-upcut
144 words out≤ 150 word limit
The cut
Example of a query-aware extraction
The question asks about failure and recovery, so Trimwise kept those sections under the 150-word limit. This incident report is illustrative, but the 144-word result is real.
Why did the image workers fail, and how did the team restore service?
start of sourcekept verbatimend of source
Source / 333 words
Image delivery incident review
On 17 April, publishers in the EU region saw image uploads stall between 09:14 and 10:07 UTC. Existing images still loaded from the CDN, but new posts remained in a processing state. At the peak, 1,842 image jobs were waiting and the oldest job had been queued for 19 minutes. No source documents or published posts were lost.
Read the full report
# Illustrative incident review: image delivery backlog On 17 April, publishers in the EU region saw image uploads stall between 09:14 and 10:07 UTC. Existing images still loaded from the CDN, but new posts remained in a processing state. At the peak, 1,842 image jobs were waiting and the oldest job had been queued for 19 minutes. No source documents or published posts were lost. ## Timeline At 09:14, the media queue alert crossed its ten-minute threshold. Support received the first report six minutes later. The on-call engineer checked CDN error rates and regional network health because the user-visible symptom was a missing image. Both were normal. At 09:32, a worker log sample showed repeated storage 403 responses. The retries were safe to replay, but they filled the worker pool and hid the original authorization failure behind queue delay. ## Cause The credential rotator promoted a new storage key at 08:58. The upload API read the new key immediately, while long-lived image workers kept the previous key in memory. Storage rejected their writes after the old key expired at 09:11. Each failed job retried three times, so the queue grew faster than the workers could drain it. The rotation runbook checked the upload API but did not exercise a background image job. ## Recovery At 09:41, the team paused new retries, restarted the image workers so they loaded the current key, and replayed the idempotent jobs from the queue. Storage writes succeeded on the first attempt. Queue age returned below one minute at 10:07 UTC, and support confirmed that the affected posts rendered their images. The team kept the incident open for another hour to watch error rates and queue depth. ## Follow-up The media team owns a worker-side credential reload before the next rotation. The platform team will add a rotation test that uploads and processes an image, plus an alert on storage 403 responses before queue age rises. The incident review is scheduled for 21 April; no customer action is required.
Selected / 144 of 150 words
[…omitted…] ## Cause The credential rotator promoted a new storage key at 08:58. The upload API read the new key immediately, while long-lived image workers kept the previous key in memory. Storage rejected their writes after the old key expired at 09:11. Each failed job retried three times, so the queue grew faster than the workers could drain it. The rotation runbook checked the upload API but did not exercise a background image job. ## Recovery At 09:41, the team paused new retries, restarted the image workers so they loaded the current key, and replayed the idempotent jobs from the queue. Storage writes succeeded on the first attempt. Queue age returned below one minute at 10:07 UTC, and support confirmed that the affected posts rendered their images. The team kept the incident open for another hour to watch error rates and queue depth. […omitted…]
This is extractive prompt compression: Trimwise keeps original wording and marks omitted gaps, so you can compare the shorter result with the full source.
Try it
Try it on your text.
The report above is loaded here. Change the question or limit, paste your own text, or switch to Shared context for several sources.
Result
Selected text
[…omitted…] ## Cause The credential rotator promoted a new storage key at 08:58. The upload API read the new key immediately, while long-lived image workers kept the previous key in memory. Storage rejected their writes after the old key expired at 09:11. Each failed job retried three times, so the queue grew faster than the workers could drain it. The rotation runbook checked the upload API but did not exercise a background image job. ## Recovery At 09:41, the team paused new retries, restarted the image workers so they loaded the current key, and replayed the idempotent jobs from the queue. Storage writes succeeded on the first attempt. Queue age returned below one minute at 10:07 UTC, and support confirmed that the affected posts rendered their images. The team kept the incident open for another hour to watch error rates and queue depth. […omitted…]
Demo limits: 5 demo requests per minute and 5,000 submitted words daily.
Optional prefix and suffix
Benchmarked
Did the useful evidence stay?
Shorter context only helps if it keeps what the next task needs. We checked both required source passages and short answers from a model.
Trimwise Hybrid / keeping needed passages
62.5%
Observed in 160 author-annotated examples, where a pass meant keeping every marked passage together, leaving out prohibited text, and fitting within 256 tokens. Trimwise Lexical passed 60.0%. The best non-Trimwise method tested, a RECOMP extractive sentence adapter, passed 30.6%.
See how passages were scored ↗Short answers / 93-case check
About the same
With a 256-token Trimwise Hybrid context, three models matched the expected short answer about as often as with the full source: 44.1% to 46.2% with full source and 45.2% to 46.2% compressed. The largest difference is two answers out of 93. This is a weaker check than the passage test, not a study of answer quality.
See the answer check ↗Results come from one 160-case test suite and the specific adapters named in the report. They do not establish performance on every language, document type or model. Read the scope and limits ↗
Run the same example locally.
You can reproduce the result above on your machine. Download the incident text as incident.md, then run Trimwise 0.7.0 with the same question and 150-word limit:
python -m pip install 'trimwise==0.7.0'
python - <<'PY'
from pathlib import Path
from trimwise import Trimmer
result = Trimmer().trim(
Path('incident.md').read_text(),
limit=150,
unit='words',
strategy='lexical',
query="Why did the image workers fail, and how did the team restore service?",
)
print(result.text)
print(result.output_count)
PYTrimwise is open-source Python software under the MIT license, for Python 3.10 and newer. You can also call the public API without a key.