response_compress
Shrink oversized JSON response files to stay within size limits, using array sampling, string truncation, or key selection to return compact, inline data for your AI.
Instructions
response_compress
Reduces a JSON value inside a saved response file so it fits within the response size limit and can be returned to the LLM inline.
When to use
Use this tool after response_outline when you want to see a representative sample of a large array or reduce verbose string/object content before reading specific items.
When NOT to use
Do NOT use
bash,cat,head,tail,file,open,less,more, or any external command to readfileRef.path.Do NOT read the file manually. Always use
response_compressorresponse_sliceto access data inside saved response files.
Parameters
path(required): The absolute file path fromfileRef.pathreturned byinvoke.jsonPath(optional): Path to the value to compress. Default is the root of the file.mode(required): Compression strategy.first_of_array: keep only the first element of an array.sample_array: keep a head and tail sample of an array.truncate_strings: shorten every string tostringLencharacters.keys_only: replace object values with type names.select_keys: keep only the keys listed inselectKeysfor every object in an array.
arrayHead(optional): Number of leading array items forsample_array. Default is 3.arrayTail(optional): Number of trailing array items forsample_array. Default is 2.stringLen(optional): Maximum string length fortruncate_strings. Default is 80.selectKeys(optional): Keys to keep forselect_keysmode.
Returns
Either:
body: the compressed JSON value inline, orfileRef: if the compressed result is still too large, a new saved file path and metadata.hint: a short explanation of what was compressed and how to continue exploring.
Recommended workflow
After response_outline shows a large array such as pets with 5000 items:
response_compress({
"path": "/.../responses/...json",
"jsonPath": "pets",
"mode": "first_of_array"
})Then use response_slice with jsonPath like pets.0, pets.1, etc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | required,Compression mode: first_of_array, sample_array, truncate_strings, keys_only, select_keys | |
| path | Yes | required,Absolute path returned in fileRef.path | |
| jsonPath | No | optional,Path to the value to compress (e.g. data or data.0) | |
| arrayHead | No | optional,Number of leading array items for sample_array mode | |
| arrayTail | No | optional,Number of trailing array items for sample_array mode | |
| stringLen | No | optional,Maximum string length for truncate_strings mode | |
| selectKeys | No | optional,Keys to keep for select_keys mode |