- Home
- Skills
- Agents & Orchestration
- Minimal Extensible Agent Loop
More screenshots
Works with the AI Agents you already use
Minimal Extensible Agent Loop
This TypeScript package provides a minimal, extensible agent runtime designed for developers who need to build or extend coding-agent loops without the bloat of a full framework.
$9
/moSubscription · cancel anytime
Secure checkout via Stripe
- Always the latest version
- Delivered live to your agent via MCP
- Cancel anytime, access ends at period end
Minimal Extensible Agent Loop
Example session with this skill installed
Build a TypeScript agent loop that requires human approval for any 'write_file' tool calls and terminates if the agent hits 10 consecutive errors.
- Read your context and instructions
- Compiled the minimal extensible agent
I have initialized a minimal agent loop with a custom security door for write approvals and a guard configuration to prevent error storms.
Agent Runtime Configuration
import {
runIMLoop,
ToolRegistry,
createConfig,
createWriteApprovalDoor
} from './src/index.js';
// 1. Setup registry with security door
const registry = new ToolRegistry();
registry.registerDoor(
createWriteApprovalDoor({
handler: async (req) => {
console.log(`Approval requested for: ${req.toolName}`);
// In a real app, this triggers a UI signal
return 'approved';
}
})
);
// 2. Configure guards
const config = createConfig({
maxConsecutiveToolErrors: 10,
maxSteps: 50,
});
// 3. Execution entry point
const result = await runIMLoop({
config,
registry,
streamChat: myModelClient,
url: 'https://api.openai.com/v1/chat/completions',
model: 'gpt-4',
systemPrompt: 'File manager agent.',
sessionId: 'session-123'
});
console.log(`Loop terminated. Reason: ${result.reason}`);
Next steps
- Implement the
streamChatfunction to connect to your LLM provider. - Connect the
signalGateto your front-end to handleapproval.requestevents asynchronously. - Run
npm testto verify that the error-rate guard trips as expected in your environment.
Subscription · always the latest version
- Secure checkout via Stripe
- Cancel anytime
- Delivered live via MCP
About this skill
This TypeScript package provides a minimal, extensible agent runtime designed for developers who need to build or extend coding-agent loops without the bloat of a full framework. It solves the difficult problems of agent safety and multi-session management: termination guards, pluggable security doors, per-session approval isolation, and a unified signal gate for multiple front-ends. The codebase focuses on the loop itself rather than specific tools or prompt templates.
Small by design, the package contains zero runtime dependencies and 247 tests covering five critical safety invariants. It ensures the loop cannot run away, prevents tripped states from leaking into the model's prompt, and enforces security doors before every tool execution. The signal gate acts as a single source of truth for governance, allowing you to connect CLI, web, or mobile front-ends to a shared core without duplicating complex session locking or approval logic.
What it does
- Enforces termination guards by monitoring tokens, steps, tool-call rates, and consecutive error thresholds to prevent runaway loops.
- Isolates session state using a per-session
ApprovalStoreto ensure tool permissions and grants do not leak between users or turns. - Secures tool calls through pluggable security doors that can trigger human-in-the-loop approvals or block dangerous operations.
- Relays front-end communication via a signal gate that manages turn serialization, command processing, and event broadcasting.
- Handles OpenAI-style streaming with built-in SSE parsing, tool-call accumulation, and bounded retry logic for 429/503 errors.
How it works
- Initialize the Registry by registering your system tools and security doors (e.g., file system access or write approvals).
- Define the Model Client by supplying a
streamChatfunction that conforms to the OpenAI-compatible streaming contract. - Invoke the Loop using
runIMLoopwith a specificsessionIdand configuration to start the turn. - Manage Signals by subscribing to the signal gate for text deltas, approval requests, and session updates to update your UI.
Frameworks & tools
Built for Node.js 18+ environments using TypeScript. It targets ES2022 and relies on standard web APIs like AbortSignal and node:crypto.
Why this beats prompting it yourself
Prompting an agent to "be safe" or "stop eventually" is unreliable and prone to jailbreaking. This skill implements safety at the runtime level with hard-coded guards and isolated memory that the model cannot bypass or ignore.
Use cases
- Building a secure IDE agent that requires explicit approval before writing to sensitive production directories.
- Creating a multi-user agent service where session isolation and turn queueing must be handled by the backend.
- Wrapping an existing agent in a new front-end (like Slack or a web dashboard) without rebuilding the security logic.
- Adding runtime protection to an agent that currently lacks bounds on costs or execution steps.
Known limitations
The package is TypeScript-only and does not include built-in tools (like bash or search), prompt assets, or LLM provider clients. It lacks context compression and does not support hot-plugging tools or doors at runtime.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.
TypeScript only, Node.js 18+. No built-in tools or prompt content. OpenAI wire format only. No hot-plugging of tools. No context compression or sub-agent tree support.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 23 days ago
- Software
Node.js 18+npmtsc
Git