Skip to content

ltm-organize: a value your code reads belongs in a topic, not only in text - #53

Open
alberttwong wants to merge 1 commit into
redis:mainfrom
alberttwong:ltm-organize-structured-values
Open

alberttwong wants to merge 1 commit into
redis:mainfrom
alberttwong:ltm-organize-structured-values

Conversation

@alberttwong

@alberttwong alberttwong commented Sep 15, 2026 •

Copy link
Copy Markdown

What this changes

One reference file: skills/iris-development/references/ltm-organize.md (+ the vendored copy via npm run sync:plugins). Two added sections, no existing guidance removed.

Why

ltm-organize already teaches the right principle — its Incorrect block calls out "structured signals hidden inside free text". But the page's own Correct examples only apply that to the scoping fields. The value lives in the prose:

"text":      "User 42 prefers dark mode in the dashboard.",
"topics":    ["ui", "theme"],

ui and theme are categories. "dark mode" — the thing an application actually branches on — appears nowhere but the sentence. So an agent following this page verbatim ships a record whose value can only be recovered by re-parsing that sentence or by running a similarity search over it.

That is a silent-failure generator. Reword the sentence — a copy edit, a typo fix, a change of tone — and every stored record becomes unreadable, the caller falls back to its default, and nothing raises an error. A copy edit becomes a data-loss event, discovered months later as "that feature never worked".

This is not hypothetical. We shipped it in a product built on Agent Memory: user display preferences written as an English sentence and read back by exact string match against a table of those sentences. It worked. It would have kept working right up until someone edited the string. Found and fixed by moving the value into a key:value topic; the page is one step short of the guidance that would have prevented it.

What was added

1. A value your code reads must live in a structured field, not only in text.

  • Encode it as a key:value topic — theme:dark. Topics are filterable and round-trip verbatim, colon included.
  • The sentence stays, and its role is stated: prose for humans and for similarity, because the store is shared with memories the user actually said and theme=dark would be unpleasant to come across. Nothing parses it.
  • Decode against your own allowed set. A record can carry any string, so theme:chartreuse must read as unset — your default — rather than reaching the UI as a value it has never heard of. Shown with code, because "validate it" is the step people skip.
  • The value becomes filterable, which the sentence never was: filter_={"topics": {"all": ["theme:dark"]}}.
  • Rule of thumb: if rewording text would change what your application does, the value is in the wrong field.
  • One related note: reading a single known record is a get by id, not a search. A threshold slightly too strict returns nothing, and the caller cannot distinguish "unset" from "not found" — so the setting applies intermittently, which is worse than one that never applies.

2. memory_type is a closed set.

semantic / episodic / message are the only accepted values. The API field description mentions a "custom type registered on the store", which reads as an invitation — we took it, and got:

400 Invalid Request
memories[0]: memory type "preference" is not registered on this store

We could not find a registration route in the SDK, the models, or the docs. One line saying the set is closed saves the next person that detour, and points them at topics, which is filterable with eq / in / all and needs no registration.

Validation

$ npm run validate
Validation passed.                                  # plugin manifests
Validation passed.                                  # cursor plugins
Vendored plugin skills match skills/ (8 skills, 55 files).
Eval baseline validation passed for 8 suites.

$ npm run validate:skill-structure                  # skill-validator v1.5.6 on PATH
- skills/iris-development: 0 errors, 0 warnings
Total: 0 errors, 2 warnings                         # both pre-existing, on redis-search

skills/ edited, plugins/redis-development/skills/ regenerated with npm run sync:plugins, nothing hand-edited under plugins/.

Evals — not run, and why

Per CONTRIBUTING this is a meaningful content change and should carry evals; I have not run them, so please treat that as an open item rather than an omission I am arguing past.

The suite needs ANTHROPIC_SKILL_CREATOR_PATH and the claude CLI, and evals/iris-development/agent-memory/model-matrix.json is 3 models × 2 configurations × 2 repetitions over 6 evals — ~72 agent runs plus claude-sonnet-5 judging. That is real spend I was not in a position to authorize on this account.

The eval that covers this change is #5, organize-and-scope-search — it is the one whose behaviour could move, in either direction, so it is the one worth re-running before merge. Happy to run the suite and attach the "Against Baseline" screenshots if someone can point me at a sanctioned budget, or for a maintainer to run it.

Manual validation instead

Measured against a provisioned Agent Memory store, not asserted:

  • A topic round-trips verbatim. result_detail:full comes back as ["preferences", "result_detail:full"] — the colon survives, so key:value is usable as written. Also checked result-detail-full and result_detail=full; all three unchanged.
  • The stored record reads back correctly by id from its own namespace, with the value taken from the topic.
  • The property the change is about: with the value in a topic, rewording text at runtime and re-reading still returns full. Under the previous prose-matching code the same test returned the default. That is the before/after in one line.
  • memory_type: "preference" reproduces the 400 above; semantic is accepted.

Full context in the originating change: alberttwong/networkdex#40.

🤖 Generated with Claude Code


Note

Low Risk
Documentation-only changes to iris-development reference material; no runtime or API code paths modified.

Overview
Extends ltm-organize.md (source skill + vendored plugins/redis-development copy) with two guidance blocks—no existing text removed.

Values application code branches on must not live only in text. The doc now recommends key:value topics (e.g. theme:dark), keeping prose for humans/semantic search, with Python/TypeScript create examples, safe decoding against an allowlist, topic-based filters, a rule of thumb about rewording text, and a note to get by id for known settings instead of similarity search.

memory_type is documented as a closed set (semantic / episodic / message); unregistered types (e.g. preference) return 400, with direction to use topics for domain discriminators instead.

Reviewed by Cursor Bugbot for commit 997cbc8. Bugbot is set up for automated code reviews on this repo. Configure here.

`ltm-organize` already says not to stuff structured signals into `text`, and
its examples follow that for the *scoping* fields — `owner_id`, `namespace`,
`topics`. But the **value** in every example lives only in the prose:
`topics: ["ui", "theme"]` with "dark mode" appearing nowhere but the sentence.

An agent following the page verbatim therefore ships a record whose value can
only be recovered by re-parsing that sentence or by a similarity search. Reword
the sentence — a copy edit, a typo fix — and every stored record becomes
unreadable and the caller falls back to its default. Nothing raises an error.

We shipped exactly that in a product built on Agent Memory, found it later, and
fixed it by moving the value into a `key:value` topic. So this adds the step the
page stops one short of:

- put the value in a topic (`theme:dark`); the sentence stays as prose for
  humans and for similarity, and nothing parses it
- decode against your own allowed set, because a record can carry any string
  and an unrecognised value must read as unset rather than reach the UI
- filter on the topic, which the sentence never allowed
- rule of thumb: if rewording `text` would change what your application does,
  the value is in the wrong field
- reading one known record is a `get` by id, not a search — a threshold
  slightly too strict returns nothing and the caller cannot tell "unset" from
  "not found", so the setting applies intermittently

Also records that `memory_type` is a **closed** set. The field's API
description mentions a "custom type registered on the store", which reads as an
invitation; an unregistered value is rejected with
`400 … memory type "preference" is not registered on this store`. Use
`semantic` and put the discriminator in `topics`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant