Skip to main content

Module builder

Module builder 

Source
Expand description

BriefBuilder — orchestrates fan-out, tokenization, budget pruning, governance, and receipt assembly.

The builder is intentionally cheap to construct and held by the agent across turns. Sources, tokenizer, governance, budget, and strategy are all swappable.

§Typical usage

let builder = BriefBuilder::new()
    .tokenizer(Arc::new(CharApproxTokenizer))
    .budget(TokenBudget::default());
    // .source(Arc::new(MySource)) ...

let ctx = BriefContext::new(TokenBudget::default());
let brief = builder.build(&ctx).await?;
println!("brief receipt: {} tokens", brief.receipt.total_tokens);

§Open decision: cancellation

An open question is whether the builder should cancel pending sources when the budget overflows mid-fan-out. Phase 2 ships without cancellation — every source’s contribute() is allowed to run to completion, and pruning happens once after try_join_all returns. This keeps the contract simple (every source either succeeds, errors, or is skipped — never half-cancelled) and lets Phase 4 add cancellation as an opt-in BriefBuilder::with_cancellation(...) knob without breaking callers.

Structs§

BriefBuilder
Assembles a Brief from registered Sources.