purra-compaction · Python
English | 简体中文
Compress older conversation turns with a model call when PurrA's context budget requires it. Instructions and recent complete turns, including tool results, remain in the input.
Install
From the repository root, with Python 3.11+:
python -m pip install . ./integrations/compaction/python
Configure
from purra.context_orchestration import ContextCompressionCoordinator
from purra_compaction import SemanticCompaction
def compactor(model_tasks):
return ContextCompressionCoordinator(SemanticCompaction(
model_tasks,
max_summary_tokens=1024,
max_input_tokens=16000,
keep_recent_messages=8,
))
Attach the factory to your existing Agent preset. Core supplies the Run-bound model task runner:
from dataclasses import replace
from purra.api import AgentComponentBinding
preset = replace(
preset,
conversation_compactor_factory=compactor,
component_bindings={
**preset.component_bindings,
"conversationCompactor": AgentComponentBinding("semantic-compaction", "1"),
},
)
Pass this preset to AgentCore. Keep the component binding stable during recovery;
change its revision when the compression configuration changes.
| Option | Default | Purpose |
|---|---|---|
max_summary_tokens |
1024 | Output limit for the summary call |
max_input_tokens |
16000 | Maximum estimated input tokens for the summarizer |
keep_recent_messages |
8 | Recent-message retention target, adjusted to complete turns |
Behavior
Each compression uses one managed model call and consumes the Run's budget. The summary retains goals, constraints, decisions, completed work, open questions, and evidence references. Private reasoning and provider continuation data are excluded from the summarizer input.
The summary is untrusted historical context. Invalid or oversized summaries fail without replacing the input. Set the input limit within the summarizer model's available context window. The application retains the original conversation.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file purra_compaction-0.5.0.tar.gz.
File metadata
- Download URL: purra_compaction-0.5.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be886c7a54d77d1d0182f1310089b2c258de18287861567bf50da6fc5c9dabbb
|
|
| MD5 |
1d46c7d523197c285c2d0c56407daa35
|
|
| BLAKE2b-256 |
340e0e6176767cba7e95bfc7ed5d9ea4d4558061dac314a87f23fea921b02e9e
|
Provenance
The following attestation bundles were made for purra_compaction-0.5.0.tar.gz:
Publisher:
release.yml on Lybrands/purra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
purra_compaction-0.5.0.tar.gz -
Subject digest:
be886c7a54d77d1d0182f1310089b2c258de18287861567bf50da6fc5c9dabbb - Sigstore transparency entry: 2728652823
- Sigstore integration time:
-
Permalink:
Lybrands/purra@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Lybrands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file purra_compaction-0.5.0-py3-none-any.whl.
File metadata
- Download URL: purra_compaction-0.5.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
079e4471f0e30af2fb3f9ebc306bbdfcc1927fd16acfca177c9814015259f4f6
|
|
| MD5 |
928443190c1c92a5d40cd4a7cdf7e149
|
|
| BLAKE2b-256 |
6cdb2bfcd06ebe0af601bbb91cc70af625302886d87c85e5fb1fbd1337868013
|
Provenance
The following attestation bundles were made for purra_compaction-0.5.0-py3-none-any.whl:
Publisher:
release.yml on Lybrands/purra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
purra_compaction-0.5.0-py3-none-any.whl -
Subject digest:
079e4471f0e30af2fb3f9ebc306bbdfcc1927fd16acfca177c9814015259f4f6 - Sigstore transparency entry: 2728653561
- Sigstore integration time:
-
Permalink:
Lybrands/purra@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Lybrands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Trigger Event:
workflow_dispatch
-
Statement type: