Skip to content

Examples Playbook

Real-world examples covering every feature of confused-ai. Pick your level.


Full framework map (start here)

For a single narrative that walks every capability area—NorthPeak StoreOps Copilot, import cheat-sheets, architecture diagram, and links back to these tutorials—see 17 · Full framework showcase.

Runnable counterparts in the repo:

  • bun run example:showcase — LLM, sessions, workflows, pipeline, health, metrics, optional HTTP.
  • bun run example:potential — chunking, circuit breaker, rate limiter, artifacts, profiles, eval metrics, config (no LLM calls).
  • bun run example:meridian — full role intelligence platform: 6 personas, handoff, router, supervisor, consensus, RAG, HTTP server.
  • bun run example:reasoning — chain-of-thought incident triage with ReasoningManager.
  • bun run example:scheduled — nightly market digest cron with ScheduleManager.
  • bun run example:code-review — three-agent PR review pipeline with bare(), compose(), pipe().
  • bun run example:eval — CI eval regression guard with runEvalSuite + InMemoryEvalStore.

Skill Levels

LabelWho it's for
🟢 BeginnerNever used an AI framework. First time here.
🟡 IntermediateBuilt basic agents, want real-world patterns.
🔴 AdvancedProduction systems, orchestration, resilience.

All Examples

#ExampleLevelWhat you learn
01Hello World🟢Create and run your first agent
02First Custom Tool🟢Build a tool that calls a real API
03Tool with Approval🟢Ask human before executing risky actions
04Extend & Wrap Tools🟡Add middleware, caching, auth to any tool
05RAG Knowledge Base🟡Answer questions from your own documents
06Persistent Memory🟡Remember users and conversations
07Storage Patterns🟡Cache, state, and config in agents
08Multi-Agent Team🔴Specialized agents working together
09Supervisor Workflow🔴One agent delegates to many
10Database Analyst🔴Query a SQL database with natural language
11Customer Support Bot🔴Full bot: sessions + guardrails + handoff
12Observability & Hooks🟡Log, trace, and measure every agent step
13Production Resilience🔴Circuit breakers, retries, fallbacks
14MCP Filesystem Agent🔴Use Model Context Protocol tools
15Full-Stack App🔴Complete app: HTTP API + agent + RAG + storage
16Intelligent LLM Router🟡Auto-route requests to the right model by task, cost & speed
17Full framework showcase🔴Coverage map: one real-world story + every module / import path + links to 01–16
18Meridian — Role Intelligence Platform🔴Full platform demo: 6 role personas, triage handoff, router, supervisor, consensus, compose/pipe, workflows, RAG, guardrails, resilience, health, HTTP runtime
19Incident Triage Bot🔴Chain-of-thought reasoning, ReasoningManager, event streaming, NextAction loop
20Scheduled Agent Jobs🔴Cron scheduling, ScheduleManager, handler registry, run history, enable/disable
21Code Review Pipeline🔴bare(), compose(), pipe(), conditional when hand-off, lifecycle hooks
22Eval Regression Guard🟡runEvalSuite, EvalStore, custom scorer, baseline saving, CI exit code

Quick Start (30 seconds)

bash
npm install confused-ai
ts
import { createAgent } from 'confused-ai';

const agent = createAgent({
  name: 'my-first-agent',
  model: 'gpt-4o-mini',
  instructions: 'You are a helpful assistant.',
});

const result = await agent.run('What is 2 + 2?');
console.log(result.text); // "4"

Environment Variables

Most examples need these in a .env file:

bash
OPENAI_API_KEY=sk-...        # required for OpenAI models
ANTHROPIC_API_KEY=sk-...     # optional, for Claude models
GOOGLE_AI_API_KEY=...        # optional, for Gemini models

Released under the MIT License.