Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Simple Agent Architecture
A simple single-agent architecture is the best starting point for most agent projects. Build this pattern before moving to multi-agent systems.
8 min•By Priygop Team•Updated 2026
Simple Architecture Code
Simple Architecture Code
# Simple agent architecture
import json
class SimpleAgent:
def __init__(self, goal, tools, max_steps=10):
self.goal = goal
self.tools = tools # Dict of tool_name -> tool_function
self.max_steps = max_steps
self.state = {
"goal": goal,
"history": [],
"step": 0,
"status": "running"
}
def decide(self):
"""
In a real agent, this calls a language model.
Here we use a simplified mock decision.
"""
# The controller reads the goal and history, returns the next action
step = self.state["step"]
if step == 0:
return {"action": "web_search", "args": {"query": self.goal}}
elif step == 1:
return {"action": "summarise", "args": {"text": self.state["history"][0]["observation"]}}
else:
return {"action": "FINISH", "result": "Task complete"}
def run(self):
while self.state["step"] < self.max_steps:
decision = self.decide()
if decision["action"] == "FINISH":
self.state["status"] = "complete"
print("Goal complete. Result:", decision.get("result"))
break
# Execute tool
tool_fn = self.tools[decision["action"]]
result = tool_fn(**decision["args"])
# Record observation
self.state["history"].append({
"step": self.state["step"],
"action": decision["action"],
"observation": result
})
self.state["step"] += 1
print(f"Step {self.state['step']}: {decision['action']} complete")
return self.state