<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Serhii Antonuik</title>
    <description>The latest articles on DEV Community by Serhii Antonuik (@uagents8).</description>
    <link>https://dev.to/uagents8</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4235170%2F3aea2576-a4b2-43d5-8895-e120ed73c925.jpg</url>
      <title>DEV Community: Serhii Antonuik</title>
      <link>https://dev.to/uagents8</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uagents8"/>
    <language>en</language>
    <item>
      <title>Why Hosting an AI Agent Isn't the Same as Hosting a Website</title>
      <dc:creator>Serhii Antonuik</dc:creator>
      <pubDate>Mon, 23 Nov 2026 11:16:57 +0000</pubDate>
      <link>https://dev.to/uagents8/why-hosting-an-ai-agent-isnt-the-same-as-hosting-a-website-21hd</link>
      <guid>https://dev.to/uagents8/why-hosting-an-ai-agent-isnt-the-same-as-hosting-a-website-21hd</guid>
      <description>&lt;h2&gt;
  
  
  The 20-minute agent that needs a server running 24/7
&lt;/h2&gt;

&lt;p&gt;A data engineer wants to ship an AI agent that checks a pipeline every morning, patches a broken dependency, and goes back to sleep. Writing the agent logic itself: &lt;strong&gt;an afternoon of work&lt;/strong&gt;. Everything around it, on a classic cloud, is &lt;strong&gt;the part that eats the week&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That gap — between &lt;em&gt;"I have an agent"&lt;/em&gt; and &lt;em&gt;"it's running safely in production"&lt;/em&gt; — is where most of the pain lives, and it's rarely discussed when people compare hosting options by price or region.&lt;/p&gt;

&lt;h3&gt;
  
  
  A day in the life of a 20-minute agent
&lt;/h3&gt;

&lt;p&gt;On a classic VM, the bill and the risk surface run for all &lt;strong&gt;24 hours&lt;/strong&gt;, whether or not the agent is doing anything; on &lt;strong&gt;uagents8&lt;/strong&gt;, there's simply nothing running the other &lt;strong&gt;23 hours and 40 minutes&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The classic path: provisioning before you write a line of agent code
&lt;/h2&gt;

&lt;p&gt;On DigitalOcean, AWS, or GCP, an agent is just another workload — so it inherits every step a long-running service needs, even though it only runs for 20 minutes a day:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Provision an instance or droplet:&lt;/strong&gt; pick a size, pick a region, wait for it to boot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lock down SSH access&lt;/strong&gt;, configure a firewall, and plan for key rotation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Issue and renew a TLS certificate&lt;/strong&gt; (Let's Encrypt or a paid cert) and point DNS at it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create IAM roles, API tokens, and secrets&lt;/strong&gt; — and a place to store them that isn't a &lt;code&gt;.env&lt;/code&gt; file in git.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stand up a load balancer&lt;/strong&gt;, configure health checks, and set up path-based routing if the agent exposes more than one endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build the runtime:&lt;/strong&gt; install OS packages, the language runtime, and every dependency the agent needs — then keep that image patched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wire up a scheduler&lt;/strong&gt; (&lt;code&gt;cron&lt;/code&gt;, a managed scheduler, or your own) to trigger the 20-minute run — and keep the instance it runs on powered on and billed 24 hours a day, because a classic VM has nowhere to "go" between runs.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;None of this is agent logic.&lt;/strong&gt; It's the toll for being allowed to deploy any code at all — and most of it has to be maintained indefinitely, not just set up once.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The uagents8 path: the same outcome, minus the toll
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://uagents8.com" rel="noopener noreferrer"&gt;uagents8&lt;/a&gt; is built for exactly this shape of workload — short, frequent, agent-sized bursts of work — so the steps above collapse:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Point uagents8 at your repo&lt;/strong&gt;, or push your agent's code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Declare what it needs to run&lt;/strong&gt; — not what box it runs on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It runs on the schedule you set&lt;/strong&gt;, and scales to zero the moment it's done.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;TLS, routing, secrets storage, and the runtime environment are the platform's job, not yours. There's no step where you provision, patch, or pay for a server sitting idle between runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step by step, side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;What it actually involves&lt;/th&gt;
&lt;th&gt;Classic cloud (DO / AWS / GCP)&lt;/th&gt;
&lt;th&gt;uagents8&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Compute&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Getting a machine to run code on&lt;/td&gt;
&lt;td&gt;Provision, size, and patch an instance or droplet&lt;/td&gt;
&lt;td&gt;Handled by the platform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Network &amp;amp; TLS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Making the endpoint reachable and secure&lt;/td&gt;
&lt;td&gt;DNS, certificates, renewal, firewall rules&lt;/td&gt;
&lt;td&gt;Built in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Identity &amp;amp; secrets&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Giving the agent credentials safely&lt;/td&gt;
&lt;td&gt;IAM roles, token rotation, a secrets manager&lt;/td&gt;
&lt;td&gt;Built in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Routing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Exposing more than one endpoint&lt;/td&gt;
&lt;td&gt;Load balancer + path-based routing rules&lt;/td&gt;
&lt;td&gt;Built in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Runtime&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Having the right packages and dependencies available&lt;/td&gt;
&lt;td&gt;Build and maintain a runtime image&lt;/td&gt;
&lt;td&gt;Declare dependencies; the platform builds it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scheduling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Running a short job on a timer&lt;/td&gt;
&lt;td&gt;A scheduler, plus an always-on host to run it on&lt;/td&gt;
&lt;td&gt;Native scheduled runs, scales to zero&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Expertise required&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;DevOps / SRE-level, maintained indefinitely&lt;/td&gt;
&lt;td&gt;None beyond writing the agent&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What this looks like in minutes
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0i575xf32wnznd90k5jf.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0i575xf32wnznd90k5jf.jpeg" alt="Setup time comparison in minutes: Classic Cloud (~180 min) vs uagents8 (~2 min)" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add it up and the classic path costs roughly &lt;strong&gt;three hours of setup&lt;/strong&gt; before the agent runs once; on &lt;strong&gt;uagents8&lt;/strong&gt;, it's a &lt;strong&gt;couple of minutes&lt;/strong&gt;, mostly spent describing what the agent needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same outcome, different number of moving parts
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2bv7n7j2clvoioovixvw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2bv7n7j2clvoioovixvw.jpeg" alt="Architecture comparison: 6+ moving parts on Classic Cloud versus 1 push on uagents8" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The classic stack is &lt;strong&gt;six things&lt;/strong&gt; to provision, secure, and keep patched; &lt;strong&gt;uagents8&lt;/strong&gt; is &lt;strong&gt;one push&lt;/strong&gt; that already includes all six.&lt;/p&gt;

&lt;h2&gt;
  
  
  Different workloads need different infrastructure
&lt;/h2&gt;

&lt;p&gt;None of this means DigitalOcean, AWS, or GCP are bad — they're excellent at what they're built for: long-running services with steady traffic. An AI agent that works for 20 minutes and then has nothing to do has a different load shape, and infrastructure built for always-on services carries always-on setup and always-on cost, whether the agent is actually running or not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://uagents8.com" rel="noopener noreferrer"&gt;uagents8&lt;/a&gt; is built for the agent's shape of work, not the server's: short bursts, frequent triggers, and nothing to pay for in between.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Note: All time and setup estimates in this article are illustrative — intended to reflect real-world workflow differences rather than a formal benchmark.)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cloudcomputing</category>
      <category>devops</category>
      <category>agents</category>
    </item>
    <item>
      <title>Deploy a LangGraph agent to a public URL</title>
      <dc:creator>Serhii Antonuik</dc:creator>
      <pubDate>Thu, 19 Nov 2026 08:03:56 +0000</pubDate>
      <link>https://dev.to/uagents8/deploy-a-langgraph-agent-to-a-public-url-1odc</link>
      <guid>https://dev.to/uagents8/deploy-a-langgraph-agent-to-a-public-url-1odc</guid>
      <description>&lt;p&gt;You have a LangGraph graph that works in a notebook. Now someone else needs to call it: a teammate, a Telegram bot, a CRM that posts a question and waits for an answer. That means a web API, a server that stays up, pinned dependencies, a secret for your model key, and a URL that not everyone on the internet can spend your model budget through.&lt;/p&gt;

&lt;p&gt;This walkthrough takes a small LangGraph agent from a folder on your laptop to a public HTTPS address on uagents8, then locks that address with a token. In our run on 28 October 2026 the agent was live 78 seconds after we created it; the build took about 38 of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we're deploying
&lt;/h2&gt;

&lt;p&gt;One graph, two nodes, one branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;START --(the question is arithmetic)--&amp;gt; calculate --&amp;gt; END
START --(anything else)--------------&amp;gt; respond   --&amp;gt; END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;calculate&lt;/code&gt; is a tool node in plain Python. &lt;code&gt;respond&lt;/code&gt; is where your model goes; until you add one, it answers with a labelled stub, so the whole thing runs with no key and no network. The graph sits behind FastAPI with one route that matters, &lt;code&gt;POST /ask&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;typing&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;TypedDict&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uvicorn&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langgraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;graph&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;START&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;StateGraph&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;TypedDict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;  &lt;span class="c1"&gt;# "tool", "stub" or "model"&lt;/span&gt;


&lt;span class="n"&gt;_OPERATORS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Sub&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Mult&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mul&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Div&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;truediv&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;AST&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Evaluate + - * / and parentheses on numbers; anything else raises ValueError."""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Expression&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;_evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Constant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;UnaryOp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;USub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nf"&gt;_evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;operand&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BinOp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_OPERATORS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;_OPERATORS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;_evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;_evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"unsupported expression"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_arithmetic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""The expression inside `question`, if the whole question is just arithmetic."""&lt;/span&gt;
    &lt;span class="n"&gt;expression&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeprefix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"what is"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"?= "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isdigit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"0123456789+-*/(). "&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"calculate"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;_arithmetic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"question"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"respond"&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;expression&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_arithmetic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"question"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"eval"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ArithmeticError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"answer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"I could not calculate {expression!r}."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"answer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{expression} = {result:g}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;respond&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Your model call goes here. The key comes from the environment, never from this file.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"answer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"[stub] You asked: {state['question']}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"stub"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;StateGraph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"calculate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"respond"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;respond&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_conditional_edges&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;START&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"calculate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"calculate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"respond"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"respond"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"calculate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"respond"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;END&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;graph&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Ask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="nd"&gt;@app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/ask"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Ask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"question"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"answer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"question"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"answer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"answer"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;uvicorn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"PORT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"8000"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;_arithmetic&lt;/code&gt; and &lt;code&gt;_evaluate&lt;/code&gt; accept &lt;code&gt;+ - * /&lt;/code&gt; and parentheses on numbers and nothing else, so user input never reaches &lt;code&gt;eval&lt;/code&gt;. A malformed expression gets a polite answer, not a crash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three things the platform needs from your code
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Listen on &lt;code&gt;PORT&lt;/code&gt;, on &lt;code&gt;0.0.0.0&lt;/code&gt;.&lt;/strong&gt; The last two lines do it. The platform sets &lt;code&gt;PORT&lt;/code&gt;; a server bound to &lt;code&gt;127.0.0.1&lt;/code&gt; runs fine and can never be reached.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Start listening before anything slow.&lt;/strong&gt; The health check only asks whether the port accepts connections. It requests no route, so an API with only &lt;code&gt;/ask&lt;/code&gt; is fine. It gives the port about 150 seconds to open. Load big models or indexes after the server is up, or lazily on the first request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Pin every dependency.&lt;/strong&gt; The build runs Python 3.12 with no compiler, so pick versions that ship wheels. In a clean virtual environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install fastapi uvicorn langgraph
pip freeze &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sample pins &lt;code&gt;fastapi==0.143.3&lt;/code&gt;, &lt;code&gt;uvicorn==0.54.0&lt;/code&gt; and &lt;code&gt;langgraph==1.2.16&lt;/code&gt;. &lt;code&gt;main.py&lt;/code&gt; and &lt;code&gt;requirements.txt&lt;/code&gt; sit at the top level, and the platform runs &lt;code&gt;python main.py&lt;/code&gt;. There is no build file to write: the platform works out the build from your code, and if your project already has its own build file at the top level, it uses that as written.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy it
&lt;/h2&gt;

&lt;p&gt;Push the folder to a GitHub, GitLab or Bitbucket repository, or zip &lt;code&gt;main.py&lt;/code&gt; and &lt;code&gt;requirements.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In the dashboard, press &lt;strong&gt;+ Deploy Agent&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Source:&lt;/strong&gt; pick your Git provider and the repository. Every push to the branch redeploys. Or pick &lt;strong&gt;Code Archive&lt;/strong&gt; and upload the zip.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configure:&lt;/strong&gt; keep &lt;strong&gt;Continuous Service&lt;/strong&gt; and choose a &lt;strong&gt;Resource size&lt;/strong&gt;. Sizes are memory limits: T is 256 MB, S 512 MB, L 1 GB. In our run this agent used about 80 MB, so T is enough.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Confirm&lt;/strong&gt;, then &lt;strong&gt;Deploy agent&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmipcebzpjk4exth515lg.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmipcebzpjk4exth515lg.webp" alt="The Configure step of the deploy wizard with the three resource sizes, T, S and L, highlighted" width="800" height="1134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The status screen moves from &lt;strong&gt;Building agent&lt;/strong&gt; to &lt;strong&gt;Starting your agent&lt;/strong&gt; to &lt;strong&gt;Running&lt;/strong&gt;. Ours took 78 seconds, uploaded as a zip, with no model key. The agent's page then shows its public URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F36omvugzh4miu0awtqv6.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F36omvugzh4miu0awtqv6.webp" alt="The page of a running agent on the demo account, with its Running status and the Open agent button highlighted" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Call it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST https://&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-agent-url&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/ask \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"question": "what is 2+3*4?"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"question"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"what is 2+3*4?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"answer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2+3*4 = 14"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ask it anything else and you get the stub, with &lt;code&gt;"mode": "stub"&lt;/code&gt;. That's your sign that the branch to the model is wired and waiting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add your model
&lt;/h2&gt;

&lt;p&gt;Put your provider's client library in &lt;code&gt;requirements.txt&lt;/code&gt; (pinned) and replace the body of &lt;code&gt;respond()&lt;/code&gt; with the call. Then add the key in the agent's &lt;strong&gt;Settings → Environment Variables&lt;/strong&gt;, with &lt;strong&gt;Sensitive&lt;/strong&gt; switched on, and redeploy. A changed variable is picked up on the next deploy. The key never goes into the code or the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Close the door: an access token
&lt;/h2&gt;

&lt;p&gt;Here is the part most tutorials skip. Your agent now has a public URL, and behind it sits a model you pay for per token. Anyone who finds the URL can spend your budget.&lt;/p&gt;

&lt;p&gt;Open the agent's &lt;strong&gt;Settings&lt;/strong&gt; tab, find &lt;strong&gt;Access tokens&lt;/strong&gt; and choose &lt;strong&gt;Generate agent token&lt;/strong&gt;. Give it a name you'll recognise (&lt;code&gt;crm&lt;/code&gt;, &lt;code&gt;telegram-bot&lt;/code&gt;) and pick how long it stays valid: 7, 30 or 90 days, or no expiry. Copy it. It starts with &lt;code&gt;uagt_live_&lt;/code&gt; and is shown only once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmmim1l2pm30mxxni53zy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmmim1l2pm30mxxni53zy.png" alt="The Generate agent token dialog: a name for the caller and how long the token stays valid" width="800" height="543"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST https://&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-agent-url&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/ask \
  -H &lt;span class="s2"&gt;"Authorization: Bearer uagt_live_..."&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"question": "what is 6*7?"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A call without a valid token gets &lt;code&gt;401 Unauthorized&lt;/code&gt; before it reaches your code or your model. Once an agent has its first token, every caller needs one, so give your existing callers theirs before you generate it. One token per caller means you can revoke a leaked one without breaking the others.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdlq1fkuri80cy3rfddcm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdlq1fkuri80cy3rfddcm.png" alt="The Access tokens card of an agent with two active tokens, one per caller, each with its own Revoke button" width="800" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When the deploy fails
&lt;/h2&gt;

&lt;p&gt;It will, sooner or later: a package you installed locally and never pinned, a variable you renamed in one file and not the other, a server bound to localhost. The failed agent's page explains the error in plain language. If you press &lt;strong&gt;Fix with AI&lt;/strong&gt;, it reads the error and your code, patches a copy, checks the patch before building it, and deploys the fixed copy as a new version. If that copy fails too, it makes one more attempt. Your repository is never changed, and you can restore the previous version in one click.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it costs
&lt;/h2&gt;

&lt;p&gt;Size T runs on every plan, from Builder at €19 a month (prices before VAT). Monthly plans start with a 14-day free trial of every feature. A card is required to prevent abuse, and nothing is charged unless you choose a plan to continue with. For the launch, &lt;strong&gt;LAUNCH30&lt;/strong&gt; takes 30% off the first three months on Builder or Growth, monthly billing, until 30 November; with the trial, the discount starts with your first payment, after the trial. Code from your laptop to a token-protected URL, in Europe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it:&lt;/strong&gt; &lt;a href="https://uagents8.com/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=launch-2026-11&amp;amp;utm_content=devto-langgraph-article" rel="noopener noreferrer"&gt;https://uagents8.com/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=launch-2026-11&amp;amp;utm_content=devto-langgraph-article&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>langchain</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Your AI agent's public URL is an open wallet</title>
      <dc:creator>Serhii Antonuik</dc:creator>
      <pubDate>Mon, 16 Nov 2026 12:31:10 +0000</pubDate>
      <link>https://dev.to/uagents8/your-ai-agents-public-url-is-an-open-wallet-196d</link>
      <guid>https://dev.to/uagents8/your-ai-agents-public-url-is-an-open-wallet-196d</guid>
      <description>&lt;p&gt;You build an agent that answers questions, summarises documents or triages tickets. A Telegram bot, a CRM or a webhook has to call it, so it gets a public HTTPS URL. Behind that URL sits a paid model.&lt;/p&gt;

&lt;p&gt;The URL is not a secret. It ends up in config files, logs, screenshots and chat threads. Anyone who has it can call your agent, and every call that reaches your code can spend your model budget. Nothing goes down and nothing looks wrong; the bill just grows. Call it denial of wallet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three ways people lock it down
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Write the check into every agent.&lt;/strong&gt; Read a header, compare it with a secret, return 401. It works, and it is yours to write, test and keep correct in every agent you ever deploy. One forgotten route leaves one agent open. Changing the shared secret means redeploying every caller at once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Put a proxy or gateway in front.&lt;/strong&gt; A reverse proxy with basic auth, an OAuth proxy, an API gateway. One place to enforce the rule, but also one more service to deploy, patch and pay for, and often one shared credential for everyone who calls through it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Refuse the call at the edge.&lt;/strong&gt; The platform checks a token before the request reaches your agent. There is no code in the agent and no extra service. This is what we built, and the rest of this post shows how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  How per-agent tokens work
&lt;/h2&gt;

&lt;p&gt;Each agent gets its own access tokens. They belong to one agent and open only that agent's public URL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the agent, go to &lt;strong&gt;Settings&lt;/strong&gt; and find &lt;strong&gt;Access tokens&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Generate agent token&lt;/strong&gt;, name it after the caller (&lt;code&gt;telegram-bot&lt;/code&gt;) and pick how long it stays valid: 7, 30 or 90 days, or no expiry.&lt;/li&gt;
&lt;li&gt;Copy the token. It starts with &lt;code&gt;uagt_live_&lt;/code&gt; and is shown once; we keep only a fingerprint of it.&lt;/li&gt;
&lt;li&gt;Give it to that one caller. The caller sends it in the &lt;code&gt;Authorization&lt;/code&gt; header.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmmim1l2pm30mxxni53zy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmmim1l2pm30mxxni53zy.png" alt="The Generate agent token dialog: a name for the caller and how long the token stays valid" width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A request without a valid token for this agent gets &lt;code&gt;401 Unauthorized&lt;/code&gt; and never reaches your code or your model. A token made for another agent, a revoked or expired token, and your account's API key are all refused the same way.&lt;/p&gt;

&lt;p&gt;Because every caller has its own token, you can revoke one without touching the others. Revoke the Telegram bot's token and your CRM keeps working. If a token leaks, it opens that one agent only, and revoking it takes effect right away. An agent can hold up to 10 active tokens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdlq1fkuri80cy3rfddcm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdlq1fkuri80cy3rfddcm.png" alt="The Access tokens card of an agent with two active tokens, one per caller, each with its own Revoke button" width="800" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two things to know. From the first token on, the agent stays closed: letting your last token expire does not reopen it, so a forgotten expiry date never exposes the agent by accident. And give existing callers their token before you generate the first one on a live agent, or they will start getting &lt;code&gt;401&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5h3fxgxrlo7ae23ihwzq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5h3fxgxrlo7ae23ihwzq.png" alt="Caller, edge check, agent: with the agent's token the call goes through; without a valid one it gets 401 at the edge" width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Calling an agent with its token
&lt;/h2&gt;

&lt;p&gt;The URL and the &lt;code&gt;/ask&lt;/code&gt; route below are placeholders for your own agent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# No token: refused at the edge&lt;/span&gt;
curl -s -o /dev/null -w &lt;span class="s2"&gt;"%{http_code}\n"&lt;/span&gt; -X POST \
  https://agent-my-bot-12345.uagents8.io/ask
&lt;span class="c"&gt;# 401&lt;/span&gt;

&lt;span class="c"&gt;# With the token made for this agent&lt;/span&gt;
curl -s -o /dev/null -w &lt;span class="s2"&gt;"%{http_code}\n"&lt;/span&gt; -X POST \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $AGENT_TOKEN"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"question": "Summarise the open tickets"}'&lt;/span&gt; \
  https://agent-my-bot-12345.uagents8.io/ask
&lt;span class="c"&gt;# 200&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="no"&gt;AGENT_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://agent-my-bot-12345.uagents8.io"&lt;/span&gt;
&lt;span class="no"&gt;AGENT_TOKEN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"AGENT_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# keep it in an environment variable&lt;/span&gt;

&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{AGENT_URL}/ask"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {AGENT_TOKEN}"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"question"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Summarise the open tickets"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Token missing, expired or revoked for this agent"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your agent checks nothing itself. It only receives requests that already passed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two layers: an address list and a token
&lt;/h2&gt;

&lt;p&gt;A token proves the caller knows a secret. An address list proves where the call comes from. On the Scale plan you can use both on the same agent.&lt;/p&gt;

&lt;p&gt;Turn on &lt;strong&gt;Restrict access by IP address&lt;/strong&gt; in the agent's configuration and give it up to 10 IPv4 addresses or ranges (for example your office and one client's servers). Today the switch is in the dashboard and the list itself is set through the API. Then generate a token for each caller, as above.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frnrbooy1jwae2ktpf8wo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frnrbooy1jwae2ktpf8wo.png" alt="The agent's configuration with the Restrict access by IP address switch turned on" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now a call has to pass two independent checks before it reaches your code: it must come from a listed address, and it must carry a valid token for this agent.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A token that leaks into a log or a screenshot is useless from any other network: the call gets &lt;code&gt;403&lt;/code&gt;, even with the valid token.&lt;/li&gt;
&lt;li&gt;A machine inside the listed network still gets &lt;code&gt;401&lt;/code&gt; without a token.&lt;/li&gt;
&lt;li&gt;Both checks run at the edge, so a refused call spends none of your model budget.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tokens are on every plan; the address list is on Scale. For most agents a token per caller is the right first step, and the address list is the second one when the callers sit behind fixed addresses.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to add more layers
&lt;/h2&gt;

&lt;p&gt;Tokens answer "who may call this agent?". Other controls answer different questions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A private agent has no public URL at all.&lt;/strong&gt; If only your other agents call it (an internal worker, a tool behind a front agent), make it private. They reach it by name, and nothing outside the platform can. It needs no token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A request-rate limit applies to each agent.&lt;/strong&gt; The default is 120 requests a minute, and you can set it between 10 and 1,000. A caller over the limit gets &lt;code&gt;429&lt;/code&gt; and can try again a minute later. It puts a ceiling on how fast anyone can drive calls into an agent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The address list on Scale&lt;/strong&gt;, described above, when a fixed set of addresses is the real boundary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A sensible default for a production agent that a service calls: one token per caller, plus the rate limit. Add the address list when a fixed set of addresses is the real boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does and does not claim
&lt;/h2&gt;

&lt;p&gt;Endpoint authentication is not new, and plenty of platforms let you build it. Among the three hosts we compared against (Railway, Render and Fly.io; their own pages re-read on 14 November 2026), we did not find tokens per agent, for machine callers, on every plan, with no code to write. Railway's built-in gate for public domains is a human login on its Enterprise tier. Render documents a reverse proxy you deploy yourself. Fly.io documents private networking and leaves checks on a public app to your own code. The sources and dates are on our comparison pages, and if one of them changes, so does this paragraph.&lt;/p&gt;

&lt;p&gt;What tokens are not: they identify a caller, not a person; a token opens every public route of its agent, not a subset; and before you generate the first one, the agent answers anyone who knows its URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Every plan includes access tokens, from Builder at €19 a month (excl. VAT). Make an agent, generate a token, and run the two &lt;code&gt;curl&lt;/code&gt; lines above against it: &lt;a href="https://uagents8.com/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=launch-2026-11&amp;amp;utm_content=devto-token-article#security" rel="noopener noreferrer"&gt;uagents8.com&lt;/a&gt;. Launch code &lt;strong&gt;LAUNCH30&lt;/strong&gt; takes 30% off the first three months on Builder or Growth until 30 November. The full guide is in the &lt;a href="https://uagents8.com/docs/agent-access-tokens" rel="noopener noreferrer"&gt;docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>security</category>
      <category>api</category>
      <category>agents</category>
    </item>
    <item>
      <title>How we built an AI that fixes failed builds (and why we verify the patch before building)</title>
      <dc:creator>Serhii Antonuik</dc:creator>
      <pubDate>Mon, 09 Nov 2026 14:09:11 +0000</pubDate>
      <link>https://dev.to/uagents8/how-we-built-an-ai-that-fixes-failed-builds-and-why-we-verify-the-patch-before-building-47ap</link>
      <guid>https://dev.to/uagents8/how-we-built-an-ai-that-fixes-failed-builds-and-why-we-verify-the-patch-before-building-47ap</guid>
      <description>&lt;p&gt;It's Tuesday, 11 p.m. The demo is at nine. You push one last change to your&lt;br&gt;
agent, and the deploy fails: a dependency you installed locally and never&lt;br&gt;
wrote down, a variable you renamed in one file and not the other, a port your&lt;br&gt;
framework picked by itself. The error is somewhere in three hundred lines of&lt;br&gt;
build log.&lt;/p&gt;

&lt;p&gt;We run a hosting platform for AI agents, and that moment is the one we wanted&lt;br&gt;
to remove. Not with a chatbot that explains the log, but with a button: &lt;strong&gt;Fix&lt;br&gt;
with AI&lt;/strong&gt;. One click, and a fixed copy of your agent is live a few minutes&lt;br&gt;
later, or you are told clearly why not.&lt;/p&gt;

&lt;p&gt;The hard part turned out not to be "ask a model for a patch". It was&lt;br&gt;
everything around the model. This is how it works, and what each part taught us.&lt;/p&gt;

&lt;h3&gt;
  
  
  Triage first: is this even a code problem?
&lt;/h3&gt;

&lt;p&gt;Our first version sent every failure straight to code generation. It went&lt;br&gt;
wrong in a very specific way: an agent missing a required environment variable&lt;br&gt;
was "fixed" again and again. The model can't set a variable, so it wrote code&lt;br&gt;
around the missing value, the deploy failed the same way, and the user clicked&lt;br&gt;
again.&lt;/p&gt;

&lt;p&gt;Now every attempt starts with a diagnosis that sorts the failure. Three&lt;br&gt;
outcomes are possible before any code is touched:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A value only the owner can know.&lt;/strong&gt; A missing API key, connection string or
host. The fix stops and says which variable to set. We learned this one in a
stress test: a model "fixed" a missing database URL by writing its own
placeholder in as the real value, and the agent started, connected to
nothing, and reported success. Now a credential-looking name or a
placeholder-looking value is never filled in by AI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A configuration change the evidence supports.&lt;/strong&gt; If the platform's own
health-check events show "connection refused" on the expected port, the
port is aligned in configuration and the agent is redeployed. If the agent
was stopped by a genuine out-of-memory kill, it is moved up one size
(within the plan; at the largest size it stops and says so). The diagnosis
alone is not enough; the evidence has to agree - and "exit code 137" alone
is not evidence of a memory kill, because a process stopped for failing
its health check exits the same way. We learned that one live too: an
agent bound to the wrong interface was given more memory twice before the
one-line code fix ran.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A real code problem.&lt;/strong&gt; Everything else goes on to the patching pipeline.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A failure caused by us, such as a temporary capacity limit while building, is&lt;br&gt;
never sent to a model at all. No patch can fix our capacity, and trying would&lt;br&gt;
spend the user's allowance on nothing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choosing a model per failure class
&lt;/h3&gt;

&lt;p&gt;Not every failure deserves the same model. A missing import is mechanical; a&lt;br&gt;
race condition across three files is not. So before generating anything, a&lt;br&gt;
fast, cheap model labels the failure &lt;strong&gt;LOW&lt;/strong&gt;, &lt;strong&gt;MEDIUM&lt;/strong&gt; or &lt;strong&gt;HIGH&lt;/strong&gt;, with a&lt;br&gt;
one-sentence reason. If that call fails, deterministic rules decide instead:&lt;br&gt;
known patterns like &lt;code&gt;ModuleNotFoundError&lt;/code&gt; or &lt;code&gt;SyntaxError&lt;/code&gt; mean LOW,&lt;br&gt;
deadlocks, segmentation faults and out-of-memory signals mean HIGH, and a&lt;br&gt;
generic "never became ready" with no application error also goes to HIGH,&lt;br&gt;
because there is nothing safe to guess from.&lt;/p&gt;

&lt;p&gt;Each label has its own ordered chain of models. LOW and MEDIUM failures start&lt;br&gt;
with a fast model that has a very large context window; HIGH ones, and every&lt;br&gt;
second attempt, start with the strongest coding models we use. If one provider in the&lt;br&gt;
chain errors, times out or is rate-limited, the next one answers.&lt;/p&gt;

&lt;p&gt;Two lessons from running this in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Routing everything to the strongest model made the fix the most
expensive thing we sell.&lt;/strong&gt; Starting easy cases on a cheaper model, and
saving the expensive ones for hard failures and retries, kept quality where
it matters and costs bounded by each plan's monthly AI budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A fallback you never exercise is not a fallback.&lt;/strong&gt; We found two models
in our chains failing almost every call for weeks: for one, our account's
rate limit was smaller than a single fix prompt; for the other, the context
window was. Both were fixed, and every chain was re-tested with a real-size
prompt.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What the model sees
&lt;/h3&gt;

&lt;p&gt;The model gets the error output (the tail, where the failure is), your&lt;br&gt;
Dockerfile if there is one, and up to 60 source files. The files the error&lt;br&gt;
names come first and whole, even when they are larger than the usual&lt;br&gt;
per-file limit, because a fix for a syntax error needs the file's header too.&lt;br&gt;
It also gets the &lt;strong&gt;names&lt;/strong&gt;, never the values, of the environment variables&lt;br&gt;
you have set, so it doesn't invent a "missing variable" that exists.&lt;/p&gt;

&lt;p&gt;Before anything leaves the platform, files that exist to hold credentials&lt;br&gt;
(&lt;code&gt;.env&lt;/code&gt;, private keys) are left out, and values that look like secrets are&lt;br&gt;
replaced with placeholders. The real values go back into the patched files&lt;br&gt;
afterwards. This is pattern-based and can't catch every secret, which is why&lt;br&gt;
we tell users to keep secrets in variables, not in code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two gates before any build: parse, then a security review
&lt;/h3&gt;

&lt;p&gt;A build takes real time and real money. An early patch for a Go service&lt;br&gt;
dropped the file's &lt;code&gt;package&lt;/code&gt; line; it went to a full build only for the&lt;br&gt;
compiler to reject it in the first second. Now every patch must &lt;strong&gt;parse&lt;/strong&gt;&lt;br&gt;
before anything is built: real parsers for Python, Go, Java, JavaScript,&lt;br&gt;
TypeScript, Rust and JSON, plus Go-specific checks for the mistakes models&lt;br&gt;
actually make (a dropped or renamed package clause, &lt;code&gt;=&lt;/code&gt; instead of &lt;code&gt;==&lt;/code&gt; in a&lt;br&gt;
condition). A patch that fails goes back to the model with the parser's&lt;br&gt;
message. For a typical file this takes well under a millisecond.&lt;/p&gt;

&lt;p&gt;We also check the whole snapshot, not only the patched files. In a stress test&lt;br&gt;
a repository with several broken files cost one redeploy per broken file,&lt;br&gt;
because each fix only looked at the file the latest error named. Now every&lt;br&gt;
file that doesn't parse is listed in the prompt and ranked first.&lt;/p&gt;

&lt;p&gt;Then the patch goes through an &lt;strong&gt;automated security review&lt;/strong&gt;, the same one&lt;br&gt;
every deploy from source goes through. If it finds a critical problem, nothing&lt;br&gt;
is built. If the review itself can't complete, nothing is built either: there&lt;br&gt;
is no human between the click and the deploy to weigh a skipped check, so the&lt;br&gt;
pipeline fails closed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy a copy, then ask the health check
&lt;/h3&gt;

&lt;p&gt;The patched code is never pushed to your repository. No commits, branches or&lt;br&gt;
pull requests. It is written to a snapshot, built by the normal build&lt;br&gt;
pipeline and deployed as a &lt;strong&gt;new version&lt;/strong&gt; of the agent, marked as AI-fixed,&lt;br&gt;
next to the versions you already have. If you don't like it, you restore the&lt;br&gt;
previous version in one click, and your next push builds from your own code&lt;br&gt;
again.&lt;/p&gt;

&lt;p&gt;The new version goes through the same health check as any deploy: the agent&lt;br&gt;
must start, listen on its port and answer. In our own tests, fixed copies went&lt;br&gt;
live in 2 to 4.5 minutes, depending on the error and the size of the code.&lt;/p&gt;

&lt;p&gt;If the health check fails, one more attempt runs automatically, and it is told&lt;br&gt;
what the first attempt changed and what happened. That second attempt is&lt;br&gt;
routed to the strongest models. After two attempts it stops and says so. A&lt;br&gt;
human clicking again later starts a new streak, but the history of what&lt;br&gt;
already failed is kept, so the same wrong fix isn't proposed with fresh&lt;br&gt;
confidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  What counts
&lt;/h3&gt;

&lt;p&gt;A plan includes a number of AI Fixes a month. &lt;strong&gt;Only a code fix that ends with&lt;br&gt;
your agent passing its health check uses one.&lt;/strong&gt; A patch that failed to parse,&lt;br&gt;
failed the security review, failed to build or failed to come up costs no fix.&lt;br&gt;
Every model call does draw on the plan's monthly AI budget, which is how the&lt;br&gt;
cost stays bounded either way.&lt;/p&gt;

&lt;h3&gt;
  
  
  What failures taught us: memory
&lt;/h3&gt;

&lt;p&gt;Models are confident, and a model will propose the same failed fix twice.&lt;br&gt;
So the platform remembers outcomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When a fix is confirmed healthy, it is stored for your own account. The
same error on the same files can get that fix back without a model call.
Confirmed fixes are never reused across accounts.&lt;/li&gt;
&lt;li&gt;When a patch fails, its fingerprint is recorded. A patch that has already
failed twice for a similar error is rejected outright. When another
customer hits a similar error, the model is warned with the error
signature, the error output and the names of the files that failed patch
changed. &lt;strong&gt;Never the code itself.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What it doesn't do
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It fixes failed builds and deploys, not an agent that crashes days after
it went live.&lt;/strong&gt; Today that gets a restart, a crash email and a plain-language
diagnosis. Repairing a live agent is on our public roadmap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It can't make an agent smaller than its workload.&lt;/strong&gt; If an agent is killed
for using more memory than its size allows, the repair is a larger size,
not a patch: AI Fix moves it up one size when the kill is genuine, and
stops and tells you when the next size is not in your plan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It needs source code.&lt;/strong&gt; An agent deployed from a ready-made image has no
code to patch; diagnosis still explains the failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It isn't always right&lt;/strong&gt;, which is why it stops after two attempts and why
every result is a version you can roll back. We'll publish real success
rates once we have enough launch traffic to make them honest.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Try it
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnm9ue1uf7gfloz52nmgn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnm9ue1uf7gfloz52nmgn.png" alt="How AI Fix decides and checks a fix: a flowchart from a failed build, through triage, the patch gates and the health check, to a live version" width="800" height="749"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every plan includes AI Fix. If you have an agent that works on your laptop,&lt;br&gt;
deploy it, break it on purpose, and press the button:&lt;br&gt;
&lt;a href="https://uagents8.com/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=launch-2026-11&amp;amp;utm_content=devto-ai-fix-article" rel="noopener noreferrer"&gt;uagents8.com&lt;/a&gt;.&lt;br&gt;
Launch code &lt;strong&gt;LAUNCH30&lt;/strong&gt; takes 30% off the first three months on Builder or&lt;br&gt;
Growth until 30 November.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cicd</category>
      <category>debugging</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
