# Multi-Agent System - Tasks

## Fase 1: Setup do Projeto

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T001 | Criar solution e projetos | - | S |
| T002 | Configurar packages (Semantic Kernel, etc) | T001 | S |
| T003 | Configurar appsettings.json | T001 | S |
| T004 | Criar estrutura de pastas | T001 | S |

## Fase 2: Infrastructure Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T005 | Implementar AzureOpenAIService | T002 | M |
| T006 | Implementar EmbeddingService | T005 | M |
| T007 | Implementar InMemoryVectorStore | T006 | M |
| T008 | Implementar ConversationStore (in-memory) | T002 | M |

## Fase 3: Plugin Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T009 | Criar WebSearchPlugin | T005 | M |
| T010 | Configurar Bing Search API | T009 | S |
| T011 | Criar DocumentPlugin | T007 | M |
| T012 | Criar CalculatorPlugin | T005 | S |
| T013 | Criar DateTimePlugin | T005 | S |

## Fase 4: Agent Layer - Base

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T014 | Criar BaseAgent abstract class | T005 | M |
| T015 | Implementar AgentFactory | T014 | M |
| T016 | Criar AgentContext (DI scope) | T015 | M |

## Fase 5: Agent Layer - Agents

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T017 | Implementar ResearchAgent | T014, T009, T011 | L |
| T018 | Implementar AnalysisAgent | T014, T012 | M |
| T019 | Implementar WritingAgent | T014 | M |
| T020 | Implementar OrchestratorAgent | T017-T019 | L |

## Fase 6: Orchestration Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T021 | Implementar TaskDecomposer | T020 | M |
| T022 | Implementar AgentRouter | T015, T021 | M |
| T023 | Implementar ResultAggregator | T020 | M |
| T024 | Implementar Orchestrator | T021-T023 | L |

## Fase 7: Memory Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T025 | Implementar ConversationMemory | T008 | M |
| T026 | Implementar SemanticMemory | T007 | M |
| T027 | Integrar memória com Orchestrator | T024-T026 | M |

## Fase 8: API Layer

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T028 | Configurar Program.cs base | T001 | M |
| T029 | Criar ChatEndpoints | T024, T027 | M |
| T030 | Implementar streaming (SSE) | T029 | M |
| T031 | Criar AgentEndpoints | T015 | S |
| T032 | Criar HealthEndpoints | T028 | S |
| T033 | Configurar API Key auth | T028 | S |

## Fase 9: Error Handling & Resilience

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T034 | Implementar retry policies | T024 | M |
| T035 | Implementar circuit breaker | T034 | M |
| T036 | Implementar timeout handling | T024 | M |
| T037 | Criar error logging middleware | T028 | S |

## Fase 10: Monitoring & Metrics

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T038 | Implementar token tracking | T005 | M |
| T039 | Implementar usage metrics | T038 | M |
| T040 | Criar cost estimation | T039 | S |
| T041 | Integrar com App Insights | T028 | M |

## Fase 11: Infrastructure (IaC)

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T042 | Criar main.bicep | - | M |
| T043 | Configurar Container App | T042 | M |
| T044 | Configurar Azure OpenAI (manual) | - | M |
| T045 | Configurar Key Vault | T042 | S |
| T046 | Configurar App Insights | T042 | S |

## Fase 12: Testes

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T047 | Criar testes unitários - Plugins | T009-T013 | M |
| T048 | Criar testes unitários - Agents | T017-T020 | M |
| T049 | Criar testes integração - Orchestrator | T024 | L |
| T050 | Criar testes E2E - API | T029-T032 | L |

## Fase 13: Documentação

| ID | Task | Dependências | Estimativa |
|----|------|--------------|------------|
| T051 | Documentar APIs (OpenAPI) | T029-T032 | M |
| T052 | Criar guia de extensibilidade | T014-T020 | M |
| T053 | Criar exemplos de uso | T029 | M |

## Checkpoints

| Checkpoint | Após Tasks | Validação |
|------------|------------|-----------|
| CP1 | T004 | Projeto compila |
| CP2 | T008 | Infrastructure funcionando |
| CP3 | T013 | Plugins funcionando |
| CP4 | T020 | Agents funcionando |
| CP5 | T024 | Orchestrator funcionando |
| CP6 | T027 | Memória integrada |
| CP7 | T033 | API completa |
| CP8 | T037 | Error handling completo |
| CP9 | T041 | Monitoring ativo |
| CP10 | T046 | IaC pronto |
| CP11 | T053 | Projeto completo |

## Legenda

- **S** = Small (< 1h)
- **M** = Medium (1-3h)
- **L** = Large (3-8h)

## Dependências Críticas

```
Azure OpenAI Setup (T044) - BLOQUEANTE para todos os testes reais

T005 (LLM Service) → T014 (BaseAgent) → T017-T020 (Agents) → T024 (Orchestrator)
           ↓
       T006 (Embedding) → T007 (VectorStore) → T011 (DocumentPlugin)
           ↓
       T009 (WebSearch) → T017 (ResearchAgent)
```

## Ordem de Execução Recomendada

### Fase Paralela 1 (Setup)
- T001-T004 (Setup)
- T042 (IaC base)

### Fase Paralela 2 (Foundation)
- T005-T008 (Infrastructure)
- T044 (Azure OpenAI manual)

### Fase Paralela 3 (Building Blocks)
- T009-T013 (Plugins)
- T014-T016 (Agent base)

### Fase Sequencial 4 (Core)
- T017-T020 (Agents)
- T021-T024 (Orchestration)
- T025-T027 (Memory)

### Fase Paralela 5 (API + Supporting)
- T028-T033 (API)
- T034-T037 (Resilience)
- T038-T041 (Monitoring)

### Fase Final
- T043-T046 (IaC complete)
- T047-T053 (Tests + Docs)

---

*MORPH-SPEC by Polymorphism Tech*
