Skip to content

Feature Request: Pick and choose Agent functionality  #846

@stephencoffey

Description

@stephencoffey

(edit by @threepointone: see #846 (comment))

Problem

Currently, all 5 database tables are created in the Agent constructor on every instantiation:

  • cf_agents_state
  • cf_agents_schedules
  • cf_agents_queues
  • cf_agents_mcp_servers
  • cf_agents_workflows

Many agents only use a subset of these features (e.g., just state management for a simple stateful agent), but still incur the overhead of creating all tables.

Cost Impact

Cloudflare Durable Objects are billed based on storage and operations. Currently:

  • Every Agent instance creates 5 SQLite tables on instantiation
  • Many agents only use 1-2 features (e.g., just state management)
  • This results in unnecessary storage overhead and write operations

At scale (thousands of agent instances), this can lead to meaningful cost increases for users who don't need all features. Lazy table creation would ensure users only pay for storage they actually use.

Proposed Solution

  1. Lazy table creation: Create tables on-demand when features are first used, rather than upfront in the constructor

  2. New AgentConfig type: Allow explicitly disabling features via configuration, with helpful error messages if disabled features are accessed

export type AgentConfig = {
disableStatePersistence?: boolean;
disableScheduling?: boolean;
disableQueue?: boolean;
disableMcp?: boolean;
disableWorkflows?: boolean;
};

Example usage:

class MinimalAgent extends Agent<Env> {
  // Only uses state - disable everything else
  config = {
    disableScheduling: true,
    disableQueue: true,
    disableMcp: true,
    disableWorkflows: true
  };
}

Benefits

  • Reduced costs: Users only pay for storage they actually use
  • Faster initialization: Fewer SQL operations on agent startup

Implementation

I have a working implementation ready if this approach sounds reasonable. All existing tests pass, with one test helper updated to accommodate the lazy creation pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions