SuperAPIAI Directory

agentloop

github.com · AI developer platforms

AgentLoop is a Claude agent starter project built on Anthropic's official SDK and Next.js. Its core code is about 150 lines and fully implements streaming output and the tool-calling loop. It does not rely on any framework, nor does it include a huge SaaS template; after cloning, you can deploy it by adding an API key. The project uses the MIT license and provides two example tools (get current time, calculate) as well as a single-function extension point, making it easy for developers to add custom tools. In addition, the author also provides a free Agent Token Profiler tool for analyzing the token consumption of an agent in each round of conversation, and has published research on the token cost of open-source AI agents. AgentLoop Pro is a paid version that provides fixes for eight common problems in production environments, using a pay-as-you-go model starting at $9.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

AgentLoop is a Claude agent starter project for developers, designed to provide a readable and clearly structured implementation of an agent loop. It is based on Next.js (App Router) and TypeScript, uses the official Anthropic SDK, and concentrates its core logic in the app/api/chat/route.ts file, with about 150 lines of code. The project uses the MIT license and is provided for free.

Purpose: AgentLoop is used to help developers quickly understand and build Claude-based AI agents. It demonstrates the basic pattern of an agent loop: send a conversation to the model, execute the tools the model calls, append the results to the conversation, and repeat this process until the model returns an ordinary text response. The loop is limited to a maximum of 5 steps.

Main capabilities:

  • Streaming chat: Uses native fetch and ReadableStream to render tokens in real time, with no UI dependency and no SDK lock-in.
  • Real tool calling: Implements a working agent loop, rather than simple conditional checks.
  • Two example tools: get_current_time and calculate, and provides a single-function extension point for easily adding custom tools.
  • Typed and commented: The code includes type definitions and comments, and stays in sync with current Claude models.
  • One-click deployment: Supports one-click deployment to Vercel.

How to use:

  1. Clone the repository.
  2. Get an API key at console.anthropic.com.
  3. Set the ANTHROPIC_API_KEY environment variable.
  4. Run the project, and you can ask the agent questions such as "what is (12 * 9) + 7?" to observe it calling the calculate tool.
  5. When deploying to Vercel, set ANTHROPIC_API_KEY in the project environment variables and it can go live.

Adding custom tools: You only need to make two edits in the lib/tools.ts file, and Claude will read the tool descriptions to decide when to call them.

Applicable scenarios:

  • Developers learning how AI agents work.
  • Teams that need to quickly build a Claude agent prototype.
  • Developers who want to avoid black-box frameworks and bloated SaaS templates.
  • Those who need to build their own agent products based on the Anthropic SDK.scenario.

Limitations and additional information:

  • The project core is free and uses the MIT license, but AgentLoop Pro is a paid version that provides production environment fixes, uses a pay-as-you-go model, starts at $9 (originally $29), includes a commercial license, unlimited projects, and is available on Ko-fi.
  • The author provides a free Agent Token Profiler tool that runs in the browser, requires no registration or key, and is used to analyze the token consumption of an agent per conversation turn and flag the approximately 20% waste caused by serialization redundancy (such as $schema, title added by Pydantic).
  • The author also published a study that measured the actual cost per conversation turn of 13 real open-source AI agents (79 tools), pointing out that GitHub's MCP server resends 3,546 tokens per turn.
  • AgentLoop Pro includes 29 tests, can be run via npm test, and supports running on Claude or any model (via OpenRouter) through the ModelCaller seam.
  • The project is publicly built by an independent developer.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools