Skip to main content
Glama

Think Batch

think_batch

Submit multiple reasoning thoughts at once to reduce round-trips and process complete reasoning chains efficiently with atomic validation.

Instructions

Submit multiple thoughts at once (Burst Thinking).

Use when you have a complete reasoning chain ready. Reduces N round-trips to 1.

Input:

  • goal: Session goal (required)

  • thoughts: Array of 1-30 thoughts

  • consolidation: Optional {winningPath, summary, verdict}

Validation is atomic - all or nothing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
goalYesSession goal
thoughtsYesArray of thoughts
consolidationNoOptional consolidation
showTreeNoShow ASCII tree (default: false)

Implementation Reference

  • src/index.ts:175-204 (registration)
    Registration of the 'think_batch' MCP tool, including inline handler function that delegates to ThinkingService.submitSession and formats the response.
    server.registerTool('think_batch', { title: 'Think Batch', description: THINK_BATCH_DESCRIPTION, inputSchema: thinkBatchSchema },
      async (args) => {
        try {
          const result = thinkingService.submitSession({
            goal: args.goal as string,
            thoughts: args.thoughts as BurstThought[],
            consolidation: args.consolidation as BurstConsolidation | undefined,
          });
    
          if (result.status === 'rejected') {
            return { content: [{ type: 'text' as const, text: `🚫 REJECTED\n${result.validation.errors.map(e => `• ${e}`).join('\n')}` }], isError: true };
          }
    
          // v5.0.1: Compact output - tree only when requested
          const m = result.metrics;
          const text = [
            '✅ ACCEPTED',
            `🎯 ${args.goal}`,
            `📊 ${result.thoughtsProcessed}t | conf:${m.avgConfidence} ent:${m.avgEntropy} stag:${m.stagnationScore}`,
            result.validation.warnings.length > 0 ? `⚠️ ${result.validation.warnings.join('; ')}` : '',
            result.nudge ? `💡 ${result.nudge}` : '',
            args.showTree ? result.thoughtTree : '',
          ].filter(Boolean).join('\n');
    
          return { content: [{ type: 'text' as const, text }] };
        } catch (error) {
          return { content: [{ type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : 'Unknown'}` }], isError: true };
        }
      }
    );
  • Zod input schema for 'think_batch' tool, defining structure for batch thoughts, extensions, and optional consolidation.
    const burstExtensionSchema = z.object({
      type: z.enum(['critique', 'elaboration', 'correction', 'alternative_scenario', 'assumption_testing', 'innovation', 'optimization', 'polish']),
      content: z.string(),
      impact: z.enum(['low', 'medium', 'high', 'blocker']).optional(),
    });
    
    const burstThoughtSchema = z.object({
      thoughtNumber: z.number().int().min(1),
      thought: z.string().min(1),
      confidence: z.number().min(1).max(10).optional(),
      subSteps: z.array(z.string()).max(5).optional(),
      alternatives: z.array(z.string()).max(5).optional(),
      isRevision: z.boolean().optional(),
      revisesThought: z.number().int().min(1).optional(),
      branchFromThought: z.number().int().min(1).optional(),
      branchId: z.string().optional(),
      extensions: z.array(burstExtensionSchema).optional(),
    });
    
    const thinkBatchSchema = {
      goal: z.string().min(10).describe('Session goal'),
      thoughts: z.array(burstThoughtSchema).min(1).max(30).describe('Array of thoughts'),
      consolidation: z.object({
        winningPath: z.array(z.number().int().min(1)),
        summary: z.string(),
        verdict: z.enum(['ready', 'needs_more_work']),
      }).optional().describe('Optional consolidation'),
      showTree: z.boolean().optional().describe('Show ASCII tree (default: false)'),
    };
  • Core handler logic in ThinkingService.submitSession: validates batch input via BurstService, commits thoughts to session history, handles branches, generates metrics/tree/nudges.
    submitSession(input: SubmitSessionInput): SubmitSessionResult {
      const { goal, thoughts, consolidation } = input;
    
      // Validate using BurstService
      const validation = this.burstService.validate(goal, thoughts, consolidation);
    
      if (!validation.passed || !validation.sortedThoughts) {
        console.error(`🚫 Burst session REJECTED: ${validation.errors.length} errors`);
        return {
          status: 'rejected',
          sessionId: '',
          thoughtsProcessed: 0,
          validation: { passed: false, errors: validation.errors, warnings: validation.warnings },
          metrics: validation.metrics,
          errorMessage: validation.errors.join('; '),
        };
      }
    
      // === Commit Session ===
      this.currentSessionId = new Date().toISOString();
      this.sessionGoal = goal;
      this.reset();
    
      // Convert and add thoughts to history
      for (const t of validation.sortedThoughts) {
        const record = this.burstService.toThoughtRecord(t, thoughts.length, this.currentSessionId);
        this.thoughtHistory.push(record);
        this.lastThoughtNumber = Math.max(this.lastThoughtNumber, t.thoughtNumber);
    
        // Handle branches
        if (t.branchFromThought && t.branchId) {
          const branchHistory = this.branches.get(t.branchId) ?? [];
          branchHistory.push(record);
          this.branches.set(t.branchId, branchHistory);
        }
      }
    
      this.invalidateFuseIndex();
      
      // v5.0.1: Async save - don't block response
      this.saveSession().catch(err => console.error('Failed to save burst session:', err));
    
      // v5.0.1: Minimal system advice - only real issues
      let systemAdvice: string | undefined;
      if (validation.warnings.length > 0) {
        systemAdvice = `⚠️ ${validation.warnings.join('; ')}`;
      }
    
      // v5.0.2: Auto-save insight if consolidation with verdict='ready'
      if (consolidation?.verdict === 'ready') {
        this.insightsService.saveWinningPath({
          path: consolidation.winningPath,
          summary: consolidation.summary,
          goal,
          avgConfidence: validation.metrics.avgConfidence,
          sessionLength: thoughts.length,
        }).catch(err => console.error('Failed to save insight:', err));
        systemAdvice = (systemAdvice ? systemAdvice + ' | ' : '') + '💾 Insight saved';
      }
    
      console.error(`✅ Burst: ${thoughts.length}t, session=${this.currentSessionId.substring(0, 10)}...`);
    
      // v4.6.0: Generate nudge for batch (only if no systemAdvice)
      const hasAlternatives = thoughts.some(t => t.alternatives && t.alternatives.length > 0);
      const hasBlockers = thoughts.some(t => t.extensions?.some(e => e.impact === 'blocker'));
      const nudge = !systemAdvice 
        ? this.nudgeService.generateBatchNudge(
            validation.metrics.avgConfidence,
            thoughts.length,
            hasAlternatives,
            hasBlockers
          )
        : undefined;
    
      return {
        status: 'accepted',
        sessionId: this.currentSessionId,
        thoughtsProcessed: thoughts.length,
        validation: { passed: true, errors: [], warnings: validation.warnings },
        metrics: validation.metrics,
        // v5.0.1: Tree is lazy - generated only when requested via showTree param
        thoughtTree: this.generateAsciiTree(),
        systemAdvice,
        nudge,
      };
    }
  • TypeScript interfaces defining input/output for think_batch (SubmitSessionInput, BurstThought, SubmitSessionResult).
    // BURST_LIMITS moved to burst.service.ts to avoid duplication (v4.2.0)
    
    /** Single thought in a burst session */
    export interface BurstThought {
      thoughtNumber: number;
      thought: string;
      confidence?: number;
      subSteps?: string[];
      alternatives?: string[];
      isRevision?: boolean;
      revisesThought?: number;
      branchFromThought?: number;
      branchId?: string;
      extensions?: QuickExtension[];
    }
    
    /** Consolidation data for burst session */
    export interface BurstConsolidation {
      winningPath: number[];
      summary: string;
      verdict: ConsolidateVerdict;
    }
    
    /** Input for submit_thinking_session tool */
    export interface SubmitSessionInput {
      /** Session goal - required for burst thinking */
      goal: string;
      /** Array of thoughts (1-30) */
      thoughts: BurstThought[];
      /** Optional consolidation if ready */
      consolidation?: BurstConsolidation;
    }
    
    /** Validation metrics for burst session */
    export interface BurstMetrics {
      avgConfidence: number;
      avgEntropy: number;
      avgLength: number;
      stagnationScore: number;
      thoughtCount: number;
    }
    
    /** Validation result for burst session */
    export interface BurstValidation {
      passed: boolean;
      errors: string[];
      warnings: string[];
    }
    
    /** Result from submit_thinking_session tool */
    export interface SubmitSessionResult {
      status: 'accepted' | 'rejected';
      sessionId: string;
      thoughtsProcessed: number;
      validation: BurstValidation;
      metrics: BurstMetrics;
      thoughtTree?: string;
      systemAdvice?: string;
      errorMessage?: string;
      /** Proactive micro-prompt for self-reflection (v4.6.0) */
      nudge?: string;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: the atomic validation ('Validation is atomic - all or nothing'), which is crucial for understanding error handling and data integrity. However, it lacks details on potential side effects, error responses, or performance characteristics like rate limits, leaving some gaps in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured. It uses brief, impactful sentences: 'Submit multiple thoughts at once (Burst Thinking).' 'Use when you have a complete reasoning chain ready.' 'Reduces N round-trips to 1.' Each sentence adds clear value without redundancy, and the information is front-loaded with the core purpose and usage guidelines.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of the tool (4 parameters with nested objects) and no output schema, the description does a good job of covering essential context: purpose, usage guidelines, and key behavioral trait (atomic validation). However, it lacks details on the output format or error handling, which could be important for a batch processing tool with no output schema provided.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema: it mentions the parameters ('goal', 'thoughts', 'consolidation') and notes that validation is atomic, but does not provide additional semantic context or usage examples. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Submit multiple thoughts at once (Burst Thinking).' It specifies the verb ('submit') and resource ('multiple thoughts'), and distinguishes it from sibling tools by emphasizing batch processing versus individual operations like 'think' or 'think_done'. The phrase 'Reduces N round-trips to 1' further clarifies its unique role in efficiency.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: 'Use when you have a complete reasoning chain ready.' This clearly indicates the prerequisite condition for usage. It also implies alternatives by contrasting with sibling tools that handle single thoughts or other operations, helping the agent choose appropriately based on the reasoning state.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GofMan5/think-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server