The Agent Stack #034 — Monday Build


You don’t need a framework to build an AI agent. You need 300 lines of Python and a clear head about what ReAct actually does.

This week’s most practical piece came from quantumentangled.dev - a walkthrough of ReAct’s core loop without the enterprise bloat. I’ve been saying this for months: most agent frameworks are solving problems you don’t have yet.

The 300-Line Reality Check

ReAct (Reasoning + Acting) boils down to three steps:

  1. Reason: Ask the LLM to think through the problem
  2. Act: Let it choose and execute a tool
  3. Observe: Feed the results back and repeat

Here’s what that looks like in practice:

class ReActAgent:
    def __init__(self, llm, tools):
        self.llm = llm
        self.tools = {tool.name: tool for tool in tools}
        
    def run(self, query, max_steps=10):
        messages = [{"role": "user", "content": query}]
        
        for step in range(max_steps):
            # Reason
            response = self.llm.complete(messages + [self.get_prompt()])
            
            if "Final Answer:" in response:
                return self.extract_answer(response)
                
            # Act
            action = self.parse_action(response)
            if action["tool"] not in self.tools:
                messages.append({"role": "assistant", "content": f"Error: Unknown tool {action['tool']}"})
                continue
                
            result = self.tools[action["tool"]].run(action["input"])
            
            # Observe
            messages.append({"role": "assistant", "content": response})
            messages.append({"role": "user", "content": f"Observation: {result}"})
            
        return "Max steps reached"

The magic isn’t in the code - it’s in the prompt structure. You need clear instructions for tool format, reasoning steps, and when to stop.

What Actually Matters

Skip the abstractions. Focus on:

  • Tool calling format: Standardise how your agent calls functions
  • Error handling: What happens when tools fail or return rubbish?
  • Memory management: How many conversation turns can you afford?
  • Stopping conditions: When does the agent decide it’s done?

Most production issues come from these four areas. Not from choosing the wrong graph database or agent orchestration platform.

Build your first agent in vanilla Python. Add complexity only when you understand exactly why you need it.

Quick Hits

Polis Protocol: New markdown-based spec for multi-agent teams that learn from interactions. Worth watching for team coordination patterns.

Agnt CLI: Open-source tool for running public AI agents locally. Good for testing agent workflows without vendor lock-in.

Bitloops Brain: Codebase-aware agent system that builds knowledge graphs from your code. Interesting approach to context-aware development assistants.

One Thing to Try

Take your current agent (or build a simple one) and implement the 300-line ReAct pattern. No frameworks, no dependencies beyond your LLM client. Time yourself - it should take under two hours.

You’ll learn more about agent behaviour in those two hours than reading agent framework docs for a week.

The best way to understand agents is to build one that breaks in interesting ways.