say "bytes", not "characters", where the limit is bytes

`check()` enforces the entry limit on `len(text.encode())`, but every place
that asks the agent for a line calls it characters:

  - the `nap` compression prompt ("at most %d characters")
  - `note`'s usage line ("at most %d chars")
  - the installed prompt in TEMPLATE ("max {chars} chars")

An agent budgeting characters overshoots on any non-ASCII text and only
finds out from the error, one round trip per attempt. The error message
already explains the byte cost -- this just says it up front, at no cost
to the prompt.

Five words, no behaviour change. 109099 tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
julianss 2026-07-29 13:53:12 -06:00
parent 428d2ecb89
commit f5b6a24a59
2 changed files with 5 additions and 5 deletions

View file

@ -21,7 +21,7 @@ The tool lands at `~/.optmem/memo`; put `~/.optmem` on `PATH` to type `memo`.
| | |
|---|---|
| `memo wake` | read the memory — the first command of every session |
| `memo note "..."` | record one memory: one line, up to 280 chars |
| `memo note "..."` | record one memory: one line, up to 280 bytes |
| `memo nap` | answer the merges that came due |
| `memo recall <regex>` | search every memory ever recorded, word for word |
| `memo zoom <lo>-<hi>` | open a tree node into its two halves |
@ -77,7 +77,7 @@ then do exactly what it prints, to the end of its output.
### While working: register memories (mandatory)
Call `~/.optmem/memo note "<1 line, max 280 chars>"` whenever you learn
Call `~/.optmem/memo note "<1 line, max 280 bytes>"` whenever you learn
something new, or something worth keeping happens. That covers a task
worth real effort, a fact or insight the user teaches you, anything you
learn about their life (even indirectly), any event of lasting effect.

6
memo
View file

@ -478,7 +478,7 @@ def nap_prompt(d, lo, hi, left):
tail = "" if not left else "\n%s after this one." % (
"1 compression remains" if left == 1 else
"%d compressions remain" % left)
return ("Compress memories #%d-%d into one line of at most %d characters.\n"
return ("Compress memories #%d-%d into one line of at most %d bytes.\n"
"Keep what has lasting effect, drop what does not. Invent "
"nothing.\n\n"
"%s\n%s\n"
@ -513,7 +513,7 @@ then do exactly what it prints, to the end of its output.
### While working: register memories (mandatory)
Call `{memo} note "<1 line, max {chars} chars>"` whenever you learn
Call `{memo} note "<1 line, max {chars} bytes>"` whenever you learn
something new, or something worth keeping happens. That covers a task
worth real effort, a fact or insight the user teaches you, anything you
learn about their life (even indirectly), any event of lasting effect.
@ -653,7 +653,7 @@ def cmd_wake(d, args):
def cmd_note(d, args):
if len(args) != 1:
die("usage: %s note \"<one line, at most %d chars>\""
die("usage: %s note \"<one line, at most %d bytes>\""
% (ME, ENTRY_CHARS))
text = check(args[0])
i = log_append(d, [(datetime.date.today().isoformat(), text)])