Skip to content

feat(sdk): upsert or key-based recall for structured agent state (JSON profile pattern) #247

@Olympusxvn

Description

@Olympusxvn

Problem

For structured agent state (user profile JSON: predictions, roast history, flip-flop count), we currently:

  1. rememberAndWait the full JSON snapshot on every mutation
  2. recall({ query: "fan profile predictions favorite team", limit: 10 }) on load
  3. Parse the first hit containing a magic prefix FAN_PROFILE_JSON:

This works for a hackathon MVP but is fragile:

  • Stale reads: semantic recall may return an older snapshot if multiple versions exist in the namespace
  • No exact key: we cannot fetch "current profile" deterministically
  • Write amplification: every small update re-embeds the entire JSON blob

Reference: https://github.com/Olympusxvn/special-one-agent/blob/master/lib/memory/fan-profile.ts

Proposed improvements (any of)

  1. rememberUpsert(key, value, namespace) — replace prior memory with same key/tag
  2. recallByKey(key, namespace) — deterministic fetch for structured state
  3. Documented pattern if upsert exists elsewhere (e.g. via metadata/tags) — we may have missed it

Use case

World Cup prediction roast bot: fan profile must be authoritative (latest predictions, toxicity inputs), while semantic lines ("Prediction WRONG: …") remain good fits for recall by meaning.

Environment

  • @mysten-incubation/memwal@0.0.7, mainnet relayer
  • Walrus Sessions 4 project: Mr. Toxic Special One

Thanks — this was the main SDK gap we hit when moving from in-memory demo to persistent Walrus memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions