SuperCompress

CI · Updated 2026-11-19

How to compress CI logs before sending them to an LLM

By

When a build fails, the log you hand to an LLM or a triage bot is mostly setup, installs and passing steps, and the lines that explain the failure can be anywhere in it. Filter the obvious noise first, then compress what is left against the question you are asking, so the model reads the failure instead of the whole job.

Why is a failed CI log so hard for an LLM to read?

A failing job log is mostly lines from steps that worked: dependency installs, setup, and passing tests. The failure can sit in the middle of the log. On GitHub Actions, post-job cleanup and upload steps run after the failing step, so a blunt cut of the last lines can drop the actual error. ANSI color codes and per-line prefixes also repeat on every line. Sending all of it costs input tokens and can bury the error under noise the model does not need.

What should you cut before compressing?

Do the free trims first. Fetch only failed steps with gh run view <run-id> --log-failed, or narrow to one job with --job <job-id>. Strip ANSI color codes. Drop repeated per-line prefixes if your tool adds them. A plain tail of the log is fragile because cleanup and upload steps run after the failing step on GitHub Actions, so the last lines are often not the error. A grep for "error" is fragile too: many failures do not contain that word, and the useful lines may be a traceback, an assertion message, or a non-zero exit without the word you searched for.

How do I compress a CI log with the SuperCompress API?

curl -X POST https://www.supercompress.dev/api/v1/compress \
  -H "X-API-Key: $SUPERCOMPRESS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": "<failed step log>", "query": "Why did this job fail, and which test or command failed first?"}'
import os
import re
import subprocess
import requests

API_URL = "https://www.supercompress.dev/api/v1/compress"
RUN_ID = "RUN_ID"  # replace with the failed run id
QUESTION = "Why did this job fail, and which test or command failed first?"
MAX_CHARS = 120000
ANSI_RE = re.compile(r"\x1b\[[0-9;:]*m")

raw = subprocess.check_output(
    ["gh", "run", "view", RUN_ID, "--log-failed"],
    text=True,
)
log_text = ANSI_RE.sub("", raw)

def line_chunks(text, limit):
    lines = text.splitlines(keepends=True)
    buf = []
    size = 0
    for line in lines:
        if size + len(line) > limit and buf:
            yield "".join(buf)
            buf = []
            size = 0
        if len(line) > limit:
            start = 0
            while start < len(line):
                yield line[start:start + limit]
                start += limit
            continue
        buf.append(line)
        size += len(line)
    if buf:
        yield "".join(buf)

parts = []
for chunk in line_chunks(log_text, MAX_CHARS):
    kept = chunk  # fail open: default to the original chunk
    try:
        r = requests.post(
            API_URL,
            headers={"X-API-Key": os.environ["SUPERCOMPRESS_API_KEY"]},
            json={"context": chunk, "query": QUESTION},
            timeout=60,
        )
        r.raise_for_status()
        kept = r.json().get("compressed_text") or chunk
    except requests.RequestException:
        pass
    parts.append(kept)

compressed_log = "".join(
    p if p.endswith("\n") else p + "\n" for p in parts
)

The context field is limited to 120,000 characters per call. Longer input returns HTTP 422 with "context too long (120k max)". Empty context returns 422 with "context required". SuperCompress is extractive and query-aware: it selects lines from the original rather than writing a summary, so error messages, file paths, test names and line numbers in the kept lines stay as written; preprocessing may rewrite JSON or collapse repeated stack frames before lines are chosen. Each response reports original_tokens and kept_tokens, which are estimates, not provider-billed totals. When the saving would be too small the call passes through: passthrough is true, compressed_text is the original and kept_tokens equals original_tokens.

What question should I send?

Send the question you actually want answered. A good default is why the job failed and which test or command failed first. Use a narrower question if you already know the failing test. Without a specific question the API returns a broader digest and labels the response query_mode "dump". If you want two different answers from one log, compress once per question.

When is a tail or grep enough?

Skip compression for short logs, when the error is reliably in the last lines (for example a single-step job with no cleanup steps after it), when you need the full log for an audit or a human, and for infrastructure failures with no error output. For a fuller decision guide, see when prompt compression is worth it. For logs from a running service rather than a build, see how to compress Kubernetes pod logs for an LLM.

How do I know it helped?

Run the same failures with and without compression and check whether the model names the right failing test or command. Log original_tokens and kept_tokens (estimates). Confirm cost on your provider bill. See whether context compression lowers your bill.

Frequently asked questions

Can I send a whole GitHub Actions log in one call?

Only up to 120,000 characters of context per call. Fetch the failed steps first, then split anything longer into chunks and compress each one.

Will compression change the error messages?

SuperCompress selects original lines rather than writing a summary, so error messages, file paths and test names in the kept lines stay as written. Preprocessing may collapse repeated stack frames before lines are chosen.

Why not just send the last 200 lines?

On GitHub Actions, cleanup and upload steps run after the failing step, so the last lines are often not the error. Fetching only failed steps and compressing against your question avoids depending on where the error lands.

Do I need to send a question?

Yes, for a targeted result. Without a specific question the API returns a broader digest and labels the response query_mode "dump".

Get API key API reference Reduce tool output tokens