<?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: Varad J</title>
    <description>The latest articles on DEV Community by Varad J (@varad13).</description>
    <link>https://dev.to/varad13</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%2F1460772%2F0d7e639d-4abe-43b6-9979-43758130cbc5.jpeg</url>
      <title>DEV Community: Varad J</title>
      <link>https://dev.to/varad13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/varad13"/>
    <language>en</language>
    <item>
      <title>How I turned my AI CLI into an autonomous agent with Playwright and Sub-agents 🚀</title>
      <dc:creator>Varad J</dc:creator>
      <pubDate>Mon, 22 Jun 2026 07:14:08 +0000</pubDate>
      <link>https://dev.to/varad13/how-i-turned-my-ai-cli-into-an-autonomous-agent-with-playwright-and-sub-agents-51di</link>
      <guid>https://dev.to/varad13/how-i-turned-my-ai-cli-into-an-autonomous-agent-with-playwright-and-sub-agents-51di</guid>
      <description>&lt;p&gt;When I first built Codey, it was a simple CLI wrapper around an LLM with a few basic tools. It was great for small tasks, but as I started throwing harder problems at it, the limitations became obvious.&lt;/p&gt;

&lt;p&gt;It couldn't run dev servers without blocking the thread, it couldn't browse documentation, and honestly, raw eval() calls were keeping me up at night.&lt;/p&gt;

&lt;p&gt;So, I tore down the foundation and did a massive platform rewrite. Today, I'm excited to share how Codey evolved from a simple script into a secure, persistent agent runtime.&lt;/p&gt;

&lt;p&gt;Here’s a deep dive into the technical upgrades.&lt;br&gt;
🌐 1. Human-Like Browsing (Playwright + Vision)&lt;br&gt;
I wanted Codey to be able to read documentation, check GitHub issues, and visually debug UIs. I integrated a full Playwright-backed web tool.&lt;/p&gt;

&lt;p&gt;The Vision Bottleneck: Initially, to pass visual context to the model, the pipeline looked like this: Screenshot -&amp;gt; Write PNG to disk -&amp;gt; Read PNG -&amp;gt; Base64 encode. This disk I/O was noticeably slow. I optimized it by capturing the screenshot directly into memory as bytes and encoding it on the fly. We completely removed the .codey_screenshots/ temp directory.&lt;/p&gt;

&lt;p&gt;Self-Healing Dependencies: There's nothing worse than a tool failing because a user doesn't have Chromium installed. Now, if the browser launch fails, Codey catches the error, automatically runs playwright install chromium, and retries the launch in the background.&lt;/p&gt;

&lt;p&gt;Smart Prompting: If you drop a link like https://... into the terminal, the system dynamically injects the web tool into the prompt and immediately triggers web.navigate() instead of asking you to paste the content.&lt;/p&gt;

&lt;p&gt;🤖 2. Sub-Agents and Persistent Terminals&lt;br&gt;
This is where the architecture really shifted from "chatbot" to "agent runtime".&lt;/p&gt;

&lt;p&gt;The delegate Tool: Codey can now launch a completely autonomous sub-agent. This second agent gets its own tool loop, its own history, and its own context. It goes off to solve a sub-task and returns a summary to the main agent.&lt;br&gt;
Persistent Sessions (terminal): Previously, if Codey ran a command, it would lose the process. I added start, send, peek, and stop actions. Now, Codey can start a Next.js dev server, leave it running in the background, peek at the logs, and continue writing code.&lt;br&gt;
Human-in-the-Loop (ask): Sometimes the AI shouldn't guess. If Codey isn't sure which file to edit, it pauses execution and renders an interactive multiple-choice prompt in your terminal.&lt;/p&gt;

&lt;p&gt;🛡️ 3. Security Hardening&lt;br&gt;
As Codey got smarter, it got more dangerous. I had to lock it down.&lt;/p&gt;

&lt;p&gt;Killing eval(): Arbitrary code execution is a massive vulnerability. I stripped out raw eval() for the calculator tool and replaced it with strict ast.parse() validation. We now use a strict whitelist of safe operators, functions, and constants.&lt;/p&gt;

&lt;p&gt;Fixing Shell Injections: I moved away from raw shell execution and string concatenation. Before: git diff  passed directly to the shell. After: Using subprocess.run([...]) combined with shlex.split() for safe argument parsing.&lt;/p&gt;

&lt;p&gt;Path Traversal &amp;amp; Approval Gates: Added a strict assert_within_project() check to create_file, edit_file, and read_files so the agent can't randomly decide to read ../../../etc/passwd. I also added a CONFIRM_SHELL=true environment flag that forces Codey to ask for human permission before running potentially destructive commands.&lt;/p&gt;

&lt;p&gt;🧠 4. State Management &amp;amp; Developer Experience&lt;br&gt;
Finally, I overhauled how Codey remembers things.&lt;/p&gt;

&lt;p&gt;Multi-Session Workflow: Codey used to dump everything into one history.jsonl per project. Now, it generates separate session files and greets you with an interactive startup picker (showing message counts and previews) so you can resume yesterday's work or start fresh.&lt;br&gt;
Streaming &amp;amp; Context: Switched to token-by-token streaming for a snappy, ChatGPT-like feel. Added trim_history() and MAX_TOOL_ROUNDS to prevent infinite loops and runaway API costs.&lt;br&gt;
Wrapping up&lt;br&gt;
The patches transformed Codey from CLI + LLM + tools into a Persistent agent runtime + browser automation + subagents + project memory.&lt;/p&gt;

&lt;p&gt;Building this has been an incredible lesson in agent orchestration and Python CLI development.&lt;/p&gt;

&lt;p&gt;If you're interested in AI coding assistants, want to build your own, or just want to poke around the source code, check out the repo! I'd love your feedback, bug reports, or pull requests (we always need more tools).&lt;/p&gt;

&lt;p&gt;👉 Check out Codey on GitHub: github.com/varad-13/codey&lt;/p&gt;

&lt;p&gt;Let me know what you think in the comments! What tools should I add next?&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>ai</category>
      <category>agents</category>
      <category>python</category>
    </item>
    <item>
      <title>How OpenAI Codex let me down — and why I built Codey, an open-source coding assistant</title>
      <dc:creator>Varad J</dc:creator>
      <pubDate>Mon, 28 Apr 2025 00:32:56 +0000</pubDate>
      <link>https://dev.to/varad13/how-openai-codex-let-me-down-and-why-i-built-codey-an-open-source-coding-assistant-522h</link>
      <guid>https://dev.to/varad13/how-openai-codex-let-me-down-and-why-i-built-codey-an-open-source-coding-assistant-522h</guid>
      <description>&lt;p&gt;When OpenAI announced Codex and CLI tools, I got excited — finally, an easy way to automate coding workflows using LLMs!&lt;br&gt;
I bought credits, installed the CLI, and even set it up on my Mac.&lt;/p&gt;

&lt;p&gt;But... it didn't go smoothly.&lt;/p&gt;

&lt;p&gt;First, I realized Codex CLI only supports Mac and Linux. Okay, not ideal but manageable.&lt;br&gt;
Then, I found out that cheaper models like gpt-4o-mini don't even support shell commands.&lt;br&gt;
(If you try, you get ENOENT errors because tool calls are missing.)&lt;/p&gt;

&lt;p&gt;I thought: maybe switching to o4-mini would fix it.&lt;br&gt;
Nope — new accounts don't have access immediately. I was stuck.&lt;/p&gt;

&lt;p&gt;Instead of waiting endlessly, I decided to build my own CLI assistant from scratch — and that's how Codey was born!&lt;/p&gt;

&lt;p&gt;🚀 What is Codey?&lt;br&gt;
Codey is a Python-based, open-source coding assistant that uses OpenAI's API — but defines all tools explicitly for safety and control.&lt;/p&gt;

&lt;p&gt;It supports:&lt;/p&gt;

&lt;p&gt;File Management: Create, edit, and read files with tools like create_file, edit_file, read_codebase&lt;/p&gt;

&lt;p&gt;Git Operations: Add, commit, check status, view diffs, and more&lt;/p&gt;

&lt;p&gt;Utilities: Search files (grep) and calculate expressions safely&lt;/p&gt;

&lt;p&gt;Shell Commands: Run shell commands inside your environment securely&lt;/p&gt;

&lt;p&gt;🧠 Why build it myself?&lt;br&gt;
I wanted predictability — knowing exactly what a tool can and cannot do.&lt;/p&gt;

&lt;p&gt;I wanted local safety — no random shell execution unless I allow it.&lt;/p&gt;

&lt;p&gt;I wanted modularity — easily extend or customize based on project needs.&lt;/p&gt;

&lt;p&gt;And honestly... I just wanted something that works reliably without mysterious permission errors.&lt;/p&gt;

&lt;p&gt;📢 Codey is Open Source&lt;br&gt;
You can check it out here:&lt;br&gt;
👉 &lt;a href="https://github.com/Varad-13/codey" rel="noopener noreferrer"&gt;https://github.com/Varad-13/codey&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to try it out, suggest features, or even contribute (we need to add a million more tools) — you're welcome! 🚀&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>python</category>
      <category>tooling</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
