---
title: "You Should Write An Agent"
description: "An LLM agent is just a loop around a stateless chat API: keep a list of messages, replay it on every call, and when the model emits a function_call, run the tool and append its output."
url: "https://swe.quest/articles/you-should-write-an-agent-1b4d0eb48fb350d8"
canonical: "https://fly.io/blog/everyone-write-an-agent/"
source: "Fly.io"
published: "2025-11-06"
difficulty: "medium"
kind: "Opinion"
reading_minutes: 10
tags: ["ai-agents","llms","python"]
---

# You Should Write An Agent

A post on [Fly.io](https://swe.quest/sources/flyio.md), published 2025-11-06, 10 min read, Opinion. Original: [https://fly.io/blog/everyone-write-an-agent/](https://fly.io/blog/everyone-write-an-agent/)

## Summary

An LLM agent is just a loop around a stateless chat API: keep a list of messages, replay it on every call, and when the model emits a function\_call, run the tool and append its output. A few dozen lines of Python against the OpenAI Responses API produce a working tool-using agent that decides on its own to ping multiple Google hosts. MCP is barely a technology, just a plugin interface for agents you don't control, and context engineering is a real, legible programming problem of budgeting tokens across sub-agents, tools and summaries. Agent design leaves open problems around nondeterminism, grounding, inter-agent interchange formats and cost, and each design iteration takes about 30 minutes, so engineers should build one themselves.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Python basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- HTTP APIs ([easy posts on API design](https://swe.quest/tags/api-design.md?difficulty=easy))

## Keywords

OpenAI Responses API, MCP, Claude Code, GPT-5, context engineering

## Related posts

- [Tiny Agents: an MCP-powered agent in 50 lines of code](https://swe.quest/articles/tiny-agents-an-mcp-powered-agent-in-50-lines-of-code-6bc1baf5d192d871.md): Hugging Face · 2025-04-25 · Medium · 10 min read · AI agents, LLMs, TypeScript
  An LLM agent built on the Model Context Protocol reduces to a simple while loop around an MCP-aware inference client: connect to MCP servers, convert their tools into OpenAI-style function definitions, pass them to the chat-completion call, execute returned tool calls via the MCP SDK, and feed results back.
- [Tiny Agents in Python: a MCP-powered agent in ~70 lines of code](https://swe.quest/articles/tiny-agents-in-python-a-mcp-powered-agent-in-70-lines-of-code-ec89d52eb52d9576.md): Hugging Face · 2025-05-23 · Medium · 16 min read · AI agents, LLMs, Python
  Hugging Face's huggingface\_hub Python SDK now includes an MCP client and a minimal Agent class, letting an LLM pull tools from MCP servers (stdio, SSE or streamable HTTP) and call them during inference.
- [Harness, Scaffold, and the AI Agent Terms Worth Getting Right](https://swe.quest/articles/harness-scaffold-and-the-ai-agent-terms-worth-getting-right-0e5aba5b0f70e57a.md): Hugging Face · 2026-05-25 · Easy · 12 min read · AI agents, LLMs, Model training
  A glossary of AI agent terms that are often conflated. The model is a stateless LLM.
- [You are Doing MCP Wrong: 3 Big Misconceptions](https://swe.quest/articles/you-are-doing-mcp-wrong-3-big-misconceptions-4ed8974e9536c439.md): Docker · 2025-09-03 · Medium · 4 min read · AI agents, LLMs, API design, Observability
  MCP is a model-facing protocol for LLM tool use and context exchange, not a replacement for REST or gRPC.
- [The Art of Loop Engineering](https://swe.quest/articles/the-art-of-loop-engineering-1c4cd354dba11ffe.md): LangChain · 2026-10-29 · Easy · 6 min read · AI agents, LLMs, Evaluation
  Agent systems can be structured as four stacked loops: the basic agent loop (model calls tools until done), a verification loop where a deterministic or LLM grader checks output against a rubric and retries with feedback, an event-driven loop where crons, webhooks or Slack channels trigger background runs, and a hill-climbing loop where an analysis agent mines production traces to rewrite prompts, tools or graders.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
