AI Agents em ProduΓ§Γ£o
LiΓ§Γ΅es do LinkedIn Hiring Assistant, padrΓ΅es de arquitetura, evals e guardrails
Agente em produΓ§Γ£o β POC com ChatGPT. POC funciona em 80% dos casos felizes; produΓ§Γ£o exige 99%+ correto, custo controlado, observabilidade, fallback. As liΓ§Γ΅es abaixo vΓͺm de times que escalaram agentes para milhΓ΅es de usuΓ‘rios (LinkedIn, GitHub Copilot, Anthropic Claude apps).
Componentes de um agente em produΓ§Γ£o
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Agent System β
β β
β ββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββ β
β β Input β β Conversation β β Tools / Functions β β
β β Guardrails β β Memory β β - search_db β β
β β (PII, abuse) β β (short / long) β β - send_email β β
β ββββββββ¬ββββββββ ββββββββββ¬ββββββββ β - update_status β β
β β β ββββββββββ¬ββββββββββββ β
β βΌ βΌ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββ β
β β LLM Orchestrator β β
β β (ReAct loop, tool calling, retry, model routing) β β
β ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β² β β
β β βΌ β
β ββββββββ΄ββββββββ ββββββββββββββββββ ββββββββββββββββββββββ β
β β RAG β β Output β β Action Guardrails β β
β β (vector DB, β β Guardrails β β (permission, conf β β
β β re-rank) β β (schema, fact) β β irmation, sandbox)β β
β ββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββ ββββββββββββββββββ
β Observabilityβ β Eval Pipeline β
β (logs, tracesβ β (offline + β
β cost, qual.)β β in-prod sampleβ
βββββββββββββββ ββββββββββββββββββ
Loop bΓ‘sico ReAct (reasoning + acting)
# Loop ReAct (Reasoning + Acting)
while not_done:
thought = model.generate("Given task X and state S, what next?")
if thought.is_final_answer:
return thought.answer
action = thought.tool_call # qual tool, com quais args
if needs_human_approval(action):
wait_for_user_confirmation()
observation = execute(action) # roda a tool
state.append(thought, action, observation)
if state.iterations > MAX:
raise TooManyIterations # circuit breaker
# Variantes:
# - Plan-then-execute (plan inteiro antes de executar)
# - Tree of thoughts (explora mΓΊltiplos paths)
# - Reflexion (auto-crΓtica entre passos)
DecisΓ΅es de arquitetura
| DecisΓ£o | Trade-off |
|---|---|
| Single agent vs Multi-agent | Single Γ© simples e debugΓ‘vel; multi escala melhor pra tarefas heterogΓͺneas mas Γ© difΓcil de orquestrar e debugar |
| Sync vs Async | Sync Γ© UX simples; async permite tarefas longas (10+ min) mas exige notificaΓ§Γ£o e UX de "trabalhando" |
| Tool use vs RAG | RAG Γ© estΓ‘vel; tools dΓ£o poder mas espaΓ§o de erro maior; combinar Γ© comum |
| Modelo ΓΊnico vs router | Router (Haiku pra tarefa simples, Opus pra raciocΓnio) reduz custo 5-10x; complexidade extra de roteamento |
| MemΓ³ria curta vs longa | Curta cabe no contexto; longa precisa vector store + retrieval; introduz staleness |
| Human-in-the-loop | Para aΓ§Γ΅es irreversΓveis (delete, send email, charge); pausa fluxo mas previne desastre |
Comece simples. Single-agent + ReAct + tools bem desenhados resolve 80% dos casos. Multi-agent, dynamic routing, memory complex sΓ£o otimizaΓ§Γ΅es para depois.
Tipos de tarefa de agente
- Assistente conversacional β ChatGPT-like, multi-turn, baixo risco por aΓ§Γ£o
- Workflow agent β executa tarefa multi-step atΓ© completar (Hiring Assistant LinkedIn)
- Coding agent β modifica cΓ³digo, alta autonomia, sensores como harness (ver pΓ‘gina)
- RPA-like β automatiza aΓ§Γ£o em UI, mais brittle
Quando NΓO usar um agente, e usar workflow determinΓstico?
Se o problema tem soluΓ§Γ£o determinΓstica clara, nΓ£o use LLM. LLM Γ© caro, nΓ£o-determinΓstico, e introduz novos modos de falha. Use agente quando: (a) o input Γ© livre/ambΓguo (linguagem natural, conversa); (b) o caminho de execuΓ§Γ£o varia por contexto; (c) traduΓ§Γ£o semΓ’ntica Γ© necessΓ‘ria (nΓ£o regex). Para fluxos estruturados (workflow BPMN, ETL), use orquestrador tradicional β vai ser mais barato e confiΓ‘vel. Anti-pattern comum: LLM substituindo um
if.