Lesson 08: Agent Loops, Skills and REPL
Build autonomous agent loops with modular skill directories, human-in-the-loop approval gates, and the AgentLauncher interactive REPL with slash commands.
1. Why This Feature Exists
Production agents need more than one-off tool calls: they need persistent skills, interactive REPL environments for debugging, and human checkpoints to prevent unintended actions.
2. Key Symbols and Exports
3. Implementation Walkthrough
import {
ProviderType,
resolveProvider,
initializeClient,
loadCredentials,
getDefaultModel,
AgentLauncher
} from 'merci-sdk';
import { loadSkillsFromDirectory } from 'merci-sdk/tools';
const PROVIDER = resolveProvider();
const { client } = await initializeClient({ provider: PROVIDER, options: loadCredentials({ provider: PROVIDER }) });
// 1. Load modular skills from directory
const skills = await loadSkillsFromDirectory('examples/skills');
// 2. Instantiate AgentLauncher REPL
const launcher = new AgentLauncher(client, PROVIDER, getDefaultModel({ provider: PROVIDER }))
.withSkills(skills)
.withSystemMessage('You are a helpful coding assistant equipped with specialized skills.');
// 3. Start interactive session (supports /help, /skills, /clear, /exit)
console.log('Starting interactive agent REPL...');
// await launcher.runInteractive();4. Wire and Telemetry Mechanics
Skills are registered as tools with descriptions extracted from SKILL.md. AgentLauncher handles stdin readline parsing and matches slash commands before dispatching to the LLM.
5. Run the Example
Execute the runnable example directly from the repository root:
node examples/07_agent_loop.mjsRead the full example: examples/07_agent_loop.mjs →