Home > Core > Cognitive Modes

CognitiveMode

Core Architecture Stateful Strategy Engine

The autonomous control loop that orchestrates task execution, manages reasoning state, and defines the agent's problem-solving persona.

⚙️ OrchestrationConfig.json
{
  "mode": "AdaptivePlanningMode",
  "schema_strategy": "ScientificMethod",
  "auto_fix": true,
  "model_config": {
    "smart": "gpt-4-turbo",
    "fast": "gpt-3.5-turbo"
  }
}
🧠 Live Transcript

State: Hypothesis Testing

graph TD A[Analyze Error] --> B{Hypothesis?} B -->|Network| C[Check DNS] B -->|Code| D[Run Linter] C --> E[Refute Hypothesis] E --> A

Thinking: Network checks passed. Switching strategy to Code Analysis.

Executing: RunCodeTask...

Architectural Patterns

Mode Name Architecture Best Use Case
WaterfallMode Plan -> Review -> Execute Well-defined problems where the user must approve the entire roadmap.
ConversationalMode Listen -> Act -> Reply Interactive debugging or simple "Chat with Code" workflows.
AdaptivePlanningMode Loop(Think -> Act -> Reflect) Complex, ambiguous goals requiring research and self-correction.
HierarchicalPlanningMode Tree(Decompose -> Delegate) Massive projects requiring sub-goal decomposition.

Cognitive Schema Strategies

Strategies define the "Persona" and internal state structure, separating control flow from reasoning style.

Strategy Internal State Reasoning Style
Project Manager ReasoningState Generalist. Tracks short-term vs. long-term goals.
Scientific Method ScientificState Debugger. Formulates hypotheses and attempts to falsify theories.
Agile Developer AgileState Coder. Follows TDD loop: Test Failing -> Implementing -> Refactoring.
Critical Auditor AuditState Security. Adversarial mindset designed to find flaws.

Implementation Skeleton

To create a custom mode, extend CognitiveMode and implement the handleUserMessage loop.

kotlin
class MyCustomMode(
    config: OrchestrationConfig,
    session: Session,
    user: User
) : CognitiveMode<MyConfig>(config, session, user) {

    override fun handleUserMessage(userMessage: String, task: SessionTask) {
        // 1. Initialize Strategy (The "Brain")
        val strategy = CognitiveSchemaStrategy.ScientificMethod
        var state = strategy.initialize(userMessage, orchestrationConfig.smartModel)

        // 2. Execution Loop
        while (!state.isComplete()) {
            val guidance = strategy.getTaskSelectionGuidance(state)
            
            // Select & Execute Task
            val tool = enabledTasks.first { it.canHandle(guidance) }
            val result = tool.execute(task, guidance)

            // Update State (Reflection)
            state = strategy.update(state, result)

            // Observability: Write to transcript
            task.transcript()?.write("## Step Complete: ${state.currentPhase}\n".toByteArray())
        }
    }
}

Integration Guide

Configuration

Reference your mode in the OrchestrationConfig.

kotlin
val config = OrchestrationConfig(
    mode = CognitiveModeType.AdaptivePlanningMode,
    overrides = mapOf("schema_strategy" to "AgileDeveloper"),
    autoFix = true
)

Observability Standards