-
Notifications
You must be signed in to change notification settings - Fork 6
Description
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 GBScreenshots
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.mdencoded as UTF‑16 LE with BOM (e.g., viaiconv -f utf-8 -t utf-16leor 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.