kiarina-agi-flow
Dependencies
| Package | Version | License |
|---|---|---|
| kiarina-agi-base | >=2.7.0 |
MIT |
| kiarina-agi-data | >=2.7.0 |
MIT |
| kiarina-agi-text | >=2.8.0 |
MIT |
| kiarina-i18n | >=2.3.1 |
MIT |
| kiarina-utils-common | >=2.8.0 |
MIT |
| Pydantic | >=2.11.7,<3 |
MIT |
| pydantic-settings | >=2.10.1,<3 |
MIT |
| pydantic-settings-manager | >=3.2.0 |
MIT |
Installation
pip install kiarina-agi-flow
Features
Temporary prompt resizing
A prompt composes fixed and resizable sections in a SectionContainer. The container
subtracts fixed sections and distributes the remaining token allowance among resizable
sections by weight. HistorySection shrinks its file view before removing old message
units; FileInfoSection shrinks files before removing them from its view. These operations
change the section's presentation, not the supplied History.
run_prompt retains the original ChatLimits and computes an effective limit from the
current token conversion factor. Local resize iterations do not compound that factor.
Provider token-overflow responses can recalibrate it from the estimated and reported
counts. When no actual count is reported, retrying reduces the current allowance.
A resize may advance a section's internal state without reducing its token count on that
call. The prompt does not stop on one unchanged count and does not impose a local resize
iteration limit. Each section must exhaust its finite resizing stages and return False
from is_resizable() when it cannot resize further.
If the remaining sections cannot fit, including when fixed sections alone exceed the
allowance, TokenOverflowError propagates to the caller. Persistent compaction is the
caller's responsibility; it is not an implicit mutation performed by the prompt.
Migrating custom sections
Subclasses of BaseSection must override _resize, not resize. The public wrapper
invalidates cached estimates in finally, including on failure, cancellation, or closure
of the async generator. Static and tool sections retain the non-resizable default.
Classes implementing the Section protocol without inheriting BaseSection must provide
the same cache-invalidation and finite-resize behavior themselves.
API Reference
kiarina.agi.section.BaseSection
Relevant resizing methods:
def is_resizable(self) -> bool: ...
async def resize(self, reduce: TokenCount) -> AsyncIterator[Event]: ...
async def _resize(self, reduce: TokenCount) -> AsyncIterator[Event]: ...
def get_estimates(self, ignore_cache: bool = False) -> ChatEstimates: ...
reduce is the requested reduction in estimated tokens, not a target size. Call resize
and fully consume its events; implement the protected _resize hook in subclasses.
get_estimates() caches until the view is resized. ignore_cache=True remains available
for other explicit view changes, but is not required after the resize wrapper completes.
kiarina.agi.section_container.SectionContainer
def __init__(
self,
ctx: SectionContext,
*,
sections: list[Section | tuple[Section, Weight]] | None = None,
) -> None: ...
def is_resizable(self) -> bool: ...
async def resize(self, token_count_limit: int) -> AsyncIterator[Event]: ...
def get_estimates(self, ignore_cache: bool = False) -> ChatEstimates: ...
Unlike a section, the container's resize accepts the desired total token limit.
Fixed sections are retained. An impossible fixed-section budget raises
kiarina.agi.chat_provider.TokenOverflowError, rather than ValueError. For local
capacity failures, its limit is the effective local token allowance. Provider-originated
errors may instead report the provider's token units.
kiarina.agi.prompt.run_prompt
async def run_prompt(
history: History,
*,
chat_options: ChatOptions | None = None,
prompt_options: PromptOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
**kwargs: Any,
) -> AsyncIterator[Event]: ...
prompt_options["limits"] accepts ChatLimits or a limits specifier. If omitted, model
capabilities supply the limits. Provider overflow retries are separate from section
resize iterations. Neither the supplied limits object nor the stored history is changed
by temporary resizing.
Metadata
Release files for kiarina-agi-flow 2.37.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kiarina_agi_flow-2.37.0.tar.gz | 24.5 kB | With provenance | Details for kiarina_agi_flow-2.37.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kiarina_agi_flow-2.37.0-py3-none-any.whl | Python 3 | none | any | Details for kiarina_agi_flow-2.37.0-py3-none-any.whl |
Total release size: 58.3 kB
Release files / kiarina_agi_flow-2.37.0.tar.gz
| Download URL | kiarina_agi_flow-2.37.0.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1998c9873f8a1459663b8fcb2eedc0676cf61bbc6c3caffc96812e7faf1f2b7c
|
|
BLAKE2b-256 checksum How to use checksums |
53e2810889cda32036becef4d66be37e44c75c5c936861d31ed9ad1b899a6ced
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / kiarina_agi_flow-2.37.0-py3-none-any.whl
| Download URL | kiarina_agi_flow-2.37.0-py3-none-any.whl |
|---|---|
| Size | 33.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8d5eadaa72657e85705449d18450902cd02f1bacf8d1beb705879049b45d4d5
|
|
BLAKE2b-256 checksum How to use checksums |
bf8bace9e8c7e4e39761f14a8e610e3aa0f707122d7ebb6e871bc1a1e5ad58a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for kiarina-agi-flow 2.37.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for kiarina_agi_flow-2.37.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.