Hmbown/CodeWhale · error
memory note exceeds bytes
Error message
memory note exceeds {MAX_NOTE_BYTES} bytes What it means
`normalize_note` enforces a hard size cap (`MAX_NOTE_BYTES`) on memory notes, measured after whitespace collapsing. Oversized notes are rejected instead of silently truncating, preserving data-integrity of the memory store.
Solutions
- Summarize or extract only the salient facts before storing.
- Split the content into multiple smaller notes.
- Store large content in a file and keep a short pointer/summary as the note.
- Measure `note.len()` (bytes) against the cap before calling, accounting for UTF-8 multi-byte characters.
Example fix
// before: dumping whole file as a note
let note = std::fs::read_to_string("big.log")?;
store.remember(¬e).await?;
// after: store a summary under the cap
let note = summarize(&std::fs::read_to_string("big.log")?);
assert!(note.len() <= MAX_NOTE_BYTES);
store.remember(¬e).await?; Defensive patterns
Strategy: validation
Validate before calling
// Enforce the byte cap before calling (note: bytes, not chars)
const MAX_NOTE_BYTES: usize = 2048; // match library constant
if note.len() > MAX_NOTE_BYTES {
note = summarize(¬e); // or split into multiple notes
} Prevention
- Summarize large content before storing; keep raw data in files with a pointer note.
- Remember .len() counts bytes — multi-byte UTF-8 counts more than characters.
- Split long content into several focused notes instead of one blob.
When it happens
Trigger: Calling `remember`, `revise`, or `retire` with note text whose byte length (post-normalization) exceeds `MAX_NOTE_BYTES` — e.g. pasting an entire log file or a large document as a memory note.
Common situations: An agent dumps large tool output into memory; a user pastes a long document; a loop repeatedly appends content to one note until it blows past the cap; multi-byte UTF-8 inflates byte length beyond the character count expectation.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- correction must match exactly one active note on the…
- Fleet artifact exceeds the 16 MiB limit
- Invalid local connection file.
- invalid session id for memory reconcile
- memory edits require non-empty evidence
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/9e9e453489301ed7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/native_memory.rs:891
/// as a note. An unexplained rewrite of durable context is the thing the
/// journal exists to prevent.
fn normalize_evidence(evidence: &str) -> Result<String> {
normalize_note(evidence).map_err(|_| anyhow!("memory edits require non-empty evidence"))
}
fn normalize_note(note: &str) -> Result<String> {
let note = note.replace("\r\n", "\n").replace('\r', "\n");
let note = note
.lines()
.map(str::trim)
.filter(|line| !line.is_empty())
.collect::<Vec<_>>()
.join(" ");
if note.is_empty() {
bail!("memory note is empty");
}
if note.len() > MAX_NOTE_BYTES {
bail!("memory note exceeds {MAX_NOTE_BYTES} bytes");
}
Ok(note.trim_start_matches('-').trim().to_string())
}
fn validate_query(query: &str) -> Result<&str> {
let query = query.trim();
if query.is_empty() || query.chars().count() > MAX_QUERY_CHARS {
bail!("memory search query is empty or too long");
}
Ok(query)
}
fn safe_component(value: &str) -> Result<String> {
if value.is_empty()
|| value == "."
|| value == ".."
|| value.contains('/')
|| value.contains('\\')View on GitHub (pinned to 433685b202)