Files
Agent-System-Backend/internal/runtime/toolselect_test.go
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

19 lines
436 B
Go

package runtime
import (
"testing"
agentllm "agent-native/runtime/llm"
)
func TestApplyToolSelectionRemovesName(t *testing.T) {
decls := []agentllm.ToolDecl{{Name: "read_file"}, {Name: "write_file"}}
got := applyToolSelection(decls, "-write_file,+missing")
if len(got) != 1 || got[0].Name != "read_file" {
t.Fatalf("%+v", got)
}
if same := applyToolSelection(decls, ""); len(same) != 2 {
t.Fatalf("empty: %+v", same)
}
}