Guides

Annotate Context

Capture model-visible, tool-visible, state-only, and metadata-only decision inputs.

Context annotation is how you turn hidden framework state into searchable evidence. Without it, analysts see events but not the decision inputs that made those events likely.

Basic Annotation

await client.annotateContext({
  kind: "retrieval_chunk",
  path: "retrieval.policy[0]",
  value: {
    source: "policy-v7",
    text: "Refunds over 500 require manager approval.",
    score: 0.91,
  },
  visibility: "model_visible",
  provenance: "policy-index",
});

What To Annotate

KindRecommended path
system_messageprompt.system
developer_messageprompt.developer[0]
user_messageprompt.user
prompt_clauseprompt.system.clauses[0]
retrieval_chunkretrieval.<source>[<rank>]
memory_itemmemory.<store>.<key>
state_fieldstate.<field>
tool_schematools.<toolName>.schema
tool_argumenttools.<toolName>.args
tool_resulttools.<toolName>.result
model_settingmodel.settings.temperature

Path Design

Good context paths are stable, scoped, and searchable:

prompt.system.clauses[2]
retrieval.claimPolicy[0]
memory.customerProfile.riskScore
state.claim.status
tools.lookup_claim.schema
model.settings.temperature

Avoid using random IDs in paths unless they are the real domain key. Put volatile IDs in metadata.

Visibility

VisibilityUse
model_visibleAnything the model could see or infer directly.
tool_visibleTool inputs/results that a tool saw but the model may not have seen.
state_onlyRuntime state used for decisions or branching.
metadata_onlySettings, versions, counters, and metadata.

Advice

  • Prefer many targeted context items over one giant prompt blob.
  • Capture prompt clauses when individual instructions may be causal.
  • Add provenance to retrieval and memory.
  • Capture tool schemas before tool choice, not only executed args.
  • Use redaction policy before annotating sensitive values.

On this page