Voltar aos PodcastsClaude
Lance seu primeiro Managed Agent
All right.
Muito bem.
Hello everyone.
Olá a todos.
It's great to see you all here today for our session on shipping your first manage agent.
É ótimo ver vocês aqui hoje para nossa sessão sobre como lançar seu primeiro Managed Agent.
Let's go ahead and get started.
Vamos em frente e começar.
My name is Isabella He.
Meu nome é Isabella He.
I'm a member of technical staff at Anthropic on the Applied AI team.
Sou membro do corpo técnico da Anthropic, no time de Applied AI.
The Applied AI team at Anthropic sits at the intersection of products, research, and our customers, which means that I get to contribute internally to products at Anthropic like Claude code and our Claude harnesses, as well as work externally with our customers that are building on top of Claude and on top of our harnesses.
O time de Applied AI da Anthropic está na interseção de produtos, pesquisa e nossos clientes, o que significa que contribuo internamente para produtos da Anthropic como o Claude Code e nossos harnesses do Claude, além de trabalhar externamente com clientes que constroem em cima do Claude e dos nossos harnesses.
So, my goal today is to get you all hands-on with actually building on top of manage agents, understanding how the harness works under the hood, and getting you ready to actually ship your first incident response management.
Meu objetivo hoje é que todos vocês coloquem a mão na massa para construir em cima do Managed Agents, entendam como o harness funciona internamente e se preparem para realmente lançar seu primeiro gerenciador de resposta a incidentes.
So, the quick overview of today's agenda.
Um panorama rápido da agenda de hoje.
We're going to cover first a quick refresher of Claude manage agents.
Vamos cobrir primeiro uma revisão rápida do Claude Managed Agents.
I want to talk you through a little bit about how this harness works under the hood and what makes it so special.
Quero explicar um pouco sobre como esse harness funciona internamente e o que o torna tão especial.
Our team put a lot of thought into the architectural design of Claude manage agents to make sure that it runs ready and reliably for production-ready agents.
Nosso time pensou muito no design arquitetural do Claude Managed Agents para garantir que ele rode de forma confiável e pronto para produção.
So, I want to talk you through a little bit of how that works so that then when we transition to the second portion here, which is the hands-on workshop, you'll actually understand what each of the primitives you're building actually mean for your agents under the hood.
Quero explicar um pouco sobre como isso funciona, para que, quando formos para a segunda parte, o workshop prático, vocês entendam o que cada primitiva que estão construindo significa para seus agentes internamente.
So, for the majority of today's session, I want you all to actually have your laptops open, building alongside me, actually working inside of a repository, and getting you ready to actually spin up a working incident response agent.
Durante a maior parte da sessão de hoje, quero que todos vocês abram seus notebooks, construam junto comigo, trabalhem dentro de um repositório e se preparem para subir um agente de resposta a incidentes funcionando.
Lastly, we'll talk a little bit about beyond the basics.
Por fim, vamos falar um pouco sobre o que vai além do básico.
Today's session is the first session of a couple of other ones that will build on top of this on Claude manage agents.
A sessão de hoje é a primeira de uma série de outras que vão se construir sobre o Claude Managed Agents.
Specifically, right after this one, I think there's another session on dreaming, which is one of my favorite new features with Claude manage agents for self-improving agents and memory built into the harness.
Especificamente, logo após esta, acho que há outra sessão sobre dreaming, que é um dos meus novos recursos favoritos do Claude Managed Agents para agentes que aprendem sozinhos e para memória integrada ao harness.
So, encourage everyone to dive in a little bit deeper into what else is in the box after we set you all up for success today with a quick introduction.
Então, encorajo a todos a mergulharem um pouco mais fundo no que mais está disponível depois que os prepararmos com uma introdução rápida hoje.
So, let's first touch a little bit about how we got here with Claude manage agents.
Vamos primeiro falar um pouco sobre como chegamos aqui com o Claude Managed Agents.
When we first released the very first Claude back in 2023, we released a messages API alongside access to Claude.
Quando lançamos o primeiro Claude em 2023, lançamos junto a Messages API para acesso ao Claude.
This provided raw model access to all Claude models.
Isso forneceu acesso direto ao modelo para todos os modelos Claude.
This became the very first way that people could programmatically build on top of Claude and essentially gave a way for people to access tokens in and tokens out via our Claude models.
Essa foi a primeira forma que as pessoas tinham de construir programaticamente em cima do Claude e essencialmente abriu um caminho para acessar tokens de entrada e saída via nossos modelos Claude.
This also meant that for everyone building on top of Claude models, they had to implement all the various primitives themselves.
Isso também significava que todos que construíam em cima dos modelos Claude tinham que implementar todas as diversas primitivas por conta própria.
Things like context management, the actual agent loop, compaction, etc.
Coisas como gerenciamento de contexto, o próprio loop do agente, compaction e assim por diante.
All the primitives that come alongside making the agent work.
Todas as primitivas necessárias para fazer o agente funcionar.
When models were less intelligent back in the early days of let's say 2023, some of these primitives were much simpler because agents could simply do less.
Quando os modelos eram menos inteligentes nos primeiros dias, digamos em 2023, algumas dessas primitivas eram muito mais simples porque os agentes simplesmente podiam fazer menos.
But, as we evolved into now with higher model intelligence and as agents are able to take on more complex tasks and actually take actions within environments and come to actually do entire tasks for humans, the primitives that come alongside context management and managing an agent's ability to execute API calls and tool calls becomes much more complex.
Mas, à medida que evoluímos para modelos com maior inteligência e os agentes conseguem assumir tarefas mais complexas, realizar ações dentro de ambientes e de fato executar tarefas inteiras por humanos, as primitivas de gerenciamento de contexto e controle da capacidade do agente de executar chamadas de API e chamadas de ferramentas se tornam muito mais complexas.
So, that's when we moved to the agent SDK, which became a harness that allows you to programmatically call Claude code, one of our agents at Anthropic.
Foi aí que migramos para o Agent SDK, que se tornou um harness para chamar programaticamente o Claude Code, um dos nossos agentes na Anthropic.
So, Claude code is something that an agent has access to a computer and takes actions within file system.
O Claude Code é um agente que tem acesso a um computador e toma ações dentro de um sistema de arquivos.
So, the agent SDK became a way for you to make Claude much more powerful by leveraging the power of Claude code within a harness.
O Agent SDK se tornou uma forma de tornar o Claude muito mais poderoso aproveitando o poder do Claude Code dentro de um harness.
The main thing here though is that with the agent SDK, developers still had to manage hosting and scaling on their own and making sure that the agent SDK would be safe to run within their containers.
O principal ponto aqui é que com o Agent SDK, os desenvolvedores ainda precisavam gerenciar hospedagem e escalabilidade por conta própria e garantir que o Agent SDK fosse seguro para rodar dentro de seus contêineres.
That's only then evolved into Claude managed agents, which is the first harness to be able to handle scaling and production ready components for you by Anthropic, providing things like a purpose-built harness, sandboxing, observability, tool runtime, all within a managed infrastructure system.
Isso só então evoluiu para o Claude Managed Agents, que é o primeiro harness capaz de lidar com escalabilidade e componentes prontos para produção por você, oferecido pela Anthropic, com coisas como um harness criado especificamente, sandboxing, observabilidade e runtime de ferramentas, tudo dentro de um sistema de infraestrutura gerenciada.
This means that developers can focus on task and agent configuration, custom tool logic, the things that actually matter for bringing domain expertise and customizability to your agents, where you're handing off the rest of all the primitives and core compute and primitives of essentially managing the basics of agent running to Anthropic.
Isso significa que os desenvolvedores podem se concentrar na configuração de tarefas e agentes, na lógica de ferramentas customizadas, nas coisas que realmente importam para trazer expertise de domínio e personalização aos seus agentes, transferindo todo o resto, todas as primitivas e a computação básica de gerenciamento do agente, para a Anthropic.
So, that brings me to managed agents as the fastest way to build production ready agents on Claude.
Isso me leva ao Managed Agents como a forma mais rápida de construir agentes prontos para produção no Claude.
We've seen people build 10 to 15 times faster to production with Claude managed agents by leveraging our purpose-built harness.
Vimos pessoas construírem de 10 a 15 vezes mais rápido para produção com o Claude Managed Agents aproveitando nosso harness criado especificamente.
Part of the reason why we built Claude managed agents is because is because harnesses should evolve alongside your agents.
Parte do motivo pelo qual construímos o Claude Managed Agents é que os harnesses devem evoluir junto com seus agentes.
For example, back when we were building ourselves on top of models like Sonnet 4.5, we noticed that Sonnet 4.5 emitted a particular behavior called context anxiety.
Por exemplo, quando estávamos construindo em cima de modelos como o Sonnet 4.5, notamos que o Sonnet 4.5 exibia um comportamento específico chamado context anxiety.
This meant that with Sonnet 4.5, Claude started wrapping up tasks early even when it still had room to spare in its context window.
Isso significava que com o Sonnet 4.5, o Claude começava a encerrar tarefas cedo, mesmo quando ainda tinha espaço sobrando na sua janela de contexto.
To manage that in our harness, we then added some mitigations to combat against this early stopping behavior.
Para gerenciar isso no nosso harness, adicionamos algumas mitigações para combater esse comportamento de parada antecipada.
But, when Opus 4.5 then came out, we actually saw this behavior go away, making all that work we had done inside of the harness essentially obsolete because Claude had evolved beyond that behavior that we had built into the harness to manage.
Mas, quando o Opus 4.5 saiu, vimos esse comportamento desaparecer, tornando todo o trabalho que tínhamos feito dentro do harness essencialmente obsoleto, porque o Claude havia evoluído além daquele comportamento que havíamos construído no harness para gerenciar.
So, the takeaway there is that it's a lot of work to maintain harnesses and make sure that they actually evolve alongside your agents, which is why with Claude managed agents, we want to make it really easy for Claude and Anthropic to handle all the complexities that come with compaction, caching, things like context anxiety, all these various primitives that come with actually making agent production ready and getting the most out of Claude.
A conclusão aqui é que dá muito trabalho manter harnesses e garantir que eles realmente evoluam junto com seus agentes, por isso com o Claude Managed Agents, queremos facilitar ao máximo para que o Claude e a Anthropic lidem com todas as complexidades de compaction, caching, coisas como context anxiety, todas essas diversas primitivas que vêm com o trabalho de tornar o agente pronto para produção e de extrair o máximo do Claude.
So again, you can focus on the tasks, tools, and things that actually matter for building agents on Claude.
Assim, você pode se concentrar nas tarefas, ferramentas e coisas que realmente importam para construir agentes no Claude.
So three primary resources go into building on Claude managed agents.
Três recursos principais são necessários para construir no Claude Managed Agents.
First is the agent's endpoint, which is the persona and capabilities.
O primeiro é o endpoint do agente, que define a persona e as capacidades.
This is the core system prompt that powers your agent.
É o system prompt principal que alimenta seu agente.
Essentially here, you're defining the model, the MCP servers, the skills, the various components that your agent can actually leverage when it's able to run in that agent loop.
Aqui você define o modelo, os servidores MCP, as habilidades e os diversos componentes que seu agente pode aproveitar quando está rodando no loop do agente.
The next is the environments.
O próximo são os ambientes.
You can think of this as the hands of the agent, where the previous one is the brain of the agent where the agent is thinking through what to execute, and then it's using an environment to actually have a space and a container to actually take action on your behalf.
Você pode pensar nisso como as mãos do agente, onde o anterior é o cérebro do agente onde ele raciocina sobre o que executar, e então usa um ambiente para ter um espaço e um contêiner para agir em seu nome.
Sessions are next the way to tie together agents and environments.
As sessões são a próxima forma de conectar agentes e ambientes.
A single session has a spun up on an agent instance within an environment.
Uma única sessão sobe uma instância do agente dentro de um ambiente.
So you can connect the two together and actually stream events back to your user and start to take action on behalf of your humans as part of a Claude powered agent.
Você conecta os dois e consegue transmitir eventos de volta para o seu usuário e começar a tomar ações em nome dos seus usuários como parte de um agente alimentado pelo Claude.
A key thing here, as I alluded to briefly before, Claude managed agent has the agent loop run server side.
Um ponto importante, como mencionei brevemente antes, é que no Claude Managed Agents, o loop do agente roda no lado do servidor.
This means that a lot of the complexities that come with managing hosting and scaling are abstracted away.
Isso significa que grande parte das complexidades de gerenciamento de hospedagem e escalabilidade é abstraída.
And when you close your laptop or you hit hard refresh on your agent that you're building on Claude managed agents, everything is maintained and you don't have to worry about durability, reliability, all these various aspects that usually come to bite you when you're trying to turn your agent from a prototype into production.
Quando você fecha o notebook ou dá um hard refresh no agente que está construindo no Claude Managed Agents, tudo é mantido e você não precisa se preocupar com durabilidade, confiabilidade e todos esses aspectos que costumam te pegar quando você tenta transformar seu agente de protótipo em produção.
And lastly here, before we dive into the hands-on portion, is I want to talk you through a key design decision that went into Claude managed agents.
Por fim, antes de mergulharmos na parte prática, quero explicar uma decisão de design fundamental que foi para o Claude Managed Agents.
Previously, with a lot of agent harnesses, we saw the agent loop coupled tightly with tool execution.
Anteriormente, com muitos harnesses de agentes, vimos o loop do agente acoplado firmemente à execução de ferramentas.
This design pattern made sense and still makes sense for some agents because you want to give the agent powerful abilities to actually take action within the environment.
Esse padrão de design fazia sentido e ainda faz para alguns agentes, porque você quer dar ao agente capacidades poderosas para realmente agir dentro do ambiente.
For instance, with Claude Code, we want the agent to be able to access various files on your computer, take action within a file system, and therefore it makes sense for the agent to have access to all those tools spun up on every container.
Por exemplo, com o Claude Code, queremos que o agente possa acessar diversos arquivos no seu computador, tomar ações dentro de um sistema de arquivos, e por isso faz sentido que o agente tenha acesso a todas essas ferramentas rodando em cada contêiner.
But, we also realized there are some constraints for this, especially with some agents where you essentially want to be able to decouple the hands from the brains of the agents.
Mas percebemos que há algumas limitações para isso, especialmente com alguns agentes onde você essencialmente quer desacoplar as mãos do cérebro dos agentes.
For instance, credentials and uh credentials and security became a huge concern.
Por exemplo, credenciais e segurança se tornaram uma grande preocupação.
With the ability to have the agent access your file system, you can actually add very distinct sandboxing by decoupling these two components, where the agent is no longer able to access the actual credentials without encryption by decoupling the hands from the sandbox of the agent.
Com a capacidade de dar ao agente acesso ao seu sistema de arquivos, você consegue adicionar um sandboxing muito específico ao desacoplar esses dois componentes, onde o agente não tem mais acesso às credenciais reais sem criptografia, ao desacoplar as mãos do sandbox do agente.
The other aspect here is actually you can see huge benefits by doing these decoupling on things like time to first token and latency.
O outro aspecto aqui é que você pode ver grandes benefícios ao fazer esse desacoplamento em coisas como time to first token e latência.
Previously, with the agent loop into execution in the same box, you had to spin up containers for every single session that you're spinning up in the agent, which contributed to additional latency from a time to first time to first token perspective.
Anteriormente, com o loop do agente e a execução dentro da mesma caixa, você precisava subir contêineres para cada sessão que iniciava no agente, o que contribuía para latência adicional do ponto de vista do time to first token.
But, with this now decoupled, our teams actually saw reductions in time to first token along the lines of over 90% reduction in TTFT for our P95 metrics on latency.
Mas, com esse desacoplamento, nossos times viram reduções no time to first token da ordem de mais de 90% de redução no TTFT para nossas métricas de P95 de latência.
So, here you can start to see the power of this design decision coming through from the perspective of safety, reliability, latency, and everything else that you care about when it comes to building production-ready agents.
Aqui você começa a ver o poder dessa decisão de design a partir de perspectivas de segurança, confiabilidade, latência e tudo mais que você se importa ao construir agentes prontos para produção.
All right, so now it's time for the exciting part of today's session, which is where I want you all to open up your laptops and go to this URL here to actually clone a repository, and let's start to actually feel the magic of everything that I just talked through.
Agora é hora da parte mais emocionante da sessão de hoje, onde quero que todos abram seus notebooks e acessem essa URL aqui para clonar um repositório e começar a sentir a mágica de tudo o que acabei de explicar.
So, I'm going to give everyone a second to just go over to that URL there and just spin up the repository that we have ready for you.
Vou dar um segundo para todos acessarem essa URL e subirem o repositório que preparamos para vocês.
All right, so here are some additional commands that I want you all to run to make sure this is all set up on your computers.
Aqui estão alguns comandos adicionais que quero que todos rodem para garantir que tudo esteja configurado nos seus computadores.
So, the first step many of you might have done already, but just take that repository, hit the URL, get clone it, and then I want you to CD into the specific repository for the session, which is ship your first manage agent.
O primeiro passo, muitos de vocês já podem ter feito, mas peguem esse repositório, acessem a URL, façam o clone e então entrem no repositório específico da sessão, que é o ship your first manage agent.
And then, if you're on Mac, you'll see those two commands on the side, the Python and the source.
Se você estiver no Mac, verá esses dois comandos ao lado, o Python e o source.
Um, there's a command there for Windows as well.
Tem um comando para Windows também.
And you'll just do the rest there where you want to install the requirements, copy over the environment key into your .env file.
Depois é só fazer o restante, onde você instala os requisitos e copia a chave de ambiente para seu arquivo .env.
Um, here you'll put in the Anthropic API key that hopefully all of you also received from the QR code for free credits earlier.
Aqui você coloca a chave de API da Anthropic que todos vocês receberam, espero, pelo QR code para créditos gratuitos antes.
And lastly, we'll just run the app.
Por último, vamos só rodar o app.
All right, let's go ahead and dive in, but as I mentioned before, let me just show everyone where these instructions are.
Vamos em frente, mas como mencionei antes, deixa eu mostrar a todos onde estão essas instruções.
If you go into the repository in the link and then go to ship your first manage agents, you scroll down on the read me, you'll see all the setup instructions here.
Se você acessar o repositório pelo link e depois ir em ship your first manage agents, rolar o README para baixo, verá todas as instruções de configuração aqui.
So, feel free to do this, um, as we go along or even in your own time later today and continue playing around with it, but as I mentioned before, everything will be also shown on the screen to follow along with.
Fique à vontade para fazer isso enquanto avançamos ou mesmo no seu próprio tempo depois, e continuar brincando com isso, mas como mencionei antes, tudo será mostrado na tela para acompanhar.
So, do not worry if you did not have time to fully get it set up on your laptop.
Não se preocupe se não teve tempo de configurar completamente no seu notebook.
Without further ado, let's go ahead and dive in.
Sem mais delongas, vamos em frente.
So, once you run streamlit run app.py, you should be able to see a URL that looks like this and a page that looks like this.
Uma vez que você rodar streamlit run app.py, deve conseguir ver uma URL e uma página parecidas com essa.
What we're doing here is we're going to be simulating an agent, um, interaction here where we have an incident that's going to come up.
O que vamos fazer aqui é simular uma interação com um agente onde um incidente vai surgir.
A lot of you who might be software engineers in the room will be intimately familiar with the pain that comes alongside incident response.
Muitos de vocês que são engenheiros de software aqui vão estar bem familiarizados com a dor que acompanha a resposta a incidentes.
If you are software engineer, you might be woken up at, let's say, 3:00 a.m. in the morning, 2:00 a.m. in the morning when you're out around on on vacation as you're on call, and this is usually a very painful portion of a software engineer's life, uh, because when you're on call, it means that if a server goes down or a service goes down, you have to be immediately the one there to respond and tackle the incident.
Se você é engenheiro de software, talvez seja acordado às 3 da manhã, às 2 da manhã, enquanto está de férias quando está de plantão, e isso costuma ser uma parte muito dolorosa da vida de um engenheiro de software, porque quando você está de plantão, significa que se um servidor cair ou um serviço cair, você tem que ser imediatamente o responsável a responder e lidar com o incidente.
Usually for a human, this means diving into metrics and logs and deployments.
Para um humano, isso geralmente significa mergulhar em métricas, logs e deploys.
You can actually investigate what's going on.
Você consegue investigar o que está acontecendo.
And so, what we're going to do is we're going to now have an agent run on Claude manage agents to do all this for us.
O que vamos fazer é ter um agente rodando no Claude Managed Agents para fazer tudo isso por nós.
So, that when we get woken up by 3:00 a.m., we can hand it off to an agent, or maybe we don't even get woken up at all if Claude is able to do everything for us.
Assim, quando formos acordados às 3 da manhã, podemos passar para um agente, ou talvez nem sejamos acordados se o Claude conseguir fazer tudo por nós.
Okay.
Ok.
So, let's now go ahead and dive into the code here.
Vamos em frente e mergulhar no código aqui.
What we're going to open up here is we have the agent.py file on the left and the agent complete on the right.
O que vamos abrir aqui é o arquivo agent.py do lado esquerdo e o agent complete do lado direito.
If you want to challenge yourself, you can of course try to implement everything yourself here or with Claude.
Se quiser se desafiar, você pode tentar implementar tudo sozinho aqui ou com o Claude.
Um but, what we're going to do just for simplicity's sake is just copy over various elements from the completed file onto the incomplete file one by one.
Mas o que vamos fazer, por simplicidade, é apenas copiar os diversos elementos do arquivo completo para o arquivo incompleto, um por um.
So, you can see how these primitives compose our agent one piece at a time.
Assim, você pode ver como essas primitivas compõem o nosso agente, peça por peça.
So, let's go ahead and start off with this very first part, which is the agent.
Vamos começar com essa primeira parte, que é o agente.
We mentioned before that the agent is the one that defines the persona and the capabilities of the agent here.
Como mencionamos antes, o agente é quem define a persona e as capacidades do agente aqui.
So, that's model, the system prompts, and the tools in our case for our agent here.
Então, é o modelo, os system prompts e as ferramentas, no nosso caso, para o nosso agente aqui.
So, let me go ahead and copy over what we see there on the screen.
Vou copiar o que vemos na tela.
And you can see here that we're defining the SRE agent.
Você pode ver aqui que estamos definindo o SRE agent.
We're going to use Claude Opus 4.7 here.
Vamos usar o Claude Opus 4.7 aqui.
And I've preconfigured a system prompt and tools for the agent.
Pré-configurei um system prompt e ferramentas para o agente.