get_context
Build a token-budgeted memory context block from recent and semantically relevant past events, ready to paste into an agent's system prompt. Guide retrieval by agent ID and upcoming task.
Instructions
Get a formatted memory context block ready to inject into a system prompt.
This is the drop-in replacement for LLM-provided memory (Claude Projects,
ChatGPT memory). It combines recent events with semantically relevant past
events, fits within a token budget, and formats as plain text.
Typical usage:
context = await get_context("support-bot", "user asking about billing")
system_prompt = f"You are a support agent.\n\n{context}"
Args:
agent: Your agent identifier
task: What the agent is about to do (guides semantic retrieval)
max_tokens: Token budget for the context block (default 2000)
session_id: Current session ID to exclude from context (optional)
Returns:
Formatted context string -- paste directly into your system prompt.
On error: {"error": <message>, "status": <http status>}.
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": {
"agent": "<agent>",
"task": "<task>"
},
"name": "get_context"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | ||
| agent | Yes | ||
| max_tokens | No | ||
| session_id | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |