agora.fleet.distiller
Hierarchical map-reduce distillation for large files.
When an agent does read_file on a 67 KB knowledge-base page, the result
overflows the model’s context and the task fails. This module shrinks such
content before it reaches the agent’s message history:
Split the source into buckets that fit comfortably in one LLM call.
For each bucket, run a focused extraction prompt that keeps only the facts relevant to the current task.
Concatenate the per-bucket extracts.
If the concatenated result still exceeds the target size, recurse — treating the merged extracts as the new input.
Cap recursion depth so a pathologically large source can’t run forever.
The LLM used for distillation is the same model the agents use, so no extra dependencies and the token budget is per-call, not per-source.
Module Attributes
Roughly the size that leaves room for the task prompt + tool schemas. |
|
Per-bucket input size. |
|
Safety cap. |
Functions
|
Recursively shrink |
|
Return an |
- agora.fleet.distiller.DEFAULT_BUCKET_CHARS = 4000
Per-bucket input size. Below num_ctx by a wide margin so one call is reliable.
- agora.fleet.distiller.DEFAULT_MAX_ROUNDS = 4
Safety cap. Recursion that hasn’t converged by round 4 fallback-truncates.
- agora.fleet.distiller.DEFAULT_TARGET_CHARS = 6000
Roughly the size that leaves room for the task prompt + tool schemas.
- async agora.fleet.distiller.distill(text, *, focus, llm, model, target_chars=6000, bucket_chars=4000, max_rounds=4)[source]
Recursively shrink
textwhile preserving information relevant tofocus.Returns a string of length
<= target_chars(approximately — the last LLM call may overshoot). On internal failure (LLM errors, empty output) falls back to head-truncation with a[...truncated...]marker so the caller always receives something usable.