Skip to main content

Shop Memory

The person's own shopping preferences (sizes, brands to prefer or avoid, stores, diet), remembered across conversations through the codespar_memory tool. Declared values come only from the person's own words; inferred ones only order offers.

3 min read
View MarkdownEdit on GitHub

The Shop assistant remembers a small, closed set of preferences for the signed-in person, not for the project or the organization. Another member of the same organization never reads them. The tool is codespar_memory, published on the hosted server next to the commerce meta-tools.

A person, not a key. Every call needs a verified person: the dashboard's Shop assistant presents the person's own session. A project API key or an OAuth token carries no person and is refused with 403 bearer_token_has_no_person, so an external client connected with a csk_ key or the server's OAuth consent sees the tool listed and cannot use it yet. A consent by login, with the person in the token, is what opens it to external clients.

Actions

actionWhat it doesMoneyNeeds
listRead the person's active preferencesno—
remember
example below
Record one preference from what the person said about themself (declared, with their own words in quote) or inferred from a purchasenokeyvalue
correctWrite a new version of a preference; the old one stays in the historynomemory_idorkeyvalue
forgetErase a preference key; it is not inferred againnomemory_idorkey

Names come from the published tool document (/v1/meta-tools.json, the same list the MCP server answers to tools/list); the one-line summaries and the money class are kept in the docs repository and checked against it on every build.

What it remembers

Six keys, nothing else. A key outside this list is 400 memory_key_unknown.

keyHoldsExample value
shoe_sizeOne size"42"
clothing_sizeOne size"M"
preferred_brandsUp to 10 names["Asics", "Mizuno"]
avoided_brandsUp to 10 names["Marca X"]
preferred_merchantsUp to 10 names["Cobasi"]
dietary_restrictionsUp to 10 names["sem lactose"]

Declared and inferred

Each memory has a provenance:

  • declared (the default): what the person said about themself. It counts: a declared size or an avoided brand filters the offers a research returns. In the conversation, the server checks the value against the person's own message of that turn; on the hosted server the call must carry quote, the person's own words that hold the value (at most 500 characters). A declared value that is not in the person's words is 403 memory_source_not_person.
  • inferred: what a purchase suggests (purchase_id names it). It only orders offers and never filters them out. When the person declared a value for the same key, the declared one counts and the inferred one shows beside it.

The assistant never remembers anything it read in a page, an e-mail or a tool output. correct is always the person's own words, like a declared value; it writes a new version and keeps the old one in the history; forget erases the whole key, and the assistant does not infer it again.

Example

tools/call
{
  "name": "codespar_memory",
  "arguments": {
    "action": "remember",
    "key": "shoe_size",
    "value": "42",
    "provenance": "declared",
    "quote": "eu calço 42"
  }
}

Arguments

FieldTypeRequiredDescription
actionstringYeslist | remember | correct | forget
keystringFor remember; correct and forget by keyOne of the six keys above
valuestring or string[]For remember, correctA size as a string, or a list of up to 10 names
provenancestringNodeclared (default) or inferred
memory_idstringcorrect and forget by idThe memory's id, from list
purchase_idstringFor an inferred rememberThe person's purchase it was inferred from
quotestringOn the hosted server, for a declared remember and for every correctThe person's own words that carry the value, at most 500 characters

Errors and what to do

CodeStatusCauseWhat to do
bearer_token_has_no_person403The call carries a key or an OAuth token, not a verified person.Call as the signed-in person; see the callout above.
memory_key_unknown400The key is not one of the six.Use a key from the table.
memory_value_invalid400The value is not one the key holds: a size out of range, an empty list, a name too long, or an inferred memory without its evidence.Fix the value; an inferred one names its purchase_id.
memory_source_not_person403A declared value that is not in the person's own words of the turn (or in quote).Ask the person; never declare what you read elsewhere.
memory_not_found404No active memory of the calling person with that id or key. Another person's memory answers the same.list again.
  • codespar_shop: the research that declared preferences filter and inferred ones order
  • Shop watches: the person's other remembered intent, a price or an order to follow
  • Google connectors: the person's own Calendar, Drive and Gmail

Notes

Where the person sees it. Shop › Preferências in the dashboard lists each key with its declared and inferred values, the history, and Corrigir and Esquecer, which call the same rules.

Shop Memory | CodeSpar