feat(prompt): make context-file truncation limit configurable

PROBLEM: Automatic context files such as SOUL.md and AGENTS.md were capped by a hardcoded CONTEXT_FILE_MAX_CHARS value. Amy's local fork had raised that constant from 20K to 25K so a larger SOUL.md would not be silently truncated, but the hardcoded 25K value changed upstream default behavior and made the patch less generally useful.

SOLUTION: Restore the upstream-compatible 20K default, add a context_file_max_chars config setting for users who intentionally keep larger identity/project-context files, keep chat-visible truncation warnings, and document the new setting. Tests cover the default, config override, explicit max_chars precedence, and the warning text.
This commit is contained in:
Wolfram Ravenwolf
2026-06-16 11:28:35 -07:00
committed by Teknium
parent 17251e865b
commit f6a42b1acf
8 changed files with 126 additions and 10 deletions
+5
View File
@@ -1104,6 +1104,11 @@ DEFAULT_CONFIG = {
"min_interval_hours": 24,
},
# Maximum characters loaded from a single automatic context file such as
# SOUL.md, AGENTS.md, CLAUDE.md, .hermes.md, or .cursorrules before Hermes
# applies head/tail truncation. This is separate from read_file tool limits.
"context_file_max_chars": 20_000,
# Maximum characters returned by a single read_file call. Reads that
# exceed this are rejected with guidance to use offset+limit.
# 100K chars ≈ 2535K tokens across typical tokenisers.