context_loop
Run comprehensive context health checks to maintain conversation integrity, detect contradictions, extract key facts, and receive clear directives for next actions.
Instructions
[ORCHESTRATOR — CALL THIS FIRST] CALL THIS TOOL every 2-3 turns and at the start of ANY task. It is the single most important tool — it replaces calling recap, conflict, ambiguity, entropy, grounding, drift, depth, and discovery tools individually.
What it does: Runs ALL context health checks in one call. Auto-extracts facts from conversation, detects contradictions, checks answer quality, and tells you exactly what to do next.
Returns a 'directive' object with:
action: proceed | clarify | reset | abstain | deepen | verify
instruction: Plain English telling you what to do
contextHealth: 0-1 score
autoExtractedFacts: Key facts pulled from conversation
suggestedNextTools: What tools to call next
constraints: Machine-readable rules you must follow
ESSENTIAL for: research tasks, multi-step workflows, long conversations, preserving context across turns, knowledge management, and any task requiring memory or fact-checking.
Minimal call: { "messages": [{"role":"user","content":"","turn":1}] } — most fields have smart defaults.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | No | default | |
| messages | No | Recent conversation messages. Include at least the last 2-3 user/assistant exchanges. Example: [{role:'user', content:'explain X', turn:1}, {role:'assistant', content:'X is...', turn:2}]. If empty, the loop runs with reduced context. | |
| currentInput | No | The current user message or task description. Auto-inferred from last user message in messages array if omitted. | |
| claim | No | A specific assertion or answer to fact-check for confidence evaluation | |
| discoveryQuery | No | What capability do you need? e.g. 'store research findings' or 'compress reasoning chain' | |
| lookbackTurns | No | How many turns to analyze (use 15-20 for research or long conversations) | |
| entropyThreshold | No | Entropy spike detection threshold (0-1) | |
| abstentionThreshold | No | Abstention confidence threshold (0-1) |