Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

Merge PR #940 into main

AkitaOnRails75ac107c269c
diff --cc CHANGELOG.md
index 830775c7,4be6f809..5b4820c1
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -8,22 -8,10 +8,26 @@@ and this project adheres to [Semantic V
## [Unreleased]
### Fixed
+- `ai-memory bootstrap` on a repository small enough for one chunk no longer
+ asks the provider for 64K output tokens. The output cap was keyed on the
+ number of chunks, so the only chunk of a small repo got the one-shot cap
+ meant for `--chunk-input-tokens 0`, and every such run failed on a
+ 64K-context model. Under chunking (the default) every call now asks for up
+ to 16K; only `--chunk-input-tokens 0` keeps 64K. The `--max-input-tokens`
+ help no longer claims its 150K default leaves room for 64K of output in a
+ 200K window. (#928)
+- `ai-memory bootstrap` now leaves headroom for its own token estimate. It
+ counts bytes ÷ 4, which undercounts non-English text and source code (about
+ 40% on Portuguese mixed with code, as measured for consolidation), and it
+ filled `--max-input-tokens` and `--chunk-input-tokens` to the last estimated
+ token, so a chunk sized to fit a model's window could overflow it on input
+ alone. Prunes and chunks now fill 80% of each budget by the estimate, the
+ same default consolidation uses; a run may plan more chunks than before.
+ (#937)
+ - The `bootstrap.md` manifest no longer shows bare `---` separators when a
+ chunk returns no rationale. Empty rationales are dropped before the
+ per-chunk ones are joined, and a run where no chunk returned one says so.
+ (#939)
## [2.4.1] - 2026-09-25
diff --cc crates/ai-memory-consolidate/src/bootstrap.rs
index eb59bdbb,f943156a..0d3812e8
--- a/crates/ai-memory-consolidate/src/bootstrap.rs
+++ b/crates/ai-memory-consolidate/src/bootstrap.rs
@@@ -1414,20 -1394,27 +1407,41 @@@ fn build_chunk_request
}
}
+/// Output cap for one bootstrap LLM call.
+///
+/// With chunking on (the default), every call is a chunk that fits
+/// `chunk_budget`, including the only chunk of a small repo, so every call
+/// gets the chunk cap: it keeps Cursor bridge responses bounded and, with the
+/// default 24K chunk budget, fits a 64K-context model. Keying the cap on the
+/// chunk count instead sent a small repo's single chunk 64K output tokens,
+/// which no 64K-context model can accept. Only an operator who disables
+/// chunking (`chunk_budget == 0`, one call with the whole pruned bundle) gets
+/// the large cap.
+const fn bootstrap_chunk_max_tokens(chunk_budget: usize) -> u32 {
+ if chunk_budget == 0 { 64_000 } else { 16_000 }
+}
+
+ /// Manifest rationale from the per-chunk ones. `rationale` is
+ /// `#[serde(default)]` and the Anthropic `tool_use` schema does not enforce
+ /// required fields, so a chunk can return an empty one; joining those left
+ /// bare `---` separators in `bootstrap.md`.
+ fn merge_chunk_rationales(rationales: Vec<String>, llm_chunks: usize) -> String {
+ const NONE_RETURNED: &str = "_No chunk returned a rationale._";
+ let mut kept: Vec<String> = rationales
+ .into_iter()
+ .filter(|rationale| !rationale.trim().is_empty())
+ .collect();
+ if llm_chunks <= 1 {
+ return kept.pop().unwrap_or_else(|| NONE_RETURNED.to_string());
+ }
+ let body = if kept.is_empty() {
+ NONE_RETURNED.to_string()
+ } else {
+ kept.join("\n\n---\n\n")
+ };
+ format!("Processed in {llm_chunks} LLM chunks.\n\n{body}")
+ }
+
/// Highest `decisions/NNNN-…` serial seen in `prior_paths`, or 0.
fn next_decision_serial(prior_paths: &[&str]) -> u32 {
prior_paths