Files
Agent-System-Backend/internal/runmgr/truncate_test.go
T
weichenandCursor 78ce78a7d3 Cap tool results by character and gate stale file writes
Why: Byte truncation split UTF-8, subagent results could return unbounded text, and a write could overwrite a file that changed after it was read.
Evidence: cutRunes keeps a two-character Chinese prefix; tool selection honors -name; checklist reminders go through the reminder bus.
Impact: Tool output limits count characters. A subagent result over 32000 characters is stored as an artifact and the parent sees the path. fs_write_file rejects an existing file that was not read in this run.
Refs: feature/context-engineering
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-03 16:21:02 +00:00

18 lines
305 B
Go

package runmgr
import "testing"
func TestCutRunesKeepsUTF8(t *testing.T) {
s := "中文结果"
got := cutRunes(s, 2)
if got != "中文" {
t.Fatalf("%q", got)
}
if truncate(s, 2) != "中文…" {
t.Fatalf("%q", truncate(s, 2))
}
if cutRunes(s, 8) != s {
t.Fatal("short string was cut")
}
}