Skip to main content

Components

The AWS Orchestrator Agent is built on a sophisticated multi-agent architecture. This section documents each specialized component that powers the autonomous Terraform module generation system.


1. Planner Sub-Supervisor Agent

The Planner Sub-Supervisor Agent is the first agent in the AWS Orchestrator pipeline. It acts as the research and planning engine that analyzes user requirements and creates comprehensive execution plans before any code generation begins.

Purpose

Coordinates the planning workflow by orchestrating specialized sub-agents to:

  • Analyze infrastructure requirements from natural language
  • Map requirements to AWS services
  • Create detailed Terraform module execution plans

Architecture

Sub-Agents

AgentPurposeKey Tools
Requirements AnalyzerExtracts infrastructure needs from user inputinfra_requirements_parser_tool, aws_service_discovery_tool, get_final_resource_attributes_tool
Execution PlannerCreates Terraform module structure and execution planscreate_module_structure_plan_tool, create_configuration_optimizations_tool, create_state_management_plans_tool, create_execution_plan_tool

Workflow

Key Features

FeatureDescription
Sequential WorkflowRequirements → Execution Planning → Completion
State ManagementMaintains PlannerSupervisorState with workflow progression
Loop PreventionMaximum 10 iterations with automatic error detection
Custom HandoffsTools for seamless agent transitions (handoff_to_requirements_analyzer, handoff_to_execution_planner)
Completion DetectionAutomatic detection when planning phases complete

State Schema

PlannerSupervisorState {
planning_workflow_state: {
current_phase: "requirements_analysis" | "execution_planning"
requirements_complete: boolean
execution_complete: boolean
planning_complete: boolean
loop_counter: number
}
requirements_data: RequirementsData
execution_data: ExecutionData
planning_results: PlanningResults
}

Output

The Planner Sub-Supervisor returns comprehensive planning results including:

  • Infrastructure Requirements: Parsed service requirements with AWS mappings
  • Module Structure: Planned Terraform module organization
  • Configuration Optimizations: Best practice recommendations
  • Execution Plan: Step-by-step generation instructions

2. Generator Swarm Agent

The Generator Swarm Agent is the second agent in the AWS Orchestrator pipeline. It uses langgraph-swarm to coordinate 7 specialized agents that work together to generate complete Terraform modules with all necessary components.

Purpose

Generates complete Terraform modules through coordinated specialist agents:

  • Create Terraform resources, variables, data sources, locals, outputs
  • Handle complex dependencies between Terraform components
  • Generate backend configuration and documentation
  • Ensure generated code follows Terraform best practices

Architecture

Specialized Agents (7 Total)

AgentPurposeKey Tool
Resource ConfigurationGenerates Terraform resource blocksgenerate_terraform_resources
Variable DefinitionCreates input variable definitionsgenerate_terraform_variables
Data SourceGenerates data source blocksgenerate_terraform_data_sources
Local ValuesCreates computed local valuesgenerate_terraform_local_values
Output DefinitionGenerates output definitionsgenerate_terraform_outputs
Backend GeneratorCreates backend configurationgenerate_terraform_backend
README GeneratorGenerates module documentationgenerate_terraform_readme

Workflow

Dependency Resolution

The swarm uses dependency-aware handoffs to coordinate between agents:

Priority-Based Routing

PriorityLevelAgent TypeBlocking
5CriticalVariables✅ Yes
4HighResources✅ Yes
3MediumLocal Values✅ Yes
2LowData Sources❌ No
1MinimalOutputs❌ No

Key Features

FeatureDescription
Swarm Architecture7 specialized agents with langgraph-swarm coordination
Dependency ResolutionAutomatic discovery and resolution of component dependencies
State IsolationSeparate GeneratorSwarmState with transformation functions
Priority RoutingDependency-aware handoffs with priority levels
Agent Status TrackingTracks each agent: INACTIVE, ACTIVE, WAITING, COMPLETED, ERROR

State Schema

GeneratorSwarmState {
active_agent: string
agent_status_matrix: Record<string, AgentStatus>
dependency_graph: Record<string, string[]>
pending_dependencies: Record<string, Dependency[]>
resolved_dependencies: Record<string, Dependency[]>
agent_workspaces: Record<string, AgentWorkspace>
execution_plan_data: ExecutionPlanData
handoff_queue: HandoffItem[]
}

Generated Module Structure

terraform_module/
├── main.tf # Resource definitions
├── variables.tf # Input variables
├── data.tf # Data sources
├── locals.tf # Local values
├── outputs.tf # Output definitions
├── backend.tf # Backend configuration
└── README.md # Documentation

Output

The Generator Swarm returns a complete Terraform module including:

  • Resource Blocks: AWS resource definitions with best practices
  • Variable Definitions: Typed inputs with validation and defaults
  • Data Sources: External data references
  • Local Values: Computed expressions
  • Outputs: Exposed module values
  • Backend Config: State management configuration
  • README: Comprehensive documentation

3. Writer React Agent

The Writer React Agent is the final executor in the AWS Orchestrator pipeline. It takes the generated Terraform content from the Generator Swarm and writes it to the filesystem as structured Terraform modules.

Purpose

Writes generated Terraform modules to disk through:

  • File writing with LangChain's WriteFileTool
  • Content validation before writing
  • Directory structure creation
  • Comprehensive error handling and recovery
  • Detailed operation tracking and logging

Architecture

Tools

ToolPurposeKey Feature
write_terraform_fileWrite single file to diskState tracking, error handling
batch_write_terraform_filesWrite multiple files efficientlyProgress tracking, batch processing
edit_terraform_fileEdit existing filesBackup creation before edit
create_directoryCreate directory structuresPath validation
validate_terraform_syntaxValidate HCL syntaxKeyword detection, brace matching
list_filesList directory contentsPattern matching
read_fileRead file contentsState tracking
completion_toolMark task completeSummary generation, supervisor handover

Workflow

Data Format Support

The Writer Agent handles multiple generation data formats:

FormatStructureExample Field
Legacygenerated_module.resourcesgenerated_module.resourcesmain.tf
Modernterraform_files[]terraform_files[0].content → file content
Content*_content fieldsmain_contentmain.tf

Key Features

FeatureDescription
React Agent PatternTool-based execution with LangChain's create_react_agent
State InjectionTools receive injected state for context awareness
Operation TrackingTracks each file operation with status and timestamps
Error RecoveryContinues with remaining files if one fails
Batch ProcessingEfficient batch file writing
Completion ReportingDetailed summary with files created

State Schema

WriterReactState {
workspace_path: string
module_name: string
generation_data: GenerationData
files_to_write: FileDescriptor[]
operations: FileOperationRecord[]
status: "pending" | "in_progress" | "completed" | "failed"
errors: ErrorRecord[]
warnings: string[]
completion_status: string
completion_summary: string
completion_files_created: string[]
}

Operation Tracking

Each file operation is tracked with:

FileOperationRecord {
file: FileDescriptor
operation: "create_directory" | "validate_content" | "write_file" | "batch_write"
status: "pending" | "in_progress" | "completed" | "failed"
started_at: datetime
completed_at: datetime
error?: string
result?: string
}

Output

The Writer React Agent produces:

  • Terraform Module on Disk: Complete file structure
  • Operation Log: Detailed record of all file operations
  • Completion Summary: Summary of files created
  • Error Report: Any errors encountered during writing

4. Validation Agent

Documentation coming soon