-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Bug: String truncation fails with "byte index is not a char boundary" for non-ASCII text
Describe the bug
Goose crashes with byte index is not a char boundary error when truncating text content that contains multi-byte UTF-8 characters (Japanese, Chinese, Korean, emojis, etc.). This occurs because the code uses byte-based string slicing instead of character-boundary-aware slicing.
To Reproduce
Steps to reproduce the behavior:
- Use Goose with content containing Japanese/Chinese/Korean text or emojis
- Trigger text truncation (large messages, tool responses, or session loading)
- See error:
byte index is not a char boundary
Expected behavior
Text should be truncated safely at character boundaries without crashing.
Affected Code Locations
The following locations use unsafe byte-based string slicing:
-
Context Management Truncation (
crates/goose/src/context_mgmt/truncate.rs): -
Session Storage Truncation (
crates/goose/src/session/storage.rs): caused by Session file security updates #3071 -
etc