Pular para o conteúdo

Executei 10 agentes do Claude Code durante a noite no Upstash Box

Ver no idioma original →

Autoria: Eric Tech · Assistir no YouTube

Vídeo de autoria do canal indicado, não da IANIA; todos os direitos pertencem ao criador. Transcrição, resumo e tradução gerados automaticamente; o conteúdo no idioma original é preservado na versão em idioma original.

Idioma original: inglês

Vídeo original: I Ran 10 Claude Code Agents Overnight in Upstash Box · Canal: Eric Tech · 09:22 · Assistir no YouTube

Tópicos: Agentes de IA, Automação de tarefas e workflows, Claude Code, Infraestrutura e hardware de IA, Segurança de IA

Eric usa o Upstash Box para executar 10 agentes do Claude Code em paralelo, cada um em um contêiner isolado trabalhando em uma tarefa de um backlog real. Seis agentes concluíram tarefas e deixaram branches prontas; três estouraram o limite de gastos e um fez a alteração sem criar o commit. O vídeo também mostra como pausar e retomar boxes, além dos custos e dos cuidados com segredos e acesso à rede. A conclusão é que o trabalho pode ficar sem supervisão, mas a revisão e o merge não devem ficar.

  • O Upstash Box oferece a cada agente um contêiner na nuvem com arquivos, Git e shell próprios.
  • O autor divide um backlog em 10 tarefas e executa cada uma em um box separado.
  • Uma snapshot de um box já configurado permite criar os demais sem repetir a instalação das dependências.
  • Seis agentes concluíram tarefas e criaram branches; três excederam o limite de gastos e um não fez o commit.
  • Testes que já falhavam na branch principal confundiram alguns agentes e fizeram com que revertessem as próprias alterações.
  • Boxes podem ser pausados e retomados com arquivos, dependências e alterações preservados.
  • O custo de computação dos boxes foi baixo, mas o uso de tokens cobrado pela Anthropic foi a despesa maior.
  • Segredos dentro de um box ficam acessíveis ao agente; o vídeo recomenda usar attach headers e restringir a rede com políticas.
Início Capítulo Resumo
00:00 O problema e a proposta do Upstash Box O vídeo apresenta a limitação de executar um agente por vez no laptop e propõe boxes na nuvem para trabalhar em paralelo.
02:07 Criando o orquestrador e testando um agente Claude Code escreve um orquestrador com base na documentação, e o autor valida o fluxo com uma tarefa de limitação de requisições.
03:40 Dez agentes trabalhando durante a noite O autor usa uma snapshot para iniciar 10 boxes e, pela manhã, avalia os resultados, os erros e os limites de gastos.
06:16 Retomada dos boxes e custos O vídeo demonstra como pausar e retomar um box e explica que o uso de tokens custa mais que a computação dos boxes.
07:49 Limitações, segurança e para quem serve O autor aborda runtimes, proteção de segredos e acesso à rede, e conclui que a abordagem é útil quando o gargalo é a capacidade de acompanhar tarefas.

Os ventiladores do meu laptop não estão girando. — 04:12

Você pode deixar o trabalho sem supervisão. Não pode deixar o merge sem supervisão. — 06:16

A cobrança é pelo uso ativo da CPU, não pelo tempo de relógio. — 07:17

Seu trabalho deixa de depender de a máquina ficar aberta e passa a ser algo que você coloca na fila e acompanha. — 08:52

  • Upstash Box (ferramenta): Serviço que fornece contêineres isolados na nuvem com um agente de IA integrado.
  • Claude Code (ferramenta): Ferramenta de programação usada no vídeo como agente para trabalhar nas tarefas do backlog.
  • Upstash (empresa): Empresa responsável pelo Upstash Box, usado para executar os agentes em contêineres na nuvem.
  • Anthropic (empresa): Empresa cobrada separadamente pelo uso de tokens dos agentes.
  • Docker (ferramenta): O vídeo menciona que ainda não é possível fornecer um Dockerfile próprio para configurar os runtimes.
  • npm (ferramenta): Gerenciador de pacotes usado para instalar dependências e executar testes no projeto.
  • snapshot (conceito): Captura de um box configurado que pode servir de base para criar outros boxes com o ambiente já preparado.
  • attach headers (conceito): Recurso citado para associar segredos a domínios sem expô-los dentro do contêiner.
  • política de rede (conceito): Configuração que restringe os domínios que um box pode acessar.

00:00 Se você está usando o Claude Code agora, está executando um agent no seu laptop, em um terminal, em um repo, uma tarefa por vez, [música] e, no segundo em que fecha a tampa, tudo para. Isso é tranquilo para um bug, mas, quando você tem um backlog de verdade esperando, aquela única sessão vira um gargalo. Então, neste vídeo, vamos resolver isso com o Upstash Box. O Upstash Box permite dar um computador aos seus AI agents. Assim, em vez de pegar emprestada a sua máquina, o [música] agent ganha sua própria máquina na nuvem, com seus próprios arquivos, seu próprio git e seu próprio shell. E o que estamos construindo com isso é basicamente uma

00:31 fábrica de software. Tenho aqui um app SaaS de verdade com um backlog de coisas que estão realmente quebradas. E vamos entregar esse backlog a 10 agents do Claude Code. [música] Cada um em seu próprio box, trabalhando durante a noite enquanto meu laptop fica fechado. Então, vamos primeiro às docs do Upstash Box, porque isso funciona de um jeito um pouco diferente das ferramentas de sandbox que você provavelmente já viu. Cada Upstash Box é um contêiner seguro e isolado na nuvem, com um AI agent integrado. E essa última parte é o que importa. Na maioria das ferramentas de sandbox, o agent roda do seu lado, e o sandbox é apenas um lugar para executar código. Aqui, o

01:02 agent vive dentro do box. Você dá um prompt para ele, e ele executa os próprios comandos, edita os próprios arquivos e roda os próprios testes exatamente onde está o código. Então, aqui você pode ver que um box recebe um runtime, git e um shell de verdade. E aqui embaixo estão os estados do ciclo de vida: em execução, pausado e snapshots. Vamos usar os três. Certo. Este é o app. Login, banco de dados, usuários, dashboard. Construído rapidamente, do jeito que a maioria de nós constrói coisas hoje. Então, ele tem uma lista bem familiar de problemas, e ela está neste arquivo aqui. Este é o backlog.md, em inglês simples. Item um,

01:35 o endpoint de login não tem limitação de taxa. Item dois: o dashboard carrega todas as linhas, sem paginação. Item três: a navegação mobile não fecha depois que você toca em um link. Item quatro: uma consulta N+1 na lista de usuários. E vai até dez. Agora, uma regra importante quando você trabalha em paralelo: cada item deve mexer em uma parte diferente do app. São 10 agents em 10 boxes, e eles não conseguem ver uns aos outros. Então, se dois deles editarem o mesmo arquivo, você fica com duas branches que entram em conflito na hora do merge. Certo, agora precisamos de algo que leia esse arquivo e crie os boxes. E não vou escrever isso à mão.

02:07 Vou pedir ao Claude Code que escreva isso usando as próprias docs do Upstash como fonte. Então, aqui está o Claude Code rodando localmente. E passo a ele o link das docs e digo o que quero. Leia o guia de início rápido do Upstash Box. Depois, escreva um orquestrador que leia backlog.md e, para cada item, crie um box com o agent do Claude Code, clone meu repo nele e passe o item como tarefa para esse agent. E aqui está a primeira versão. Olha só. Está errada. Está inventando nomes de métodos que não existem. Então, executamos e recebemos este erro. Isso é muito comum quando você aponta um agent para um SDK novinho. Então, a solução é ser específico. Abra a página de início rápido real e siga a API que está nela. E agora, a segunda versão.

02:38 Aqui, ele está instalando o SDK, lendo backlog.md e dividindo-o em itens. E esta é a parte importante: Box.create. E, dentro dela, definimos o runtime e configuramos o agent como Claude Code. Esse bloco é o que coloca um agent do Claude Code dentro do contêiner. E uma observação rápida sobre chaves: as minhas estão em um arquivo .env, que vou manter fora da tela. Faça o mesmo. Agora, antes de irmos para 10, vamos executar um, porque é sempre bom ver um funcionando primeiro. Então,

03:08 este é apenas o item um, o bug de limitação de taxa. Aqui está o box sendo criado, e recebemos um ID de box. Agora, observe. Essa é a saída do agent, transmitida diretamente do contêiner. Clonando o repo, executando npm install, abrindo a rota /, lendo o middleware. Nada disso está acontecendo na minha máquina. E, alguns minutos depois, pronto. Limitação de taxa na rota de login. Um teste para isso. Teste aprovado. Commit feito em uma branch. Todo esse ciclo aconteceu dentro de um contêiner na nuvem. Certo, agora vem a parte divertida. Vamos fazer a mesma coisa em grande escala. Não

03:40 uma sessão do Claude Code no seu laptop, mas 10 agents trabalhando nos seus repos ao mesmo tempo, cada um em seu próprio box. Então, percorremos os 10 itens do backlog, criamos um box para cada um e executamos todos de uma vez. Uma coisa que vale a pena fazer antes: clonar e executar npm install leva alguns minutos, e você não quer pagar por isso 10 vezes. Então, configurei um box, clonei o repo e instalei as dependências, criei um snapshot e, em seguida, criei os outros nove a partir desse snapshot. E lá vamos nós. 10 boxes divididos em painéis, para você ver todos ao mesmo tempo. E esta é a parte que quero que você

04:12 perceba. As ventoinhas do meu laptop não estão girando. 10 agents do Claude Code a todo vapor, e minha máquina não está fazendo nada. Agora, é aqui que isso fica realmente útil, porque os agents vivem nos boxes, não no meu laptop. Não preciso ficar aqui olhando para isso. Então, são 11 da noite. Os 10 agents estão trabalhando, e vou fechar meu laptop e dormir. E isso não é truque. Os boxes continuam rodando. Não há uma sessão na minha máquina que possa ser perdida. Certo, chegou a manhã seguinte. Vamos ver o que temos. Seis dos 10 terminaram sem problemas e enviaram uma branch.

04:43 Paginação no dashboard, estados de erro e de vazio, o README, exportação em PDF, expiração do token de redefinição de senha e o bug de fuso horário do resumo diário. Seis branches esperando por mim, e duas delas merecem destaque. Antes de criar qualquer coisa, o orquestrador executou a suíte de testes uma vez e mostrou o estado inicial. E este repo já tinha dois testes falhando na main: o do resumo e o da redefinição de senha. Pela manhã, os dois estavam passando, corrigidos por dois agents diferentes em dois boxes diferentes que nunca se comunicaram.

05:13 Agora, as falhas — e elas são mais interessantes do que os sucessos. Três agents atingiram o limite de gastos e morreram no meio da tarefa. Defini um limite de US$ 3 por agent, então 10 agents dão US$ 30 no pior caso. E a limitação de taxa, a consulta N+1 e o script de seed consumiram todo o limite. E, quando você lê os logs, é sempre a mesma falha. O agent faz a alteração, executa npm test, vê aqueles dois testes que já falhavam, decide que talvez a culpa seja dele, reverte o próprio trabalho, executa os testes de novo, fica confuso e tenta outra vez. Gastou US$ 3 discutindo consigo mesmo

05:45 sobre testes que nunca foi solicitado a alterar. Depois, a navegação mobile deu certo. Fez a correção. Disse: “Agora vou fazer o commit da alteração”. E então, não fez commit nenhum. Então, há um box ali com a alteração certa na árvore de trabalho e uma branch vazia. E depois tem este aqui, que é o que você precisa ver: a exportação em PDF. Ele decidiu usar um pacote chamado fast PDF, adicionou-o ao package.json, executou a instalação, e o npm não conseguiu encontrá-lo. Mas depois percebeu o erro, trocou para JSPDF e entregou uma exportação funcional, tudo em uma única branch.

06:16 Ele alucinou, se recuperou, e o único motivo de eu saber que tudo isso aconteceu é que li o log. Então, seis terminaram sem problemas, um chegou a fazer o commit e três gastaram todo o orçamento até morrer. E essa é a resposta real para a pergunta: posso deixar isso sem supervisão? Você pode deixar o trabalho sem supervisão. Não pode deixar o merge sem supervisão. Agora, não quero descartar os três que ficaram sem orçamento. E também não quero pagar para eles ficarem parados ali, girando. Então, existe a opção de pausar. Você congela um box a qualquer momento e continua dias ou até semanas depois, com

06:46 retomada perfeita. Então, vou pausar este aqui. E, no console, você pode ver o status mudar de em execução para pausado. Agora, observe. Vou retomá-lo, listar a pasta e abrir o arquivo em que estava trabalhando. O repo está lá, node_modules está lá. As alterações parcialmente concluídas estão lá. E a branch continua selecionada. Nada foi reconstruído. Então, você pode começar algo na segunda-feira, congelar o ambiente e voltar exatamente ao mesmo ambiente quando quiser. Certo, vamos falar de dinheiro, porque sei que essa é a pergunta. O Upstash Box cobra de você

07:17 por CPU ativa, não pelo tempo de relógio. Então, quando uma box fica pausada, você não paga pela computação, só um pequeno valor pelo armazenamento. Isso importa aqui porque os agents passam boa parte do tempo ociosos. Então, aqui está a conta: 10 boxes, e custou apenas cerca de um centavo. Mas isso é só pelas boxes. Você paga à Anthropic separadamente pelos tokens que esses agents consumiram. E esse foi o valor maior. Então, a infraestrutura para executar 10 agents durante a noite é barata. O que você realmente precisa acompanhar é o uso do modelo. Certo, há três coisas que podem causar problemas, e prefiro que vocês ouçam isso de mim. Primeiro, ainda não dá para usar seu próprio

07:49 Dockerfile. Você escolhe entre os ambientes de execução que eles oferecem: Node, Python, Go e assim por diante. Então, se seu app precisar de algum pacote de sistema incomum, você o instala em uma etapa de configuração ou faz como eu fiz: instala uma vez e cria um snapshot. Ambientes de execução personalizados estão no roteiro. Segundo, e este é o ponto importante, as variáveis de ambiente dentro de uma box ficam visíveis para tudo que está nela, inclusive para o agent. Então, se você colocar um token do GitHub lá, o agent poderá lê-lo. E, se você o passar dentro de um comando de shell, esse comando pode acabar nos logs. A documentação explica isso. Há um

08:21 recurso chamado attach headers, em que você associa o segredo a um domínio e o injeta na saída. Assim, ele nunca chega ao contêiner. Use esse recurso. E, terceiro, por padrão, uma box pode acessar toda a internet, o que também significa que um agent que sair dos trilhos pode acessar qualquer coisa. Você pode restringir isso com uma política de rede e permitir apenas os domínios de que precisa. E eu faço isso antes de executar qualquer coisa sem supervisão. Então, para quem isso realmente serve? Se você executa um agent por vez e está satisfeito assim, não precisa disso. Claude Code no seu laptop dá conta. Isso começa a fazer

08:52 sentido quando você se torna o gargalo. Uma fila de tarefas que nunca anda, alguns projetos ao mesmo tempo ou simplesmente a vontade de deixar o trabalho acontecendo enquanto você dorme. E o que realmente me surpreendeu aqui não foram os 10 agents, foi fechar o laptop. Seu trabalho deixa de depender de a sua máquina ficar ligada e passa a ser algo que você coloca na fila e verifica depois. Não é mágica. Vocês viram as falhas. Três deles gastaram todo o orçamento andando em círculos. Mas seis correções reais esperando em branches pela manhã, por alguns dólares. É uma boa troca. Então, se você quiser experimentar isso por conta própria,

09:22 pode começar em upstash.com/box ou simplesmente clicar no link na descrição abaixo. E é isso para este vídeo. Se você achou útil, curta o vídeo e considere se inscrever no canal. E me conte nos comentários o que você colocaria no seu próprio arquivo de fila de tarefas. Dito isso, vejo vocês no próximo.

Transcrição original

[00:00] If you’re using cloud code right now, you’re running one agent on your laptop, one terminal, one repo, one task at a time, [music] and the second you close the lid, everything stops, which is fine for one bug, but when you have a real backlog sitting there, that one session is the bottleneck. So, in this video, we’re going to fix that with Upstbox. Upstbox lets you give your AI agents a computer. So, instead of borrowing your machine, the [music] agent gets its own machine in the cloud with its own files, its own git, and its own shell. And what we’re building with it is basically a

[00:31] software factory. I’ve got a real SAS app here with a backlog of things genuinely broken in it. And we’re handing that backlog to 10 cloud code agents. [music] Each one in its own box running overnight while my laptop is closed. So let’s head over to the Upstashbox docs first because this works a little differently from the sandbox tools you’ve probably seen. Every Upstash box is a secure isolated cloud container with an AI agent built in. And that last part is what matters. With most sandbox tools, the agent runs on your side and the sandbox is just somewhere to execute code. Here, the

[01:02] agent lives inside the box. You give it a prompt and it runs its own commands, edits its own files, runs its own tests right where the code is. So here you can see a box gets a runtime, git, and a real shell. And down here is the life cycle running, paused, and snapshots. We’re going to use all three. All right. So this is the app. Login, a database, users, a dashboard. build fast the way most of us build things now. So it has a very familiar list of problems and that’s this file right here. This is backlog.md just plain English. Item one,

[01:35] the login endpoint has no rate limiting. Item two, the dashboard loads every row, no pageionation. Item three, the mobile nav doesn’t close after you tap a link. Item four, an N plus1 query on the users list and it goes down to 10. Now one rule that matters once you go parallel, each item should touch a different part of the app. These are 10 agents in 10 boxes and they can’t see each other. So if two of them edit the same file, you get two branches that fight when you merge. Okay, so now we need something that reads that file and spawns the boxes. And I’m not writing that by hand.

[02:07] I’m going to have Claude code write it using Upstash’s own docs as the source. So here’s Claude code running locally. And I give it the docs link and tell it what I want. Read the Upstash box quickart. Then write an orchestrator that reads backlog.mmd and for each item creates a box with the cloud code agent. clones my repo in and hands that agent the item as its task. And here’s the first pass. And look at this. It’s wrong. It’s guessing at method names that don’t exist. So, we run it and get this error. Very normal when you point an agent at a brand new SDK. So, the fix is to be specific. Pull the actual quick

[02:38] start page and follow the API on it. And now the second pass. So, here it’s installing the SDK, reading backlog.md splitting it into items. And this is the important part. Box.create. And inside it, we set the runtime and we set the agent to claude code. That block is what puts a clawed code agent inside the container. And quick note on keys, mine are in av file that I’m keeping off screen. Please do the same. Now, before we go to 10, let’s run one because you always want to see one work first. So,

[03:08] this is just item one, the rate limiting bug. Here’s the box being created, and we get a box ID back. Now, watch. That’s the agent streaming straight out of the container. Cloning the repo, running npm install, opening the O route, reading the middleware. None of that is on my machine. And a couple of minutes later, there it is. Rate limiting on the login route. A test for it. Test passing. Committed to a branch. That whole loop happened inside a container in the cloud. Okay, so now the fun part. Let’s take that same thing and go wide. Not

[03:40] one cloud code session on your laptop, but 10 agents working on your repos at the same time, each in its own box. So, we’re mapping over the 10 backlog items, creating a box for each one, and running them all at once. One thing worth doing first, cloning and running npm install takes a couple of minutes, and you don’t want to pay for that 10 times. So, I set up one box, clone and install, snapshot it, then create the other nine from that snapshot. And here we go. 10 boxes split across panes so you can see them all at once. And this is the part I want you to

[04:12] notice. My laptop fans are not spinning. 10 claw code agents at full speed and my machine is doing nothing. Now, here’s where it gets genuinely useful because the agents live in the boxes and not on my laptop. I don’t have to sit here and watch this. So, it’s 11 p.m. All 10 agents are working and I’m closing my laptop and going to sleep. And that’s not a trick. The boxes keep running. There’s no session on my machine to lose. Okay, so it’s the morning after. Let’s see what we got. Six of the 10 came back clean and pushed a branch.

[04:43] Pageionation on the dashboard, error and empty states, the readme, PDF export, password reset token expiry, and the daily digest time zone bug. Six branches sitting there waiting on me, and two of those are worth pointing at. Before it spawned anything, the orchestrator ran the test suite once and printed a baseline. And this repo already had two failing tests on main. The digest one and the password reset one. In the morning, both of those are green, fixed by two different agents in two different boxes that never talked to each other.

[05:13] Now, the failures, and they’re more interesting than the wins. Three agents hit their spending cap and died mid task. I’d set a $3 limit per agent, so 10 agents is $30 worst case. And rate limiting, the N plus1 query, and the seed script all burned through it. And when you read the logs, it’s the same failure every time. The agent makes its change, runs npm test, sees those two pre-existing failures, decides they might be its fault, reverts its own work, reruns, gets confused, tries again. It spent $3 arguing with itself

[05:45] about tests it was never asked to touch. Then the mobile nav won. It made the fix. It said, “I will now commit the change.” And then no commit. So there’s a box sitting there with the right change in the working tree and an empty branch. And then there’s this one, and this is the one you need to see. PDF export. It decided to use a package called fast PDF, added it to package.json, ran install, and npm couldn’t find it. But then it caught itself, swapped in JSPDF, and shipped a working export, which is the whole thing

[06:16] in one branch. It hallucinated, it recovered, and the only reason I know any of that happened is that I read the log. So, six clean, one that goes to the commit, three that spent themselves to death. And that’s the real answer to can I leave this unwatched. You can leave the work unwatched. You cannot leave the merge unwatched. Now, those three that ran out of budget, I don’t want to throw them away. And I don’t want to pay for them to sit there spinning either. So, this is pause. Freeze a box anytime and continue days or even weeks later with

[06:46] perfect resumability. So, I’ll pause this one. And over in the console, you can see the status flip from running to paused. And now watch this. I resume it, list the folder, open the file I was working on. The repos there, node modules is there. The half-finish changes are there. And the branch is still checked out. Nothing was rebuilt. So you can start something on a Monday, freeze it, and pick that exact environment back up whenever. Okay, let’s talk about money because I know that’s the question. Upsbox bills you

[07:17] for active CPU, not wall clock time. So when a box is paused, you’re not paying for compute, just a small amount for storage, which matters here because agents spend a lot of their life idle. So here’s the bill, 10 boxes, and it was only about a cent. But that’s just the boxes. You’re paying Anthropic separately for the tokens those agents burned. And that was the bigger number. So the infrastructure for running 10 agents overnight is cheap. The model usage is what you actually watch. All right, three things that will bite you because I’d rather you hear them from me. First, you can’t bring your own

[07:49] Docker file yet. You pick from the runtimes they give you, Node, Python, Go, and so on. So, if your app needs some weird system package, you install it in a setup step or do what I did, install it once and snapshot it. Custom runtimes are on the road map. Second, and this is the important one, environment variables inside a box are visible to everything in that box, including the agent. So if you drop a GitHub token in there, the agent can read it. And if you pass it inside a shell command, that command can end up in logs. The docs cover this. There’s a

[08:21] feature called attach headers where you map the secret to a domain and upst it on the way out. So it never touches the container. Use that. And third, by default, a box can reach the whole internet, which also means an agent that goes off the rails can reach anything. You can lock that down with a network policy and only allow the domains you need. And I do that before running anything unattended. So who is this actually for? If you’re running one agent at a time and you’re happy with that, you don’t need this. Cloud code on your laptop is fine. This starts to make

[08:52] sense the moment the bottleneck is you. A backlog that never moves, a few projects at once, or you just want work happening while you’re asleep. And the thing that actually surprised me here wasn’t the 10 agents, it was closing my laptop. Your work stops being tied to your machine staying open and becomes something you queue up and check on. It’s not magic. You saw the failures. Three of them spent their whole budget going in circles. But six real fixes waiting on branches in the morning for a couple of dollars. That’s a good trade. So, if you want to try this yourself,

[09:22] you can get started at upstash.com/box or just click the link in the description below. And that’s about it for this video. If you found this helpful, please make sure to like this video and consider subscribing. and let me know in the comments what you’d put in your own backlog file. And with that being said, I’ll see you in the next one.