Autonomous agent framework template - Build AI agents with tool usage, memory, and observability
π¦ Starter Template β This is a starter template for cloning, not an npm package. Use
git cloneor download the source to create your own AI agent application. This package is markedprivate: trueand is not published to npm.
# Clone template
npx degit dcyfr/dcyfr-ai-agents my-agent
cd my-agent
# Install and run
npm install
npm run dev
# β
Agent running, ready to process tasks| Package | Purpose | Type |
|---|---|---|
| @dcyfr/ai | Core AI framework | npm package |
| @dcyfr/ai-nodejs | Node.js starter | Template |
| @dcyfr/ai-api | REST API template | Template |
| dcyfr-labs | Production Next.js app | Application |
@dcyfr/ai-agents is a production-ready starter template for building autonomous AI agents with tool usage, memory management, and comprehensive observability.
@dcyfr/ai-agents is part of the DCYFR Labs template ecosystem for production-ready AI applications.
- DCYFR is a registered trademark of DCYFR Labs.
- Primary domain: www.dcyfr.ai
- Trademark guidance: ../TRADEMARK.md
- Licensing details: LICENSE
Perfect for developers building AI assistants, research agents, workflow automation, or any application requiring autonomous decision-making with external tool integration.
- π€ Building autonomous AI agents that make multi-step decisions
- π οΈ Need type-safe tool usage with Zod validation
- π§ Require dual memory architecture (short-term + long-term)
- π‘ Want full observability into agent behavior
- π Need production-grade error handling and resilience
- πΌ Building customer service bots, research assistants, or code generation tools
- Simple chat interface needed β Use Vercel AI SDK or LangChain Chat
- Browser automation required β Use Playwright with custom orchestration
- Low-latency streaming (<100ms) β Use Vercel AI SDK with streaming
- Complex agent orchestration β Use LangGraph or AutoGPT
- Just learning AI β Start with simpler examples before autonomous agents
π Table of Contents
-
π€ Autonomous Agent Loop - Multi-step reasoning with configurable iteration limits
- Thought β Action β Observation cycle
- Automatic decision-making flow
- Graceful termination when goals are met
-
π οΈ Type-Safe Tool System - Production-ready tool framework
- Zod schema validation for all inputs
- TypeScript generics for full type safety
- Built-in tools: calculator, search, time
- Easy custom tool creation with examples
-
π§ Dual Memory Architecture - Flexible persistence options
- Short-term: In-memory with configurable size limits
- Long-term: File-based with auto-save and import/export
- Async API compatible with any storage backend
- Perfect for conversation history and learned knowledge
-
π‘ Event-Driven Observability - Complete visibility into agent behavior
- Real-time events:
start,step,tool_call,tool_result,error,finish - Multiple event listeners support
- Custom monitoring and logging integrations
- Debug agent behavior in development
- Real-time events:
-
π Production-Grade Error Handling - Resilient agent execution
- Try-catch wrappers around all tool executions
- Graceful degradation on failures
- Detailed error propagation in results
- Automatic Error/non-Error normalization
-
π Developer Experience - Built for productivity
- TypeScript-first: 100% strict mode, full IntelliSense
- 95%+ test coverage: Every feature thoroughly tested
- Zero config: Works out of the box
- 3 complete examples: Customer service, research, code generation
- β Semantic versioning with automated releases (changesets)
- β ESLint + Prettier for code quality
- β GitHub Actions for CI/CD
- β MIT License for commercial use
- β Comprehensive documentation with API reference
- β Security audited production dependencies
Perfect for building:
- π€ Customer service chatbots with tool integration
- π¬ Research assistants that search and synthesize information
- π» Code generation agents with file system access
- π Workflow automation with multi-step reasoning
- π Content creation agents with fact-checking tools
- π― Task planning and execution systems
# Clone or use as template
git clone https://github.com/dcyfr/dcyfr-ai-agents.git
cd dcyfr-ai-agents
# Install dependencies
npm install
# Run example agent
npm run example:customer-service
# Run tests
npm test
# Build for production
npm run buildnpx degit dcyfr/dcyfr-ai-agents my-project
cd my-project
npm installimport {
Agent,
calculatorTool,
searchTool,
ShortTermMemory,
} from "@dcyfr/ai-agents";
// Create an agent
const agent = new Agent({
name: "Assistant",
description: "Helpful AI assistant",
tools: [calculatorTool, searchTool],
memory: new ShortTermMemory(),
maxIterations: 10,
});
// Run the agent
const result = await agent.run(
"Calculate 15 * 23 and search for information about AI",
);
console.log(result.output);
console.log(`Completed in ${result.iterations} steps`);The agent follows a continuous reasoning loop with tool integration and memory persistence:
sequenceDiagram
participant User
participant Agent
participant Tools
participant Memory
participant LLM
User->>Agent: Initialize with task
Agent->>Tools: Register available tools
Agent->>Memory: Load context
loop Reasoning Loop (max iterations)
Agent->>LLM: Thought (Plan next action)
LLM-->>Agent: Decision
alt Tool Required
Agent->>Tools: Action (Execute tool)
Tools-->>Agent: Observation (Result)
Agent->>Memory: Store interaction
else Goal Met
Agent->>Memory: Save final state
Agent-->>User: Return result
end
end
The main agent class that orchestrates:
- Decision-making loop
- Tool execution
- Memory management
- Event emission
const agent = new Agent({
name: "My Agent",
description: "What this agent does",
maxIterations: 10,
temperature: 0.7,
verbose: true,
tools: [
/* tools */
],
memory: new ShortTermMemory(),
listeners: [(event) => console.log(event)],
});Type-safe tools with Zod validation:
import { z } from "zod";
import type { Tool } from "@dcyfr/ai-agents";
const myTool: Tool<{ query: string }, { result: string }> = {
name: "my_tool",
description: "Description for the agent",
inputSchema: z.object({
query: z.string().min(1),
}),
async execute(input) {
// Tool logic here
return { result: `Processed: ${input.query}` };
},
};Two memory implementations:
Short-term (in-memory):
const memory = new ShortTermMemory(100); // Max 100 entries
await memory.save("key", "value");
const value = await memory.get("key");Long-term (file-based):
const memory = new LongTermMemory({
storagePath: "./agent-memory.json",
autoSaveInterval: 5000, // Auto-save every 5s
});
await memory.load();
await memory.save("knowledge", { learned: "data" });
await memory.persist();Monitor agent execution:
const agent = new Agent({
// ... config
listeners: [
(event) => {
switch (event.type) {
case "start":
console.log("Agent started:", event.data.input);
break;
case "tool_call":
console.log("Calling tool:", event.data.tool);
break;
case "finish":
console.log("Agent finished:", event.data.output);
break;
}
},
],
});import { Agent, searchTool, getCurrentTimeTool } from "@dcyfr/ai-agents";
const agent = new Agent({
name: "Customer Support",
description: "Helpful customer service agent",
tools: [searchTool, getCurrentTimeTool],
});
const result = await agent.run("Help me track my order #12345");import {
Agent,
searchTool,
calculatorTool,
LongTermMemory,
} from "@dcyfr/ai-agents";
const memory = new LongTermMemory({ storagePath: "./research.json" });
await memory.load();
const agent = new Agent({
name: "Researcher",
description: "Research assistant",
tools: [searchTool, calculatorTool],
memory,
});
const result = await agent.run(
"Research AI agent frameworks and compare adoption rates",
);import { z } from "zod";
const weatherTool = {
name: "get_weather",
description: "Get current weather for a location",
inputSchema: z.object({
location: z.string(),
units: z.enum(["celsius", "fahrenheit"]).optional(),
}),
async execute(input) {
// Fetch weather from API
return {
location: input.location,
temperature: 72,
conditions: "sunny",
};
},
};
agent.registerTool(weatherTool);# Run all tests
npm test
# Watch mode
npm run test
# Coverage report
npm run test:coverage- Unit tests -
tests/unit/*.test.ts - Integration tests -
tests/integration/*.test.ts - Fixtures -
tests/fixtures/
new Agent(options)- Create agent instanceagent.registerTool(tool)- Add tool to agentagent.run(input)- Execute agent with inputagent.getState()- Get current execution stateagent.reset()- Reset agent to initial state
registry.register(tool, category?)- Register toolregistry.unregister(toolName)- Remove toolregistry.get(toolName)- Get tool by nameregistry.getAll()- Get all toolsregistry.execute(toolName, input)- Execute tool
Both ShortTermMemory and LongTermMemory implement:
save(key, value)- Store valueget(key)- Retrieve valuedelete(key)- Remove valueclear()- Clear all datakeys()- List all keys
- README - This document (Quick start, architecture, examples)
- API Reference - Comprehensive API documentation
- Examples - Complete working examples:
customer-service/- Customer support agentresearch-agent/- Research and analysis agentcode-gen-agent/- Code generation agent
- Contributing Guide - How to contribute to the project
- Security Policy - Vulnerability reporting and security practices
Agent Loop: The core execution pattern where the agent iterates through thought β action β observation cycles until completing its task or reaching the maximum iteration limit.
Tools: Functions the agent can call to interact with external systems. Each tool has:
- A unique name
- A description the agent uses to decide when to call it
- A Zod input schema for validation
- An execute function that performs the actual work
Memory: Persistent storage for the agent to save and retrieve information across runs. Use short-term for conversation context and long-term for learned knowledge.
Events: Real-time notifications of agent activity. Subscribe to events for logging, monitoring, debugging, or building custom integrations.
- π DCYFR Website: https://www.dcyfr.ai
- π§ Support Email: hello@dcyfr.ai
- π Documentation Portal: https://docs.dcyfr.ai (coming soon)
- π GitHub Organization: https://github.com/dcyfr
- π¬ Discussions: GitHub Discussions
- π Issue Tracker: GitHub Issues
- @dcyfr/ai - Core AI framework and abstractions
- @dcyfr/ai-rag - RAG (Retrieval Augmented Generation) systems
- @dcyfr/ai-code-gen - Code generation utilities
- @dcyfr/ai-graphql - GraphQL API templates
# None required - fully self-contained template
# Add your own as needed (e.g., API keys)
OPENAI_API_KEY=your-key-here # If integrating with LLM providersStrict mode enabled by default in tsconfig.json. Customize as needed.
See CONTRIBUTING.md for guidelines.
MIT Β© DCYFR
- @dcyfr/ai - Core AI framework
- @dcyfr/ai-rag - RAG systems
- @dcyfr/ai-graphql - GraphQL API
- @dcyfr/ai-code-gen - Code generation
- π§ Email: hello@dcyfr.ai
- π Website: https://www.dcyfr.ai
- π Docs: https://docs.dcyfr.ai
Built with β€οΈ by DCYFR - Making AI development accessible