Blog / release

Token-economy navigation: locate, then expand

2026-06-05 · pgmnemo contributors · ~4 min read
releasev0.8.0token-economyretrieval

v0.8.0 introduces a two-phase navigate_locate() / navigate_expand() retrieval pattern for cost-aware recall under a token budget, plus safe in-place maintenance primitives. No schema break — ALTER EXTENSION pgmnemo UPDATE TO '0.8.0'.

The problem: recall that ignores your token budget

Classic recall returns full lesson content for the top-k matches. At agent scale that's wasteful: you pay context tokens for rows the agent may never read, and you can't see the cost until the prompt is already assembled. The retrieval step should respect a budget the way a query planner respects a LIMIT.

Locate, then expand

navigate_locate() returns only the matching IDs and their scores within a token budget — cheap, no content payload. You decide what's worth reading. navigate_expand() then fetches the content (and optional graph neighbours) only for the IDs you keep.

-- phase 1: which lessons matter, under a 2k-token budget
SELECT id, score
FROM pgmnemo.navigate_locate(
  query_text   => 'how to avoid a retry storm',
  token_budget => 2000
);

-- phase 2: fetch content only for what you keep
SELECT id, content
FROM pgmnemo.navigate_expand(ids => ARRAY[12, 47, 90]);

The split makes retrieval cost an explicit, inspectable decision — in SQL, before a single context token is spent. (A measured token-savings benchmark is in progress; we publish numbers once they're real.)

Maintenance that coexists with live ingestion

Two more additions for production corpora:

Nothing breaks

Existing recall_lessons() / recall_hybrid() callers are untouched — same signatures, same returns. Outcome-learning (reinforce() / confidence, shipped v0.7.0) keeps running. Upgrade is one statement; rollback caveats are documented in docs/MIGRATION.md.

← Back to all posts