<?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: Richard Putnam</title>
    <description>The latest articles on DEV Community by Richard Putnam (@richard_putnam_1614fa30d6).</description>
    <link>https://dev.to/richard_putnam_1614fa30d6</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3720545%2Fe3af55a8-4aa8-4fa1-9994-3341f4242d46.png</url>
      <title>DEV Community: Richard Putnam</title>
      <link>https://dev.to/richard_putnam_1614fa30d6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/richard_putnam_1614fa30d6"/>
    <language>en</language>
    <item>
      <title>I Built My First AI Agent in Under 2 Hours - Here's How</title>
      <dc:creator>Richard Putnam</dc:creator>
      <pubDate>Tue, 20 Jan 2026 01:28:26 +0000</pubDate>
      <link>https://dev.to/richard_putnam_1614fa30d6/i-built-my-first-ai-agent-in-under-2-hours-heres-how-507j</link>
      <guid>https://dev.to/richard_putnam_1614fa30d6/i-built-my-first-ai-agent-in-under-2-hours-heres-how-507j</guid>
      <description>&lt;p&gt;I've been a software developer for over 20 years. I've seen technologies come and go. But nothing has changed my workflow like AI assistants.&lt;/p&gt;

&lt;p&gt;This weekend, I built a fully functional AI research agent with a web interface. It searches the web in real-time, synthesizes information, and presents answers with citations. &lt;/p&gt;

&lt;p&gt;Total time: under 2 hours.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;A research agent that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Takes any question&lt;/li&gt;
&lt;li&gt;Searches the web using Tavily API&lt;/li&gt;
&lt;li&gt;Uses Claude to analyze and synthesize the results
&lt;/li&gt;
&lt;li&gt;Returns a well-organized answer with source citations&lt;/li&gt;
&lt;li&gt;Runs in a clean web interface&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I asked it for tomorrow's weather forecast in my city. It searched, found current data, and gave me an accurate answer. That's not a parlor trick - that's a useful tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python&lt;/strong&gt; - The language&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anthropic Claude API&lt;/strong&gt; - The "brain" that reasons and decides what to search&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tavily API&lt;/strong&gt; - Web search built for AI agents&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlit&lt;/strong&gt; - Turned it into a web app with minimal code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Total cost to experiment: about $5-10 in API credits.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Concept: The Agent Loop
&lt;/h2&gt;

&lt;p&gt;The most important thing I learned is how AI agents actually work. It's a simple loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Receive a task
2. Think: "What do I need to find out?"
3. Use a tool (web search)
4. Look at the results
5. Think: "Do I have enough info?"
6. If no, go back to step 3
7. If yes, synthesize and respond
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. This pattern is the foundation of most AI agents, from simple research bots to complex autonomous systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Surprised Me
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How fast it came together.&lt;/strong&gt; I expected this to take weeks of research - finding the right APIs, figuring out how to connect them, debugging integration issues. Instead, with AI assistance, I went from zero to working prototype in a single session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The system prompt matters.&lt;/strong&gt; My first version had a bug: when I asked about weather, the agent searched the web but then told me it &lt;em&gt;couldn't&lt;/em&gt; search the web. The AI forgot it had tools. A clearer system prompt fixed it. Lesson learned: how you instruct the AI determines how well it performs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is accessible now.&lt;/strong&gt; You don't need a PhD in machine learning. You don't need to train models. With APIs and some Python knowledge, you can build real AI-powered tools today.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Code Structure
&lt;/h2&gt;

&lt;p&gt;The entire agent is about 150 lines of Python:&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="c1"&gt;# Define tools the agent can use
&lt;/span&gt;&lt;span class="n"&gt;tools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;web_search&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Search the web for current information...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;input_schema&lt;/span&gt;&lt;span class="sh"&gt;"&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="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# The agent loop
&lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-sonnet-4-20250514&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;messages&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;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stop_reason&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;end_turn&lt;/span&gt;&lt;span class="sh"&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;final_response&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stop_reason&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tool_use&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Execute the tool, add results, continue loop
&lt;/span&gt;        &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI decides when to use tools, what to search for, and when it has enough information. You just provide the tools and let it reason.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;This is just the starting point. From here, I could:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add more tools (calculator, file reading, API calls)&lt;/li&gt;
&lt;li&gt;Specialize it for a specific domain&lt;/li&gt;
&lt;li&gt;Deploy it for others to use&lt;/li&gt;
&lt;li&gt;Build it into other applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm documenting my journey learning AI development. More posts to come.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;If you want to build this yourself:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get API keys from &lt;a href="https://console.anthropic.com/" rel="noopener noreferrer"&gt;Anthropic&lt;/a&gt; and &lt;a href="https://tavily.com/" rel="noopener noreferrer"&gt;Tavily&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install: &lt;code&gt;pip install anthropic tavily-python streamlit python-dotenv&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The core agent loop is ~100 lines of Python&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The barrier to entry has never been lower. The question isn't whether you &lt;em&gt;can&lt;/em&gt; build AI tools - it's what you'll build.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is the first post in a series documenting my experiments with AI agents and automation. Follow along for more.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>python</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
