Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

ECS Agent Orchestrator

Long-running agent on ECS Fargate that orchestrates Lambda tools using ReAct pattern with streaming responses.

What This Demonstrates

  • ReAct (Reasoning + Acting) agent pattern implementation
  • ECS Fargate for long-running containerized workloads
  • Lambda function orchestration from ECS
  • Server-Sent Events (SSE) for streaming responses
  • Multi-step reasoning and tool usage loops

Prerequisites

  • AWS ECS cluster or Docker for local development
  • Deployed Lambda AI tool from Example 03
  • Anthropic API key
  • AWS credentials with Lambda invoke permissions

Quick Start

npm install
docker build -t ecs-agent . && docker run -p 3000:3000 ecs-agent
curl -X POST http://localhost:3000/agent/process -d '{"task":"Analyze customer feedback and suggest improvements"}'

How It Works

The agent follows a ReAct loop for complex reasoning and action:

  1. Reasoning: Agent analyzes the current state and decides next action
  2. Acting: Calls appropriate Lambda tools (summarize, classify, extract)
  3. Observing: Processes tool results and updates internal state
  4. Repeating: Continues until task completion or iteration limit
User Request -> ReAct Loop -> Stream Progress -> Final Result
     |              |              |              |
     v              v              v              v
  Parse Task -> Reason/Act -> Lambda Tools -> Synthesize

The agent streams its reasoning process and intermediate results via Server-Sent Events, allowing real-time visibility into multi-step workflows.

Limitations

While this approach handles complex workflows Lambda cannot:

  • Container overhead increases costs vs serverless
  • Always-running resources vs event-driven Lambda
  • Complex scaling decisions vs automatic Lambda scaling
  • Infrastructure management vs managed Lambda runtime

Next Steps

See Example 05 (streaming-chat) for user-facing chat interfaces, or Example 06 (cost-tracking) for monitoring multi-step agent costs.