Documentation
¶
Overview ¶
Package bootstrap renders persisted memories into the SessionStart payload that an agent receives at the very beginning of a session.
The output is a single Markdown document that combines:
- a fixed system directive block (telling the agent how to use mememory),
- the loaded memories grouped by type,
- a stats block reporting how much of the bootstrap budget is consumed.
The bootstrap budget is denominated in tokens and bounded by MaxBootstrapTokens — a deliberately conservative ceiling so that bootstrap never dominates the agent's context window. Token counts are estimated from byte length using BytesPerToken; the estimate is intentionally simple (no per-tokenizer accuracy) because the goal is to give the user a sense of scale, not millimeter precision.
Index ¶
Constants ¶
const BytesPerToken = 3.5
BytesPerToken is the average bytes-per-token ratio used to estimate token counts from raw payload size. The value is tuned for mixed Cyrillic prose and source code; per-tokenizer accuracy is explicitly out of scope. The estimate is reported alongside the raw byte count so the user can apply their own correction if they care.
const MaxBootstrapTokens = 30_000
MaxBootstrapTokens is the soft ceiling on how many tokens the bootstrap payload should occupy. It is independent of the model and the context window — bootstrap is meant to stay small enough that it never crowds out the actual conversation regardless of which agent loads it.
30_000 tokens corresponds to roughly 15% of a 200K-token context window, which we consider the upper bound of "comfortable bootstrap weight" for the smallest mainstream context. On larger windows the absolute share is lower and there is no need to inflate the budget.
Variables ¶
This section is empty.
Functions ¶
func CheckBudget ¶ added in v0.4.0
CheckBudget returns a non-empty warning string if the given memory set would render into a bootstrap payload exceeding MaxBootstrapTokens. Used by the remember tool to flag the user when a newly stored bootstrap memory pushes the total over the budget — they can keep the memory but should know they are now in overflow territory.
Returns an empty string when the budget is fine. The check renders the body without the stats block (the stats describe the body, not themselves) so the warning reflects the actual cost.
func EstimateTokens ¶ added in v0.4.0
EstimateTokens converts a byte count into an approximate token count using BytesPerToken. The estimate is rounded to the nearest integer.
Types ¶
type Context ¶ added in v0.4.0
type Context struct {
Project ProjectInfo
GlobalMems []t.Memory
ProjectMems []t.Memory
}
Context bundles everything Format needs to render bootstrap output. It is constructed by the CLI after resolving the project and fetching memories from the admin API.
type ProjectInfo ¶ added in v0.4.0
ProjectInfo describes the resolved project name and the source it came from. The source is reported in the stats block so the user can see at a glance which detection rule was applied (--project flag, .mememory file, git, or cwd fallback).