Skip to content

fix three retrieval and extraction defects in nams provider - #176

Merged
prakriti-solankey merged 3 commits into
mainfrom
vercel-nams-provider
Aug 18, 2026
Merged

fix three retrieval and extraction defects in nams provider#176
prakriti-solankey merged 3 commits into
mainfrom
vercel-nams-provider

Conversation

@prakriti-solankey

Copy link
Copy Markdown
Collaborator

Fixed these issues

  1. query_memory dropped entity names. Hits were built from e.description ?? e.name, and createGraphExtractor always writes a
    description, so the name -- which is the actual fact -- never reached the model. Asked "which language do I prefer?" the agent replied that the memory didn't specify, and sometimes reconstructed a fragment of a name it had never been shown ("You're based in Ban."). Long-term hits now render as "name -- description". Dedup keys separately from display, so cross-source dedup is unchanged and two entities sharing a description both survive.

  2. Extraction never ran on OpenAI. Strict structured-output mode requires every property to appear in required; both .optional() on entity.description and .default([]) on relationships dropped their keys. OpenAI reports only the first, so fixing description alone would have left the feature dead. storeMemory swallowed the rejection and fell back to a flat entity, which is why this survived a release. A test now asserts strict compliance against the schema actually sent.

  3. Memory extracted its own output. Answering "what do you remember about me?" and storing that answer minted entities about remembering (profile details [Object]), which then outranked the real facts on the next such question -- every ask degraded the next. store_memory's description previously invited exactly this; it now tells the model never to store recall output. Backing that up, extraction skips common nouns and keeps the proper nouns it already asks for, which needs no vocabulary list and does not misfire on caseless scripts.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-memory Ready Ready Preview Aug 17, 2026 4:20pm

Request Review

@prakriti-solankey prakriti-solankey self-assigned this Aug 7, 2026
@prakriti-solankey

Copy link
Copy Markdown
Collaborator Author

fix prompt mutation on retry, add ensureMemoryStored

transformParams edited params.prompt in place. The AI SDK rebuilds the
params object for each retry attempt of a step but passes the same prompt
array every time, and transformParams re-runs on every attempt — so a
retried call stacked a second memory block onto the prompt, then persisted
the memory-augmented text as the user's own message. That message is
itself retrievable, so each retry permanently poisoned short-term memory.
withMemoryBlock() now returns a copy and the clean-text snapshot is keyed
on the returned params object, so re-entry is idempotent by construction.

The existing multi-step test missed this: it passes a fresh prompt array
per call, which models the tool loop correctly (the SDK does rebuild
promptMessages per step) but not the retry path. Two regression tests
cover it now.

ensureMemoryStored(tools) is the store_memory counterpart to
enforceQueryMemory(). prepareStep cannot reach the write side — the loop
ends when the model emits final text, so there is no later step to force —
so the guarantee runs as an onFinish hook instead, persisting the turn when
the model never called store_memory. Defaults to type 'interaction' rather
than 'fact': storing an agent's own summary as a fact is the
self-referential input the graph extractor already rejects.

@prakriti-solankey
prakriti-solankey merged commit 4eb4445 into main Aug 18, 2026
6 of 7 checks passed
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.

2 participants