Daydreams - AI Agent Framework

February 6, 2026 ยท View on GitHub

dreams

Daydreams - AI Agent Framework

Notice: This agent framework is no longer the core focus as features are already obsolete.

The Daydreams core focus is on Agentic Commerce and not the agent harness.

Check out the lucid-agents repo: https://github.com/daydreamsai/lucid-agents

We recommend the Pi agent harness for building agents and incorporating lucid-agents in it.

Finally, TypeScript agents that scale and compose

๐ŸŒ Website โ€ข โšก Quick Start โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ’ฌ Discord

Documentation License: MIT TypeScript GitHub stars

๐ŸŽฏ The Problem Every AI Developer Faces

You build an AI agent. It works great in testing. Then you need to add more features and...

โŒ Context switching breaks existing functionality
โŒ State management becomes a nightmare
โŒ Memory doesn't persist across sessions
โŒ Code becomes a tangled mess of prompts and logic

Sound familiar? You're not alone. This is why most AI agents never make it to production.

โšก The Solution: Composable Context Architecture

Daydreams is the first AI framework with composable contexts - isolated workspaces that combine for complex behaviors. Build agents that remember, learn, and scale with true memory, MCP integration, and TypeScript-first design.

๐ŸŒ Dreams Router - Universal AI Gateway

Access any AI model through one API with built-in authentication and payments:

import { dreamsRouter } from "@daydreamsai/ai-sdk-provider";

// Use any model from any provider
const models = [
  dreamsRouter("openai/gpt-4o"),
  dreamsRouter("anthropic/claude-3-5-sonnet-20241022"),
  dreamsRouter("google-vertex/gemini-2.5-flash"),
  dreamsRouter("groq/llama-3.1-405b-reasoning"),
];

// Pay-per-use with USDC micropayments (no subscriptions)
const { dreamsRouter } = await createDreamsRouterAuth(account, {
  payments: { amount: "100000", network: "base-sepolia" }, // \$0.10 per request
});

Features:

  • Universal Access - OpenAI, Anthropic, Google, Groq, xAI, and more
  • x402 Payments - Pay-per-use with USDC micropayments
  • OpenAI Compatible - Works with existing OpenAI SDK clients
  • Automatic Fallbacks - Built-in provider redundancy

๐ŸŒ Live Service: router.daydreams.systems โ€ข ๐Ÿ“– Router Docs โ€ข โšก Router Quickstart

๐ŸŒŸ The Power of Context Composition

Unlike other frameworks, Daydreams lets you compose contexts using .use() - creating powerful agents from modular components:

import { createDreams, context, action } from "@daydreamsai/core";
import { openai } from "@ai-sdk/openai";

// Base analytics context - tracks user behavior
const analyticsContext = context({
  type: "analytics",
  create: () => ({ events: [], sessions: 0 }),
}).setActions([
  action({
    name: "trackEvent",
    schema: { event: z.string() },
    handler: async ({ event }, ctx) => {
      ctx.memory.events.push({ event, timestamp: Date.now() });
      return { tracked: true };
    },
  }),
]);

// Customer support context that composes with analytics
const supportContext = context({
  type: "support",
  schema: z.object({
    customerId: z.string(),
    tier: z.enum(["free", "premium"]),
  }),
  create: () => ({ tickets: [] }),
})
  // ๐ŸŒŸ The magic: compose contexts together
  .use((state) => [
    { context: analyticsContext, args: { userId: state.args.customerId } },
    // Conditional composition based on customer tier
    ...(state.args.tier === "premium" ? [{ context: premiumContext }] : []),
  ])
  .instructions(
    (state) =>
      `You are a ${state.args.tier} customer support agent. Track all interactions.`
  );

// Agent automatically gets ALL composed functionality
const agent = createDreams({
  model: openai("gpt-4o"),
  contexts: [supportContext],
});

// Customer gets support + analytics + premium features (if applicable)
await agent.send({
  context: supportContext,
  args: { customerId: "alice", tier: "premium" },
  input: "I need help with billing",
});

Result: Your agent seamlessly combines customer support, analytics tracking, and premium features in a single conversation. No manual integration required.

๐Ÿ”Œ Universal MCP Integration

Connect to any Model Context Protocol server for instant access to external tools:

import { createMcpExtension } from "@daydreamsai/mcp";

const agent = createDreams({
  extensions: [
    createMcpExtension([
      {
        id: "filesystem",
        transport: {
          type: "stdio",
          command: "npx",
          args: ["@modelcontextprotocol/server-filesystem", "./docs"],
        },
      },
      {
        id: "database",
        transport: {
          type: "stdio",
          command: "npx",
          args: ["@modelcontextprotocol/server-sqlite", "./data.db"],
        },
      },
    ]),
  ],
});

// Use MCP tools in any action
const searchAction = action({
  name: "search-docs",
  handler: async ({ query }, ctx) => {
    // Read files via MCP
    const docs = await ctx.callAction("mcp.listResources", {
      serverId: "filesystem",
    });

    // Query database via MCP
    const results = await ctx.callAction("mcp.callTool", {
      serverId: "database",
      name: "query",
      arguments: { sql: `SELECT * FROM docs WHERE content LIKE '%${query}%'` },
    });

    return { docs, results };
  },
});

Result: Your agent instantly gets file system access, database querying, web scraping, 3D rendering, and more through the growing MCP ecosystem.

๐Ÿš€ Get Your Agent Running in 60 Seconds

npm install @daydreamsai/core @ai-sdk/openai zod
import { createDreams, context, action } from "@daydreamsai/core";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";

// Define a simple weather context
const weatherContext = context({
  type: "weather",
  create: () => ({ lastQuery: null }),
}).setActions([
  action({
    name: "getWeather",
    schema: z.object({ city: z.string() }),
    handler: async ({ city }, ctx) => {
      ctx.memory.lastQuery = city;
      // Your weather API logic here
      return { weather: `Sunny, 72ยฐF in ${city}` };
    },
  }),
]);

// Create your agent
const agent = createDreams({
  model: openai("gpt-4o"),
  contexts: [weatherContext],
});

// Start chatting!
await agent.send({
  context: weatherContext,
  input: "What's the weather in San Francisco?",
});

That's it! Your agent is running with persistent memory and type-safe actions.

Or scaffold a complete project:

npx create-daydreams-agent my-agent
cd my-agent && npm run dev

๐Ÿ”ฅ Why Developers Are Switching to Daydreams

๐Ÿ—๏ธ Traditional AI Frameworksโšก Daydreams
Monolithic agent designComposable context architecture
Memory resets between sessionsPersistent memory across restarts
Manual state managementAutomatic context isolation
Complex integration setupNative MCP support
JavaScript with types bolted onTypeScript-first design

โœจ Enterprise-Grade Features

๐Ÿงฉ Composable Contexts - Build complex agents from simple, reusable contexts
๐Ÿ”Œ Native MCP Support - Universal access to external tools and services
๐Ÿ’พ Persistent Memory - True stateful agents that remember across sessions
โšก Full TypeScript - Complete type safety with excellent developer experience
๐ŸŽฏ Context Isolation - Automatic separation of user data and conversations
๐Ÿ”ง Action Scoping - Context-specific capabilities and permissions
๐ŸŒ Universal Runtime - Works in Node.js, browsers, Deno, Bun, and edge functions
๐Ÿ—๏ธ Modular Extensions - Clean plugin architecture for platforms and services
๐Ÿ“Š Full Explainability - Understand every decision your agent makes

๐Ÿ—๏ธ Core Architecture

Context System

Isolated stateful workspaces for different conversation types:

const userContext = context({
  type: "user",
  schema: z.object({ userId: z.string() }),
  create: () => ({ preferences: {}, history: [] }),
  render: (state) =>
    `User: ${state.args.userId} | History: ${state.memory.history.length} items`,
});

Memory System

Dual-tier storage with automatic persistence:

  • Working Memory: Temporary execution state (inputs, outputs, actions)
  • Context Memory: Persistent data defined by your create() function

Action System

Type-safe functions with context access and schema validation:

const savePreference = action({
  name: "save-preference",
  description: "Save a user preference",
  schema: z.object({ key: z.string(), value: z.string() }),
  handler: async ({ key, value }, ctx) => {
    ctx.memory.preferences[key] = value;
    return { saved: `${key} = ${value}` };
  },
});

Extension System

Modular integrations for platforms and services:

import { discordExtension } from "@daydreamsai/discord";
import { supabaseExtension } from "@daydreamsai/supabase";

const agent = createDreams({
  extensions: [
    discordExtension({ token: process.env.DISCORD_TOKEN }),
    supabaseExtension({ url: process.env.SUPABASE_URL }),
  ],
});

๐ŸŽฏ Context Patterns

Single Context - Simple & Focused

Perfect for straightforward bots:

const faqBot = context({
  type: "faq",
  instructions: "Answer questions about our product",
});

Multiple Contexts - Separate Workspaces

When you need isolated functionality:

const agent = createDreams({
  contexts: [
    chatContext, // User conversations
    gameContext, // Game sessions
    adminContext, // Admin functions
  ],
});

๐ŸŒŸ Composed Contexts - Maximum Power

This is where Daydreams excels - contexts working together:

const smartAssistant = context({
  type: "assistant",
  schema: z.object({ userId: z.string(), plan: z.enum(["free", "pro"]) }),
}).use((state) => [
  // Always include user profile
  { context: profileContext, args: { userId: state.args.userId } },
  // Always include basic analytics
  { context: analyticsContext, args: { userId: state.args.userId } },
  // Add premium features for pro users
  ...(state.args.plan === "pro" ? [{ context: premiumContext }] : []),
]);

๐Ÿ“– Learn More About Contexts โ†’

๐Ÿ”Œ MCP Integration

Daydreams provides native Model Context Protocol support through extensions:

import { createMcpExtension } from "@daydreamsai/mcp";

// Connect to any MCP server
createMcpExtension([
  // Local servers via stdio
  {
    id: "files",
    transport: { type: "stdio", command: "mcp-server", args: ["./data"] },
  },
  // Remote servers via HTTP/SSE
  {
    id: "api",
    transport: { type: "sse", serverUrl: "https://mcp-api.example.com" },
  },
]);

Popular MCP Servers:

  • Database Access: SQLite, PostgreSQL, MySQL
  • File Systems: Local files, cloud storage, git repos
  • Web Services: Search, scraping, APIs, social media
  • Developer Tools: Code execution, testing, deployment
  • Specialized: 3D rendering, image processing, analytics

๐Ÿ“– Learn More About MCP โ†’

๐Ÿ“š Documentation & Learning

๐Ÿ  Complete Documentation - Everything you need to build production agents

๐Ÿƒโ€โ™‚๏ธ Quick Start Paths

๐ŸŽฏ I want to test it myself โ†’ 5-minute quickstart
๐Ÿ› ๏ธ I want to see examples โ†’ Working examples
๐Ÿš€ I want to build something โ†’ Tutorials
๐Ÿ’ฌ I need help โ†’ Join our Discord

Essential Guides

Tutorials

๐Ÿš€ Extensions & Ecosystem

Platform Integrations

Storage & Memory

Developer Tools

๐ŸŽฏ Perfect For Your Use Case

E-commerceHealthcareFinancial ServicesDeveloper Tools
Customer service at scaleHIPAA-ready agentsCompliance-first designCode review automation
Order processing automationPatient data protectionBuilt-in risk managementDocumentation generation
Inventory managementTreatment recommendationsTransaction monitoringAPI testing assistance

๐Ÿƒโ€โ™‚๏ธ Examples

Explore working examples in examples/:

Each example includes:

  • Complete TypeScript source code
  • Step-by-step setup instructions
  • Configuration examples
  • Testing and deployment guides

๐Ÿ› ๏ธ Development

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Development setup:

git clone https://github.com/daydreamsai/daydreams.git
cd daydreams
pnpm install
./scripts/build.sh --watch
bun run packages/core  # Run tests

๐Ÿค Community & Support

๐Ÿ“ˆ Join 1,000+ Developers Building Better AI

Companies using Daydreams:
E-commerce platforms โ€ข Healthcare providers โ€ข Financial institutions โ€ข Developer tools

Get Help & Connect

๐Ÿ’ฌ Discord Community - Get help from the team and community
๐Ÿ“– Documentation - Comprehensive guides and examples
๐Ÿ› GitHub Issues - Bug reports and feature requests
๐Ÿ“ง Direct Support - Direct line to our engineering team

โœจ Ready to Build AI Agents That Actually Work?

โญ Star this repo โ€ข ๐Ÿš€ Try Daydreams now โ€ข ๐Ÿ’ฌ Join Discord


MIT Licensed โ€ข Built with โค๏ธ by the Daydreams team