AdaptivePlanningMode

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

Core Architecture Stateful Strategy Engine
⚙️ 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

Iteration 3
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...

Mode Name Architecture Best Use Case
WaterfallMode Plan -> Review -> Execute Well-defined problems where the user must approve the entire roadmap before execution begins.
ConversationalMode Listen -> Act -> Reply Interactive debugging, exploratory sessions, or simple "Chat with Code" workflows.
AdaptivePlanningMode Loop(Think -> Act -> Reflect) Complex, ambiguous goals requiring research, trial-and-error, and self-correction.
HierarchicalPlanningMode Tree(Decompose -> Delegate) Massive projects. Breaks goals into sub-goals and spawns SubPlanningTasks to handle them.

Strategies define the "Persona" and internal state structure. This separates control flow from reasoning style.

Strategy Internal State Reasoning Style
Project Manager ReasoningState Generalist. Tracks short-term vs. long-term goals and manages a task queue.
Scientific Method ScientificState Debugger. Formulates hypotheses, tracks established facts, and attempts to falsify theories.
Agile Developer AgileState Coder. Follows a TDD loop: Test Failing -> Implementing -> Refactoring.
Critical Auditor AuditState Security. Adversarial mindset designed to find flaws rather than fix them.
kotlin

class MyCustomMode(val config: OrchestrationConfig) {
    fun run(task: SessionTask, userPrompt: String, availableTasks: List) {
        val strategy = CognitiveSchemaStrategy.ScientificMethod
        var state = strategy.initialize(userPrompt, config.defaultSmart)

        while (!state.isComplete()) {
            val guidance = strategy.getTaskSelectionGuidance(state)
            val tool = availableTasks.first { it.canHandle(guidance) }
            val result = tool.execute(task.ui, guidance, config)

            state = strategy.update(state, result, config.defaultSmart)
            task.transcript()?.write("## Step Complete: ${state.currentPhase}\n".toByteArray())
        }
        task.complete("Goal Achieved")
    }
}
                    

Integration Guide

Configuration

Reference the mode in your OrchestrationConfig to enable autonomous planning.


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

Observability Standards

All modes must adhere to the Transparency First principle.

  • Mermaid Diagrams: Visualize the state machine in the transcript.
  • Collapsed Details: Use <details> tags for raw JSON state dumps.
  • Graceful Degradation: Catch LLM hallucinations and attempt to simplify prompts before crashing.