08 Compress#

Script: example/08_compress.py.

flow.Compressor runs run_session_compress(...) to replace a long transcript with a smaller summary session.

python example/08_compress.py

Step

Behavior

Build history

Run an agent turn to create assistant chunks.

Count rows

Inspect len(session.chunk_table.rows).

Compress

Call compressor.forward(session).

Continue

Use the compressed session as the next user-side context.

Compression disables tools and expects the model to return text only. In v1.2.2, finish_reason="length" raises RuntimeError because a truncated summary must not replace the whole transcript. Increase the provider’s output token budget and retry; OpenRath does not retry this case automatically.

The compressed output contains one user chunk. Session.text() searches assistant chunks, so read the summary from compressed.chunk_table[-1] rather than calling compressed.text().

← Runnable Examples