Project
cortex
Description
JSON agents support UTF‑16/UTF‑8‑BOM via read_file_with_encoding, but their prompt.md is read with std::fs::read_to_string, which only accepts UTF‑8. A UTF‑16 prompt file causes the entire agent load to fail, even though UTF‑16 is supported for the agent definition itself.
Reference: cortex-cli/src/agent_cmd/loader.rs load_agent_from_json uses read_to_string for prompt.md.
Error Message
failed to read .../prompt.md: stream did not contain valid UTF-8
Debug Logs
N/A
System Information
Bounty Version: 0.1.0
OS: Ubuntu 24.04 LTS
CPU: AMD EPYC-Genoa Processor (8 cores)
RAM: 15 GB
Screenshots
No response
Steps to Reproduce
- Create a directory agent at
~/.cortex/agents/utfprompt/agent.json:
{
"name": "utfprompt",
"description": "UTF prompt agent",
"mode": "primary"
}
- Create
~/.cortex/agents/utfprompt/prompt.md encoded as UTF‑16 LE with BOM (e.g., via iconv -f utf-8 -t utf-16le or a Windows editor) and add any text.
- Run:
cortex agent list
- Observe that the agent fails to load with a UTF‑8 decoding error.
Expected Behavior
prompt.md should be read using the same encoding-aware logic as agent definitions (UTF‑8/UTF‑16/BOM), or at least not prevent agent loading.
Actual Behavior
UTF‑16 prompt files cause agent loading to fail because read_to_string only accepts UTF‑8.
Additional Context
This is inconsistent with read_file_with_encoding already used for agent.json and AGENT.md.
Project
cortex
Description
JSON agents support UTF‑16/UTF‑8‑BOM via
read_file_with_encoding, but theirprompt.mdis read withstd::fs::read_to_string, which only accepts UTF‑8. A UTF‑16 prompt file causes the entire agent load to fail, even though UTF‑16 is supported for the agent definition itself.Reference:
cortex-cli/src/agent_cmd/loader.rsload_agent_from_jsonusesread_to_stringforprompt.md.Error Message
failed to read .../prompt.md: stream did not contain valid UTF-8Debug Logs
N/A
System Information
Screenshots
No response
Steps to Reproduce
~/.cortex/agents/utfprompt/agent.json:{ "name": "utfprompt", "description": "UTF prompt agent", "mode": "primary" }~/.cortex/agents/utfprompt/prompt.mdencoded as UTF‑16 LE with BOM (e.g., viaiconv -f utf-8 -t utf-16leor a Windows editor) and add any text.cortex agent listExpected Behavior
prompt.mdshould be read using the same encoding-aware logic as agent definitions (UTF‑8/UTF‑16/BOM), or at least not prevent agent loading.Actual Behavior
UTF‑16 prompt files cause agent loading to fail because
read_to_stringonly accepts UTF‑8.Additional Context
This is inconsistent with
read_file_with_encodingalready used foragent.jsonandAGENT.md.