You Should Write An Agent
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.
Related posts
- Tiny Agents: an MCP-powered agent in 50 lines of code
Hugging Face mediumAdeptAn 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. The TypeScript implementation in huggingface.js extends InferenceClient into an McpClient that holds one session per server and maps tool names to sessions. An Agent class adds a system prompt plus two control-flow tools (task_complete, ask_question). The loop alternates tool calls and results until an exit tool is called, the model answers twice without tools, or a turn limit is reached. The default setup uses Qwen2.5-72B on Nebius, and the model, provider and MCP servers can be swapped.
- Tiny Agents in Python: a MCP-powered agent in ~70 lines of code
Hugging Face mediumAdeptHugging 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. Install it with `pip install "huggingface_hub[mcp]"`, then run agents from the `tiny-agents` CLI, configured by an agent.json that sets model, inference provider and MCP servers, plus an optional PROMPT.md. The MCPClient connects to servers, converts their tool schemas into OpenAI-style function definitions, and streams chat completions while rebuilding tool calls. It then routes each call to the right MCP session. The Agent is essentially a while loop on top of the client, with special exit-loop tools to end a turn.
- Harness, Scaffold, and the AI Agent Terms Worth Getting Right
Hugging Face easyNoviceA glossary of AI agent terms that are often conflated. The model is a stateless LLM. Scaffolding is the behavior-defining layer around it: system prompt, tool descriptions, output parsing and context management. The harness is the execution loop that calls the model, runs tool calls and decides when to stop, and an agent is model plus harness. Further entries cover context engineering, policy, tool use, skills and sub-agents, plus RL training terms (environment, trainer, rollout, reward and rubrics), with pointers to TRL's GRPOTrainer, OpenEnv and Verifiers.
- You are Doing MCP Wrong: 3 Big Misconceptions
Docker mediumAdeptMCP is a model-facing protocol for LLM tool use and context exchange, not a replacement for REST or gRPC. Tools execute while agents plan, re-plan and evaluate, and MCP also covers resources, prompts and elicitations alongside tools. The recommended architecture treats MCP as the seam between a non-deterministic planning layer and a deterministic execution layer. Concrete patterns include wrapping existing APIs with tools that declare pre/postconditions, keeping the agent control loop outside tools with explicit stop criteria, versioning prompts in a registry, using elicitations for low-confidence branches, and tracing plan → tool → result for replay and audit.
- The Art of Loop Engineering
LangChain easyNoviceAgent 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. Each level maps to a LangChain primitive (create_agent, RubricMiddleware, LangSmith Deployment triggers or Fleet channels, LangSmith Engine), illustrated with an internal docs-writing agent. Verification trades extra latency and cost for quality, and human-in-the-loop checkpoints are recommended at every level for sensitive actions. The argument is that compounding value lies in the outer event and improvement loops.