From 0e182237fdfd879ae5649628e367ad3790fee3e7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 31 Oct 2026 05:47:23 +0100 Subject: [PATCH] self-run: repair the task cut function Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/self_run.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/mind-body/src/self_run.rs b/crates/mind-body/src/self_run.rs index e4bc9a4..64d5596 100644 --- a/crates/mind-body/src/self_run.rs +++ b/crates/mind-body/src/self_run.rs @@ -133,8 +133,19 @@ fn task_section(mind: &dyn MindPort, claims: &[PipelineRef]) -> String { } cut_at(task, TASK_LIMIT) } -/// `text` cut at a character boundary to `limit` bytes, marked when cut.fn cut_at(mut text: String, limit: usize) -> String { if text.len() > limit { let mut end = limit; while !text.is_char_boundary(end) { end -= 1; } text.truncate(end); text.push_str(" -[task truncated]"); } text} + +/// `text` cut at a character boundary to `limit` bytes, marked when cut. +fn cut_at(mut text: String, limit: usize) -> String { + if text.len() > limit { + let mut end = limit; + while !text.is_char_boundary(end) { + end -= 1; + } + text.truncate(end); + text.push_str("\n[task truncated]"); + } + text +} /// What the child is told once, at the context ceiling. pub const FLUSH_MESSAGE: &str = "The context ceiling is reached. Admit to the mind what it lacks, close your run, and end.";