Session Mode

The Operator

Session Mode assigns a dedicated AI agent to drive a specific tool continuously. Unlike other modes that orchestrate multiple tools, Session Mode establishes a deep, stateful context with a single interface—perfect for debugging, shell access, or REPL interactions.

Key Capabilities

Continuous Interaction

Operates in a tight "Think-Act-Observe" loop with a single tool, maintaining context across many steps.

Deep Context

Maintains a full history of the session, allowing the AI to reference previous outputs and errors effectively.

Tool Agnostic

Can wrap any tool that accepts text input and provides text output, from SSH terminals to SQL consoles.

How It Works

1. Tool Selection

Based on the user's initial request (e.g., "Debug the database"), the system analyzes available tools and selects the most appropriate one (e.g., "Postgres Client") to initiate a session.

2. The Session Loop

The AI enters a loop where it:

  • Analyzes the current history and goal.
  • Generates a specific command for the tool.
  • Executes the command and captures the output.
  • Updates the history with the result.
3. Completion

The loop continues until the AI determines the goal has been satisfied or the maximum iteration limit is reached.

Configuration


open class SessionModeConfig(
    // Maximum number of steps the agent can take in one session
    var maxIterations: Int = 50,

    // Prompt used to select the appropriate tool
    var toolSelectionPrompt: String = "Select a tool to open a session with...",

    // The persona driving the tool
    var sessionOperatorPrompt: String = """
        You are an operator for a stateful tool.
        Your goal is: %s
        Review the history of interactions.
        If the goal is achieved, set isComplete to true.
        Otherwise, provide the next command...
    """.trimIndent()
) : CognitiveModeConfig(CognitiveModeType.Session)