Daydreams Framework

TypeScript framework for building stateful AI agents with composable contexts.

⚠️ Alpha Software: Expect breaking changes. API not yet stable.

What Makes Daydreams Different?

Composable Contexts - the key innovation that sets Daydreams apart.

Most AI frameworks treat conversations as stateless. Daydreams provides isolated, stateful workspaces that can be composed together for complex behaviors:

// Single context
const chatContext = context({ type: "chat" });

// Composed contexts - combine functionality
const customerServiceContext = context({ type: "customer-service" })
  .use(state => [
    { context: accountContext, args: { customerId: state.args.customerId } },
    { context: ticketContext, args: { customerId: state.args.customerId } }
  ]);

Result: The LLM automatically gets access to chat, account, AND ticket data in a single conversation.

Framework Features

FeatureDescriptionBenefit
Composable ContextsCombine isolated workspaces with .use()Modular, reusable agent behaviors
Stateful MemoryPersistent memory per context instanceAgents that truly remember conversations
Action ScopingContext-specific capabilities via .setActions()Precise control over agent abilities
Multi-User IsolationSeparate context instances per user/sessionSecure, scalable multi-tenant support
Real-time StreamingXML-based LLM response parsingImmediate action execution
TypeScript-firstFull type safety across all componentsBetter developer experience
Model AgnosticWorks with any AI SDK providerFlexibility in model choice
Extension SystemPre-built integrations (Discord, Twitter, etc.)Rapid development

Architecture Overview

Daydreams agents are built from four core components:

// Building blocks work together
const agent = createDreams({
  model: openai("gpt-4o"),
  
  contexts: [customerContext],  // Stateful workspaces
  actions: [linkAccount],       // What agent can do  
  inputs: [discordMessage],     // How to listen
  outputs: [emailReply],        // How to respond
});

Flow: Input triggers agent → LLM reasons with context data → Actions execute → Outputs communicate → Memory persists

Get Started

🚀 Quickstart

Your First Agent - Build a customer service agent that showcases contexts, composition, and action scoping

📚 Learn the Concepts

🏗️ System Architecture

🔧 Advanced Topics

💻 Examples & Tutorials