Builder

Forgetless is a chainable builder. Inputs stay buffered until run() executes preview filtering, chunking, scoring, and final budget selection.

Builder shape#

rust
use forgetless::{Config, Forgetless, WithPriority};

let result = Forgetless::new()
    .config(
        Config::default()
            .context_limit(64_000)
            .chunk_size(256),
    )
    .add_pinned("You are writing release notes.")
    .add(WithPriority::high(conversation))
    .add_file("design-review.pdf")
    .query("What changed in the API surface?")
    .run()
    .await?;

Core methods#

MethodPurposeNotes from the crate
new()Create an empty optimizerUses ForgetlessConfig::default() internally.
config(Config)Merge runtime optionsNon-default context_limit and chunk_size override the current config.
query(...)Attach a relevance queryWhen more than five lazy files exist, preview filtering is attempted before full reads.
add(...)Push eager string contentAccepts plain strings or WithPriority wrappers.
add_pinned(...)Shortcut for critical textWraps the content with WithPriority::critical.
add_file(...)Register one lazy fileThe file path is stored and read later inside run().
add_files(...)Register many lazy filesEvery item is converted through the private IntoLazyFile trait.
add_bytes(...)Attach in-memory bytesText MIME types are decoded as UTF-8 when possible; non-text MIME types become placeholder records.
run()Execute the pipelineReturns an OptimizedContext.

Execution flow#

StepWhat happens
1. Model initVision and text models are only initialized when the current config enables them.
2. Preview filterIf query exists and there are many files, only the most relevant lazy files are read.
3. File loadSelected files are read in parallel with Rayon and converted into ContentInput items.
4. ChunkingEach input gets a ChunkConfig derived from content type and current runtime options.
5. ScoringPriority, semantic similarity, position heuristics, and conversation-style recency contribute to each score.
6. SelectionTop chunks are kept until the configured token budget is satisfied.