Skip to content

Add agent memory Context API example - #2

Open
CalebKiragu wants to merge 1 commit into
Evokoa:mainfrom
DataYetu:feature/agent-memory-example
Open

Add agent memory Context API example#2
CalebKiragu wants to merge 1 commit into
Evokoa:mainfrom
DataYetu:feature/agent-memory-example

Conversation

@CalebKiragu

Copy link
Copy Markdown

Summary

  • Add examples/agent_memory/ showing how application teams retrieve durable agent memory through the SDK 0.2 project.context API.
  • Mirror the pgContext SQL demo: schema seed, collection config, filtered search, hybrid retrieval, and LLM context-pack assembly.

Motivation

SDK 0.2 shipped project.context, but there was no end-to-end example directory. This gives app developers a copy-pasteable pattern aligned with the pgContext engine demo and Polygres Memory messaging.

Implementation

  • examples/agent_memory/schema.sql — shared agent-memory schema/seed data
  • examples/agent_memory/collection.json — CLI preflight/create payload
  • examples/agent_memory/demo.py — capabilities → search → text_hybrid → context pack
  • examples/agent_memory/dry_run.py — offline validation without live credentials
  • examples/agent_memory/README.md — setup guide for reviewers

Benefits

  • Shows the application layer of Postgres-as-agent-memory on top of Context API
  • Reviewers can validate wiring offline via python examples/agent_memory/dry_run.py
  • Cross-links naturally to the pgContext SQL walkthrough (engine truth)

Tradeoffs

  • Live end-to-end test requires a Polygres project + API key (documented in README)
  • Example uses fixture 4-D embeddings, not production model output

Testing

Offline (no credentials):

python3 -m venv .venv && source .venv/bin/activate
pip install -e .
python examples/agent_memory/dry_run.py

Live (requires Polygres project):

polygres db psql < examples/agent_memory/schema.sql
# create collection per examples/agent_memory/README.md
export POLYGRES_API_KEY=... POLYGRES_RUNTIME_URL=...
python examples/agent_memory/demo.py

Dry run passed locally against mocked Runtime responses and validated collection.json against CollectionCreateRequest.

Related

Companion pgContext PR: Evokoa/pgContext (agent memory SQL example)

Made with Cursor

Provide a runnable SDK walkthrough that mirrors the pgContext SQL demo,
including schema seeding, collection preflight config, mocked dry-run
checks, and application-side context-pack assembly.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant