Search Memories Within a Token Budget
memory-budgetRetrieve memories that fit a specified token budget, ranked by relevance and importance, so AI agents can fill limited context slots without exceeding limits.
Instructions
Like memory-search, but returns memories that fit within a TOKEN BUDGET instead of a count limit. Greedy fill from highest-relevance memories: candidates ranked by score × importance, included until the next entry would exceed the budget. Used by przm's Context Budget Engine: the persona/memories slot allocates N tokens, and przm Memory returns "the most useful subset that fits." Returns the same memory shape as memory-search plus { budgetTokens, usedTokens, includedCount, candidateCount } so callers can see how the budget got spent.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>",
"budgetTokens": "<budgetTokens>"
},
"name": "memory-budget"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | No | Filter by exact tag match. | |
| query | Yes | Natural language search query. | |
| topic | No | Filter by topic. | |
| domain | No | Filter by domain/project. | |
| format | No | If true, returns formatted text grouped by cognitive layer instead of JSON. | |
| budgetTokens | Yes | Token budget for the returned set. Greedy fill stops before exceeding this. Recommended range: 200 (tight slot) to 5000 (generous). | |
| candidateLimit | No | Max candidates to consider before budget filtering (default: 50). Larger candidate pool = better quality picks but slower search. |