Skip to main content

POST /v1/context

Returns concise, grounded, pre-turn context for your host application.

Request body

{
  "user_id": "user-123",
  "message": "Can you help me set up tests for this repo?",
  "containers": [
    {
      "id": "thread-abc",
      "type": "thread"
    }
  ],
  "scope_level": "user_global_container",
  "read_mode": "balanced",
  "budgets": {
    "max_output_tokens": 400,
    "max_candidate_memories": 30
  },
  "metadata": {
    "app": "example-host",
    "trace_id": "trace-002"
  }
}

Request fields

FieldTypeRequiredNotes
user_idstringYesUser identity whose memory should be searched.
messagestringYesCurrent user message used for retrieval and context synthesis.
containersContainerHint[]NoOptional container hints used when scope_level includes container memory.
scope_leveluser | user_global | user_global_containerNoDefaults to user_global.
read_modesimple | balanced | deepNoDefaults to balanced.
budgetsRetrievalBudgetsNoOptional read budget override block.
metadataRequestMetadataNoOptional host metadata.

ContainerHint

FieldTypeRequiredNotes
idstringYesContainer identifier.
typestring | nullNoInformational container type.

RetrievalBudgets

FieldTypeRequiredNotes
max_output_tokensintegerNoDefaults to 400. Range: 1-4000.
max_candidate_memoriesintegerNoDefaults to 30. Range: 1-200.

RequestMetadata

FieldTypeRequiredNotes
appstring | nullNoHost application name.
sourcestring | nullNoSource channel name.
modelstring | nullNoUpstream model identifier.
trace_idstring | nullNoTrace or correlation id.

Response

{
  "status": "ok",
  "has_usable_context": true,
  "context_enhancement": "<contextenhancement>...</contextenhancement>",
  "abstained_reason": null,
  "diagnostics": {
    "scope_applied": "user_global_container",
    "read_mode": "balanced",
    "user_found": true,
    "candidate_count": 9,
    "used_memory_count": 3,
    "missing_containers": [],
    "source_breakdown": {
      "snapshot": 2,
      "vector": 4,
      "metadata": 3,
      "graph": 1
    },
    "evidence_strength": 0.78,
    "warnings": []
  }
}

XML block format

<contextenhancement>
  <scope>user_global_container</scope>
  <summary>...</summary>
  <active_context>...</active_context>
  <confidence_note>Use as supportive context, not unquestionable fact.</confidence_note>
</contextenhancement>

Notes

  • If the user does not exist, the response returns not_found.
  • Missing containers are reported in diagnostics.
  • The endpoint may abstain when evidence is weak or irrelevant.
  • Public diagnostics are relevance-gated. Unrelated raw retrieval hits are kept internal and do not appear in candidate_count, used_memory_count, or source_breakdown.
  • If no relevant memories survive gating, the endpoint short-circuits before the enhancer LLM runs.

Response field notes

FieldTypeAlways presentNotes
statusstringYesUsually ok, or not_found when the user does not exist.
has_usable_contextbooleanYesfalse when aCMF abstains.
context_enhancementstringYesXML block when context is usable, otherwise an empty string.
abstained_reasonstring | nullYesSet when aCMF declines to inject context.
diagnosticsRetrievalDiagnosticsYesRetrieval summary for the request.