Skip to content

memory write: section bodies containing get re-tokenized into top-level sections + no delete subcommand #1978

@chubes4

Description

@chubes4

Symptoms

Two bugs in wp datamachine memory surfaced while updating an agent's MEMORY.md in a long session today.

1. memory write re-tokenizes ## headings inside section content

Calling:

wp datamachine memory write "Transcribe Pipeline" --from-file=/tmp/notes.md --agent=extra-chill-bot

…where notes.md contains second-level subheadings like:

Studio's Transcribe feature is a fully headless audio→draft pipeline.

## Stack

...

## Network options

...

…doesn't write a single "Transcribe Pipeline" section with a body containing nested subheadings. Instead, it tokenizes every ## line as a new sibling top-level section. After the write, memory sections returns:

... existing sections ...
Transcribe Pipeline
Stack
Network options
Module artifact matrix
Scope allowlist
CORS
Smoke-test pattern
Common pitfalls
Behavior rule

The composer flattened the markdown hierarchy. The Transcribe Pipeline section ends up with only the leading paragraph (everything before the first ##), and the rest becomes orphan top-level sections.

Expected behavior: memory write <section> <content> should treat the content arg as opaque — write it verbatim under the named section. The body may contain any markdown, including ## subheadings, without being re-parsed.

Workaround: demote all ## to ### (or use bold prose) in any content passed to memory write. Not obvious from the help text — the docs say "Content to write" with no mention of the heading-tokenization gotcha.

2. No delete subcommand for sections

memory write "<section>" "" doesn't delete the section — it sets the body to empty, leaving a zombie ## <section> heading in the file with no content. Running it eight times to clean up the bug above produced eight empty ## blocks polluting MEMORY.md.

The only workaround was manual file editing (Python regex on /var/www/.../MEMORY.md), which defeats the purpose of having a memory subcommand surface.

Expected behavior: wp datamachine memory delete <section> --agent=<slug> that removes both the heading and the (empty or non-empty) body.

Repro

cat > /tmp/test-section.md <<'EOM'
Lead paragraph.

## Subheading A
Body of A.

## Subheading B
Body of B.
EOM

wp datamachine memory write "Test Section" --from-file=/tmp/test-section.md --agent=<some-agent>
wp datamachine memory sections --agent=<some-agent>
# Expected: "Test Section" appears once with the full markdown body
# Actual: "Test Section" + "Subheading A" + "Subheading B" all appear as top-level sections

Severity

Medium. Workarounds exist but are surprising for a tool whose job is "write structured content to a markdown file." Long-form section content with internal headings is exactly the use case a memory tool should handle gracefully.

Suggested fix direction

  • Treat the body of memory write <section> <body> as opaque text. Don't tokenize headings inside it.
  • Add memory delete <section> [--agent=<slug>] that removes the section and its body.
  • Add a section-rename subcommand for completeness (memory rename <old> <new>).

Related

  • Surfaced while documenting the Transcribe Pipeline architecture on extra-chill-bot's MEMORY.md after a long session. Cleanup required direct file editing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions