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. Calls the Platform's ModelGateway with tool use and holds no model credential. Includes an optional conversation memory subsystem with token-aware truncation, and an optional eval harness for assertion-based testing against fixture files.
| Name | agentic-loop |
| Version | 0.1.0 |
| Category | ai-systems |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | typescript, agent, llm, tools, agentic, ai, model-gateway |
| Source | templates/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
| Tool | Version | Why |
|---|---|---|
node | >=26 | Node.js runtime for TypeScript execution |
Variables
Required
ProjectNamestring- Kebab-case project name, used in package.json and directory Must be lowercase kebab-case starting with a letter.
Optional
Descriptionstring — defaults toAn agentic loop powered by LLM tool-calling- Short project description for package.json and README
LlmProviderstring — defaults togateway- LLM provider for the agent: gateway (the Platform ModelGateway, which holds the Bedrock role on the nanohype substrate), or a custom provider registered in src/providers/
PlatformNamestring — defaults to${ProjectName}- Name of the Platform CR this project deploys under. The gateway provider defaults MODEL_GATEWAY_ENDPOINT to the Service the eks-agent-platform operator creates for it, <PlatformName>-gateway in namespace tenants-<PlatformName>
IncludeMemorybool — defaults totrue- Include the conversation memory subsystem with token-aware truncation
IncludeEvalbool — defaults totrue- Include the eval harness for assertion-based agent testing
MaxIterationsint — defaults to10- Maximum number of tool-calling loop iterations before the agent stops
What it produces
39 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__/eval-cases.test.ts
src/__tests__/eval-runner.test.ts
src/__tests__/example-tool.test.ts
src/__tests__/gateway.test.ts
src/__tests__/registry.test.ts
src/agent.ts
src/bootstrap.ts
src/eval/assertions.ts
src/eval/cases.ts
src/eval/cases/answers-with-the-tool-result.json
src/eval/cases/keeps-the-system-role-under-contradiction.json
src/eval/cases/refuses-instructions-inside-tool-output.json
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/gateway.ts
src/providers/index.ts
src/providers/messages-tools.ts
src/providers/mock.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.tsComposes with
- Pairs with
mcp-server-ts - Pairs with
eval-harness - Pairs with
rag-pipeline - Nests inside
monorepo
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 a Platform tenant chart whose ModelGateway is the agent's model path..
- Enterprise AI Infrastructure — Full enterprise AI stack with agents, tool servers, safety guardrails, evaluation, prompt management, observability, and a Platform tenant chart whose ModelGateway is the stack's model path..
- 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 and the Platform tenant chart whose ModelGateway is its model path.
- 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, prompt management, and the Platform tenant chart whose ModelGateway is its model path.