# Comparison

Caskada stands out in the AI framework landscape by prioritizing simplicity, modularity, and developer experience over feature bloat.

## Quick Framework Comparison

| Framework   | Core Abstraction | App-Specific Wrappers | Vendor-Specific Wrappers | Lines  | Size   |
| ----------- | ---------------- | --------------------- | ------------------------ | ------ | ------ |
| **Caskada** | ✨                | ❌                     | ❌                        | \~300  | \~15KB |
| LangChain   | ⚠️               | ✅                     | ✅                        | \~500K | \~50MB |
| LlamaIndex  | ⚠️               | ✅                     | ✅                        | \~200K | \~25MB |
| Haystack    | ⚠️               | ✅                     | ✅                        | \~100K | \~20MB |

## Caskada's Philosophy Recap

Before diving into deeper comparisons, let's reiterate Caskada's core tenets:

* **Minimalist Core:** A tiny codebase (\~300 lines) providing essential abstractions (`Node`, `Flow`, `Memory`).
* **Graph-Based Abstraction:** Uses nested directed graphs to model application logic, separating data flow (`Memory`) from computation (`Node`).
* **Zero Dependencies:** The core framework has no external dependencies, offering maximum flexibility.
* **No Vendor Lock-in:** Encourages using external utilities directly, avoiding framework-specific wrappers for APIs or databases.
* **Agentic Coding Friendly:** Designed to be intuitive for both human developers and AI assistants collaborating on code.
* **Composability:** Flows can be nested within other flows, enabling modular design.

## Feature Comparison Matrix

| Feature                   | Caskada            | LangChain         | LangGraph            | CrewAI                    | AutoGen               | PocketFlow       |
| ------------------------- | ------------------ | ----------------- | -------------------- | ------------------------- | --------------------- | ---------------- |
| **Core Abstraction**      | Nodes & Flows      | Chains & Agents   | State Graphs         | Agents & Crews            | Conversational Agents | Nodes & Flows    |
| **Dependencies**          | None               | Many              | Many (via LangChain) | Several                   | Several               | None             |
| **Codebase Size**         | Tiny (\~300 lines) | Large             | Medium               | Medium                    | Medium                | Tiny (100 lines) |
| **Flexibility**           | High               | Medium            | Medium               | Low                       | Medium                | High             |
| **Built-in Integrations** | None               | Extensive         | Via LangChain        | Several                   | Several               | None             |
| **Learning Curve**        | Moderate           | Steep             | Very Steep           | Moderate                  | Moderate              | Moderate         |
| **Primary Focus**         | Graph Execution    | Component Library | State Machines       | Multi-Agent Collaboration | Conversational Agents | Graph Execution  |

## Caskada vs. LangChain

* **Core Abstraction:** LangChain offers a vast array of components (Chains, LCEL, Agents, Tools, Retrievers, etc.). Caskada focuses solely on the Node/Flow/Memory graph.
* **Dependencies & Size:** LangChain has numerous dependencies depending on the components used, leading to a larger footprint. Caskada core is dependency-free.
* **Flexibility vs. Opinionation:** LangChain provides many pre-built components, which can be faster but potentially more opinionated. Caskada offers higher flexibility, requiring developers to build or integrate utilities themselves.
* **Vendor Integrations:** LangChain has extensive built-in integrations. Caskada intentionally avoids these in its core.
* **Learning Curve:** LangChain's breadth can be overwhelming. Caskada's core is small, but mastering its flexible application requires understanding the graph pattern well.

## Caskada vs. LangGraph

* **Core Abstraction:** LangGraph is built on LangChain and specifically focuses on cyclical graphs using a state-based approach. Caskada uses action-based transitions between nodes within its graph structure.
* **Dependencies & Size:** LangGraph inherits LangChain's dependencies. Caskada remains dependency-free.
* **Flexibility vs. Opinionation:** LangGraph is tied to the LangChain ecosystem and state management patterns. Caskada offers more fundamental graph control.
* **Vendor Integrations:** Inherited from LangChain. Caskada has none.
* **Learning Curve:** Requires understanding LangChain concepts plus LangGraph's state model. Caskada focuses only on its core abstractions.

## Caskada vs. CrewAI

* **Core Abstraction:** CrewAI provides higher-level abstractions like Agent, Task, and Crew, focusing on collaborative agent workflows. Caskada provides the lower-level graph building blocks upon which such agent systems *can be built*.
* **Dependencies & Size:** CrewAI has dependencies related to its agent and tooling features. Caskada is minimal.
* **Flexibility vs. Opinionation:** CrewAI is more opinionated towards specific multi-agent structures. Caskada is more general-purpose.
* **Vendor Integrations:** CrewAI integrates with tools and LLMs, often via LangChain. Caskada does not.
* **Learning Curve:** CrewAI's high-level concepts might be quicker for specific agent tasks. Caskada requires building the agent logic from its core components.

## Caskada vs. AutoGen

* **Core Abstraction:** AutoGen focuses on conversational agents (`ConversableAgent`) and multi-agent frameworks, often emphasizing automated chat orchestration. Caskada focuses on the underlying execution graph.
* **Dependencies & Size:** AutoGen has a core set of dependencies, with optional ones for specific tools/models. Caskada core has none.
* **Flexibility vs. Opinionation:** AutoGen is geared towards conversational agent patterns. Caskada is a more general graph execution engine.
* **Vendor Integrations:** AutoGen offers integrations, particularly for LLMs. Caskada avoids them.
* **Learning Curve:** AutoGen's conversational focus might be specific. Caskada's graph is general but requires explicit construction.

## Relationship to PocketFlow

Caskada originated as a fork of [PocketFlow](https://arxiv.org/abs/2504.03771), inheriting its core philosophy of minimalism and a graph-based abstraction. However, Caskada has evolved with some key differences:

* **Core Abstraction & Batching**: [PocketFlow](https://arxiv.org/abs/2504.03771) included many specialized classes for async operations and batching (e.g., `AsyncNode`, `BatchNode`, `AsyncBatchNode`, `AsyncParallelBatchNode`, `AsyncFlow`, `BatchFlow`, `AsyncBatchFlow`, `AsyncParallelBatchFlow`). Caskada simplifies this by removing all of these specialized classes from its core. Instead, it relies on standard `Node` lifecycle methods (which are inherently `async`-capable) combined with `Flow` (or `ParallelFlow`). Batch-like fan-out operations are achieved using multiple `trigger` calls within a single node's `post` method.
* **State Management (`Memory`)**: While both use a shared store, Caskada's `Memory` object now has a more refined distinction between `global` and `local` stores. The `local` store is primarily populated via `forkingData` during `trigger` calls, crucial for managing branch-specific context. This eliminates the need for [PocketFlow](https://arxiv.org/abs/2504.03771)'s separate `Params` concept and simplifies the `Memory` model, removing the complexities that `Batch*` classes in [PocketFlow](https://arxiv.org/abs/2504.03771) tried to solve. Caskada's `Memory` is created with enhanced proxy mechanisms for attribute access and isolation.
* **Focus:** Caskada sharpens the focus on the fundamental `Node`, `Flow`, and `Memory` abstractions as the absolute core, reinforcing the idea that patterns like batching or parallelism are handled by how flows orchestrate standard nodes rather than requiring specialized node types.

Essentially, Caskada refines [PocketFlow](https://arxiv.org/abs/2504.03771)'s minimalist approach, aiming for an even leaner core by handling execution patterns like batching and parallelism primarily at the `Flow` orchestration level. Caskada also emphasizes a more consistent and refined API across its Python and TypeScript implementations, particularly for state management and flow execution.

On top of that, Caskada has been designed to be more agentic-friendly, with a focus on building flows that can be used by both humans and AI assistants. Its code is more readable and maintainable, prioritizing developer experience over an arbitrarily defined amount of lines of code.

## Conclusion: When to Choose Caskada?

Caskada excels when you prioritize:

* **Minimalism and Control:** You want a lightweight core without unnecessary bloat or dependencies.
* **Flexibility:** You prefer to integrate your own utilities and avoid framework-specific wrappers.
* **Understanding the Core:** You value a simple, fundamental abstraction (the graph) that you can build upon.
* **Avoiding Vendor Lock-in:** You want the freedom to choose and switch external services easily.
* **Agentic Coding:** You plan to collaborate with AI assistants, leveraging a framework they can easily understand and manipulate.

If you need extensive pre-built integrations, higher-level abstractions for specific patterns (like multi-agent collaboration out-of-the-box), or prefer a more opinionated framework, other options might be a better fit initially. However, Caskada provides the fundamental building blocks to implement *any* of these patterns with maximum transparency and control.
