-
-
Notifications
You must be signed in to change notification settings - Fork 18
Metacognition
CortexPrism assesses every user task before execution and reflects on every agent turn afterwards. The metacognition system scores confidence, classifies task types, escalates low-confidence assessments, and runs adversarial second-pass critiques.
src/agent/metacog.ts analyzes user messages for:
-
Ambiguity — unclear intent triggers
ask_firstdecision -
Complexity — multi-step tasks trigger
plan_with_rollback - Code tasks — patterns like "fix bug", "implement", "refactor"
- Destructive intent — patterns like "rm", "delete", "drop"
-
Independent subtasks — "and also", "then after" triggers
parallelize
| Decision | Meaning |
|---|---|
direct |
Execute immediately |
ask_first |
Request clarification before proceeding |
delegate |
Hand off to a sub-agent |
plan_with_rollback |
Generate a plan artifact before executing |
parallelize |
Fan out to multiple sub-agents concurrently |
When confidence falls below 0.35 for a direct decision, the system auto-escalates to ask_first:
if confidence < 0.35 and decision === 'direct':
escalate to ask_first with clarification prompt
log escalation event to lens_events
Escalation events appear in the Metacognition page history with a red ⚡ escalated badge.
After each turn (when reflection is enabled), a second-pass critique runs using a skeptical/adversarial system prompt that actively looks for:
- Missed edge cases and error handling gaps
- Validation omissions
- Security concerns the agent may have overlooked
- Alternative approaches
Results are stored in reflection_memory with category adversarial and surfaced as critique cards in the Metacognition web UI.
| Endpoint | Description |
|---|---|
GET /api/metacognition/history |
Recent assessments, reflections, and escalations (limit 80) |
GET /api/metacognition/decisions?sessionId= |
Session-scoped decision timeline |
GET /api/metacognition/summary |
Decision distribution, total escalations, recent critiques |
The Metacognition page shows:
- Decision Distribution — bar chart of decision types (direct, ask_first, delegate, plan_with_rollback, parallelize)
- Decision History — timeline with color-coded decisions and escalation badges
- Adversarial Critiques — critique cards showing issues from the adversarial reflection pass
CortexPrism — Open-source agentic AI harness · MIT License · Built with Deno 2.x + TypeScript
- Agent Loop
- Metacognition
- Memory System
- Skills System
- Sub-Agents
- Built-in Tools
- Code Intelligence
- Code Sandbox
- Cross-Agent Context Protocol
- Prompt Lab
- PKM Assistant
- Voice Pipeline
- Computer Use
- Browser Tool
- Git & GitHub
- Scheduler & Jobs
- Dashboard
- Observability
- A2A Protocol
- MCP Gateway
- Distributed Nodes
- Memori Checkpoints
- Eval System
- Workflow Engine
- Triggers
- Projects
- TUI
- Glossary
- Update System