Skip to content

Example Index

Runnable examples are located in the examples/ directory, organized by difficulty: 01-basics, 02-patterns, 03-advanced. Below is a summary with links to the corresponding code (GitHub: https://github.com/waht41/rejelly).

01 · Basics

DescriptionCode Location
Chat Agent: Multi-turn conversational flow; uses reborn + equipMemory inside an Agent to manage conversation state, rebuilding the Prompt from current state each round.examples/01-basics/chat-agent/ · Entry index.ts
Multi-model Agent: Multi-modal input (image/video); passes structured ContentPart[] via equipInstruction.examples/01-basics/multi-model-agent/ · Core multi-model-agent.ts
MCP Integration: Connects to MCP Server via @rejelly/adapter-mcp, working with equipResource / equipMCP.examples/01-basics/mcp-integration/ · Entry index.ts

02 · Patterns

DescriptionCode Location
Router: Intent recognition + Zod-structured routing decisions, dispatching to sub-agents via native switch.examples/02-patterns/router-agent/ · Logic router-agent.ts
Coding Agent: A minimal coding agent inside a sandbox workspace — explore → edit → run → verify. File/shell tools are native ToolDefinition objects. Logging and human approval are mounted per-tool as tool middleware (read-only passes, write requires gate). A single promptChat drives the full tool loop.examples/02-patterns/coding-agent/ · Core coding-agent.ts, tools tools.ts

03 · Advanced

DescriptionCode Location
Fan-in / Fan-out: Parallel Worker Agents (Promise.all), then aggregated into a single Summarizer.examples/03-advanced/fan-in-fan-out/ · Entry index.ts
Time-travel: dumpSnapshot / restoreSnapshot with trace replay (reproduction path without extra LLM calls).examples/03-advanced/time-travel/ · dump-example.ts, restore-example.ts
Graph Policy: A LangGraph-style writer–critic graph (typed state, conditional edges, cycles, critic concurrent fan-out) implemented as a custom prompt policy. Built on createAgentPolicy + executeTurn + executeValidation — core has zero knowledge of graphs. Uses usedTurnSteps for graceful degradation under budget constraints.examples/03-advanced/graph-policy/ · Runtime graph-policy.ts, specific graph writer-critic-agent.ts

Shared & Running

DescriptionCode Location
Shared models and pricing: OpenAI adapter, calculateCost and model-pricing table shared across examples.examples/shared/ · e.g. openai-model.ts, model-pricing.ts
Unified start script: Select examples by module name (matches pnpm run start in the README).examples/scripts/run.ts

Each subdirectory's README.md (some also include README.zh-CN.md) has run commands and detailed explanations. Install dependencies at the examples/ root, then follow the corresponding README.

Released under the Apache License 2.0. llm.txt