Bug Report
Version: v0.0.7
Command: cortex agent show
Summary
cortex agent show panics (process abort) with byte index 500 is not a char boundary when an agent's system prompt contains a multi-byte UTF-8 character that spans the 500-byte truncation boundary.
Steps to Reproduce
- Create an agent whose system prompt has a multi-byte char (é, U+00E9) spanning bytes 499–500:
~/.cortex/agents/test-utf8-agent.md:
---
name: test-utf8-agent
description: Test agent for UTF-8 boundary testing
---
xxx...xxx[499 x chars]émore text
$ python3 -c "print('x'*499 + chr(0xe9) + 'more text')" > prompt.txt
# prompt is 510 bytes; é spans bytes 499-500
- Run:
$ cortex agent show test-utf8-agent
Actual Behavior
Agent: test-utf8-agent
========================================
Description: Test agent for UTF-8 boundary testing
Mode: primary
Source: personal
System Prompt:
----------------------------------------
thread 'main' panicked at src/cortex-cli/src/agent_cmd/handlers/show.rs:142:24
byte index 500 is not a char boundary; it is inside 'é' (bytes 499..501) of `xxx...xxx`
note: run with RUST_BACKTRACE=1 to display a backtrace
Aborted (core dumped)
Expected Behavior
The system prompt should be safely truncated at a valid UTF-8 character boundary (e.g., at byte 499), not crash.
Root Cause
src/cortex-cli/src/agent_cmd/handlers/show.rs, line 142:
let preview = if prompt.len() > 500 {
format!(
"{}...\n\n(truncated, {} chars total)",
&prompt[..500], // PANICS if byte 500 is inside a multi-byte char
prompt.len()
)
} else {
prompt.clone()
};
prompt.len() returns the byte count. If a multi-byte UTF-8 character (e.g., U+00E9 é, 2 bytes) spans bytes 499–500, the byte slice &prompt[..500] panics.
Fix
let preview = if prompt.len() > 500 {
let safe: String = prompt.chars().take(500).collect();
format!("{}...\n\n(truncated, {} chars total)", safe, prompt.chars().count())
} else {
prompt.clone()
};
Screenshot

Bug Report
Version: v0.0.7
Command:
cortex agent showSummary
cortex agent showpanics (process abort) withbyte index 500 is not a char boundarywhen an agent's system prompt contains a multi-byte UTF-8 character that spans the 500-byte truncation boundary.Steps to Reproduce
Actual Behavior
Expected Behavior
The system prompt should be safely truncated at a valid UTF-8 character boundary (e.g., at byte 499), not crash.
Root Cause
src/cortex-cli/src/agent_cmd/handlers/show.rs, line 142:prompt.len()returns the byte count. If a multi-byte UTF-8 character (e.g., U+00E9é, 2 bytes) spans bytes 499–500, the byte slice&prompt[..500]panics.Fix
Screenshot