Copied to Clipboard
Go Agent
import subprocess, re, os, time
from openai import OpenAI
client = OpenAI()
WORKDIR = "go_agent"
FILENAME = os.path.join(WORKDIR, "main.go")
os.makedirs(WORKDIR, exist_ok=True)
def generate(goal, error=None):
prompt = f"Build a Go REST API with net/http. Fix errors: {error}"
r = client.responses.create(model="gpt-4.1-mini", input=prompt)
return r.output_text
def run():
p = subprocess.Popen(["go", "run", "main.go"], cwd=WORKDIR,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
time.sleep(3)
if p.poll() is None:
return 0, "", ""
out, err = p.communicate()
return p.returncode, out, err
def fix(err):
if "go.mod file not found" in err:
subprocess.run(["go", "mod", "init", "notesapi"], cwd=WORKDIR)
return True
m = re.search(r"no required module provides package (.+?);", err)
if m:
subprocess.run(["go", "get", m.group(1)], cwd=WORKDIR)
return True
return False
error = None
for _ in range(5):
code = generate("REST API", error)
open(FILENAME, "w").write(code)
rc, out, err = run()
if rc == 0:
break
if fix(err):
continue
error = err
TypeScript Agent
import subprocess, os, re, time
from openai import OpenAI
client = OpenAI()
WORKDIR = "ts_agent"
FILENAME = os.path.join(WORKDIR, "server.ts")
os.makedirs(WORKDIR, exist_ok=True)
def generate(goal, error=None):
prompt = f"Build an Express TypeScript REST API. Fix errors: {error}"
r = client.responses.create(model="gpt-4.1-mini", input=prompt)
return r.output_text
def setup():
if not os.path.exists(os.path.join(WORKDIR, "package.json")):
subprocess.run(["npm", "init", "-y"], cwd=WORKDIR)
subprocess.run(["npm", "install", "express", "sqlite3"], cwd=WORKDIR)
subprocess.run(["npm", "install", "-D", "typescript", "ts-node", "@types/node", "@types/express"], cwd=WORKDIR)
def run():
p = subprocess.Popen(["npx", "ts-node", "server.ts"], cwd=WORKDIR,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
time.sleep(3)
if p.poll() is None:
return 0, "", ""
out, err = p.communicate()
return p.returncode, out, err
def fix(err):
m = re.search(r"Cannot find module '(.+?)'", err)
if m:
subprocess.run(["npm", "install", m.group(1)], cwd=WORKDIR)
return True
return False
setup()
error = None
for _ in range(5):
code = generate("REST API", error)
open(FILENAME, "w").write(code)
rc, out, err = run()
if rc == 0:
break
if fix(err):
continue
error = err
The Real Insight
The agent is not fixing code.
It is fixing the system.
Failures were environmental:
- missing dependencies
- missing modules
- runtime mismatches
- process lifecycle
The hardest part of software engineering is not writing code — it’s making systems work.
Unattended agentic coding is the first serious attempt to automate that entire loop.
Key Topics for Next Articles
In this article we have scratched the surface of agentic coding .
In upcoming articles, we'll cover the following topics:
1.Multi-file & Repository-Aware Agents
Move from single-file generation to full project structures (modules, configs, folders).
2.Stateful & Incremental Code Editing
Agents that read, modify, and improve existing code instead of regenerating from scratch.
3.Test-Driven Agentic Development
Shift from "it runs" → "it works" by validating behavior via API calls, tests, and assertions.
4.Robust Environment & Tooling Orchestration
Handling real-world constraints (Python, Node, nvm, dependencies, ports) reliably.
5.Multi-Agent Architectures (Minions & Stripes)
Introduce specialized agents (planner, coder, tester, fixer) collaborating toward a goal.
- Observability, Metrics & Feedback Loops
Track attempts, failures, convergence, and use richer signals (logs, responses, tests) to guide agents.
Full Code & Examples
https://github.com/mmmattos/agentic-coding-demo