Skip to content

Agentic Loop

Scaffolds a TypeScript agentic loop that sends messages to an LLM, detects tool-call requests in the response, executes them via a typed tool registry, appends results, and repeats until the model stops calling tools or an iteration limit is reached. Supports Anthropic and OpenAI as LLM providers, an optional conversation memory subsystem with token-aware truncation, and an optional eval harness for assertion-based testing against fixture files.

Nameagentic-loop
Version0.1.0
Categoryai-systems
LicenseApache-2.0
Personaengineering
Tagstypescript, agent, llm, tools, agentic, ai
Sourcetemplates/agentic-loop

Render it

Three front doors, one catalog. Pick whichever suits the caller.

# CLI
npx @nanohype/sdk render agentic-loop --out ./my-app

# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "agentic-loop", variables);

# MCP — from an agent
get_template({ name: "agentic-loop" })

Prerequisites

ToolVersionWhy
node>=22Node.js runtime for TypeScript execution

Variables

Required

ProjectName string
Kebab-case project name, used in package.json and directory Must be lowercase kebab-case starting with a letter.

Optional

Description string — defaults to An agentic loop powered by LLM tool-calling
Short project description for package.json and README
LlmProvider string — defaults to anthropic
LLM provider to use for the agent
IncludeMemory bool — defaults to true
Include the conversation memory subsystem with token-aware truncation
IncludeEval bool — defaults to true
Include the eval harness for assertion-based agent testing
MaxIterations int — defaults to 10
Maximum number of tool-calling loop iterations before the agent stops

What it produces

32 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.

.env.example
.gitignore
biome.json
package.json
README.md
src/__tests__/agent.test.ts
src/__tests__/example-tool.test.ts
src/__tests__/registry.test.ts
src/agent.ts
src/bootstrap.ts
src/eval/assertions.ts
src/eval/fixtures/.gitkeep
src/eval/runner.ts
src/logger.ts
src/memory/context.ts
src/memory/conversation.ts
src/memory/store.ts
src/metrics.ts
src/providers/anthropic.ts
src/providers/index.ts
src/providers/mock.ts
src/providers/openai.ts
src/providers/registry.ts
src/providers/types.ts
src/resilience/__tests__/circuit-breaker.test.ts
src/resilience/circuit-breaker.ts
src/tokens.ts
src/tools/example.ts
src/tools/index.ts
src/tools/registry.ts
tsconfig.json
vitest.config.ts

Composes with

Composites that use it

  • Agent Team — Multi-agent system with a central orchestrator, specialized agents for research and writing, an evaluation harness, and MCP tool server.
  • AI Chatbot — Full-stack AI chatbot with agentic loop, HTTP service, authentication, evaluation harness, and deployment..
  • Enterprise AI Infrastructure — Full enterprise AI stack with agents, tool servers, safety guardrails, evaluation, prompt management, observability, and Kubernetes deployment..
  • Multi-Agent System — Multi-agent architecture with A2A protocol peers, MCP tool servers, and an orchestrating agent.
  • AI Proof of Concept — Minimal AI agent with evaluation harness.
  • RAG-Powered Agent — AI agent that uses retrieval-augmented generation as a tool.
  • Research to Prototype — Research-driven prototype pipeline.
  • Safe AI Agent — AI agent with safety guardrails, evaluation harness, and prompt management.