Skip to content

Overview

contox_context_pack assembles a focused context document tailored to a specific task. Instead of loading the entire brain (which may be large), it uses V2 semantic search to find only the most relevant memory items and assembles them into a token-budgeted markdown document.

This is useful when the full brain is too large for the context window, or when you want highly targeted context for a specific task.

Parameters

NameTypeRequiredDefaultDescription
taskstringYesCurrent task description — used for semantic search
scopeenumNo"relevant"How much context to include: "full", "relevant", or "minimal"
tokenBudgetnumberNo4000Approximate token budget for the pack

Scope options

ScopeBehavior
relevantSemantic search for task-related items only (default)
fullComplete brain document, truncated to the token budget
minimalTop 5 highest-confidence items only

Return value

Returns a markdown document containing the most relevant memory items, assembled within the specified token budget. The document is structured with headers and metadata for each included item.

Usage examples

Getting context for a specific task

User: I need to work on the authentication flow

Claude calls: contox_context_pack({
  task: "Implement OAuth2 authentication flow with Google provider",
  scope: "relevant",
  tokenBudget: 4000
})

Response:
# Context Pack — OAuth2 authentication

## JWT Authentication System
> confidence: 0.95 | root/implementation
Implemented JWT-based auth with access/refresh token rotation...

## Auth Middleware Pattern
> confidence: 0.90 | root/architecture
All /dashboard/* routes are protected by Next.js middleware...

## Session Management Bug Fix
> confidence: 0.85 | root/bugs
Fixed race condition in token refresh...

Minimal context for a quick fix

Claude calls: contox_context_pack({
  task: "Fix CSS z-index issue on modal overlay",
  scope: "minimal",
  tokenBudget: 2000
})

Full brain within a budget

Claude calls: contox_context_pack({
  task: "General project overview",
  scope: "full",
  tokenBudget: 8000
})

Notes

  • The relevant scope uses V2 semantic embeddings to match memory items to the task description. If semantic search is unavailable (HMAC secret not configured), it falls back to the full scope.
  • The token budget is approximate — the actual output may be slightly over or under the specified limit.
  • The minimal scope always returns the top 5 highest-confidence items regardless of task relevance, which is useful for getting the most important project context quickly.
  • For loading the complete brain without any filtering or budget, use contox_get_memory instead.