fix(examples): put order amount in metadata.amount so RFM monetary works - #18
Merged
Merged
Conversation
The next-best-offer demo wrote each order's price only into the memory
`content` string ("Order — $42 pizza"). The RFM miner sums a structured
numeric field (metadata.value/total/amount, or a lineItems array) for the
Monetary score and does not parse prices out of free text, so every contact
in the demo scored M=0 — the monetary axis of RFM was dead in our own
flagship example, and customers copying it hit the same wall.
Move the dollar amount into `metadata.amount` (a JSON number) on each
order_placed event and drop it from the display text. Non-order events
(site_visit, email_open) carry no amount, as before.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
next-best-offer.tsdemo wrote each order's price only into the memorycontentstring ("Order #1 — $42 pizza") and never set a structured amount field.The RFM miner computes the Monetary score by summing a structured numeric field —
metadata.value/metadata.total/metadata.amount, or alineItems[]array — and deliberately does not parse prices out of free text (monetary_value). So every contact in the demo scored M=0 — the monetary axis of RFM was effectively dead in our own flagship example.Why it matters
A customer reproducing our
observe → mineMemories → getProfileflow copied this example faithfully and reportedmonetaryScorestuck at 0 for priced orders. The engine is behaving as designed; the example was teaching the wrong shape.Change
metadata: { amount: N }(a JSON number — the field the miner sums).site_visit,email_open) carry no amount, unchanged.With this, the three demo contacts now produce non-zero, differentiated Monetary scores instead of a uniform M=0.
Related
Pairs with the engine fix for the Frequency axis (F was scored against the requested query window instead of the subject's active span, flooring realistic order cadences to F=1) — same customer repro.
🤖 Generated with Claude Code