Fundamentals
RAG and Cached Context
Neutron AI supports two complementary patterns for agent memory:
- Retrieval: find relevant memory for a task.
- Cached context: reuse a safe, bounded context pack when a similar task repeats.
This helps agents stay consistent without sending every historical interaction back to a model.
Retrieval
Use retrieval when the task is specific, new, or likely to depend on recent changes.
const results = await client.recall({
scopeId: process.env.NEUTRON_SCOPE_ID!,
query: "customer onboarding constraints",
limit: 8
});
Cached Context
Use cached context when the same agent performs repeated work for the same scope.
const context_pack = await client.agentContext({
scopeIds: [process.env.NEUTRON_SCOPE_ID!, process.env.NEUTRON_PROJECT_SCOPE_ID!],
agentId: "agent_success",
task: "Prepare the next onboarding follow-up",
cachePolicy: {
mode: "prefer_cache",
keyMode: "intent_profile",
ttlSeconds: 300
}
});
Choosing a Policy
| Policy | Use when |
|---|---|
bypass_cache | The task is sensitive, one-off, or must use the freshest possible memory. |
prefer_cache | The task is repeated and can safely reuse recent context. |
refresh_cache | You want to rebuild the context pack after a known update. |
Safe Defaults
Do not cache secrets, credentials, raw payment data, or unnecessary personal data. Keep task prompts narrow and scope IDs explicit so context packs stay relevant and auditable.