Build Session Context
build_contextAssemble a token-budgeted <memory_context> XML/Markdown block from a namespace (read-only, idempotent; consumes 1 Read API call) and return { context, memories_used }. Ranks up to 500 namespace memories deterministically and packs lines greedily up to max(256, token_budget * 4) characters under "## Established Facts" (core/semantic) and "## Recent Context" (episodic/buffer). Use at session start or before planning a task to ground the model in one call; use recall_memories instead when you need raw memory objects and IDs.
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": {
"namespace": "<namespace>",
"query": "<query>"
},
"name": "build_context"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Active task, feature, or session topic used to rank relevant facts and history. | |
| namespace | Yes | Logical workspace namespace to ground context around (never prefix with "org:"). | |
| token_budget | No | Maximum token budget (~4 characters per token, default 4096) before truncating lower-ranked items. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context | Yes | Formatted <memory_context>...</memory_context> block. | |
| memories_used | Yes | Number of memories packed within token_budget. |