Skip to content

Base

Architecture ABC

The contract every architecture in the library implements.

Architecture

Architecture(llm: BaseChatModel | None = None, **kwargs: Any)

Bases: ABC

Base class for every agentic pattern in this library.

Subclasses MUST implement build() and run(). They MAY override diagram() and explain() — both have sensible defaults.

Source code in src/agentic_architectures/architectures/base.py
def __init__(self, llm: BaseChatModel | None = None, **kwargs: Any) -> None:
    from agentic_architectures.llm.factory import get_llm

    self.llm = llm if llm is not None else get_llm()
    self.config = kwargs

build abstractmethod

build() -> CompiledStateGraph

Compile and return the LangGraph for this architecture.

Source code in src/agentic_architectures/architectures/base.py
@abstractmethod
def build(self) -> CompiledStateGraph:
    """Compile and return the LangGraph for this architecture."""

run abstractmethod

run(task: str, **kwargs: Any) -> ArchitectureResult

Execute the architecture on a task and return a standardized result.

Source code in src/agentic_architectures/architectures/base.py
@abstractmethod
def run(self, task: str, **kwargs: Any) -> ArchitectureResult:
    """Execute the architecture on a task and return a standardized result."""

diagram

diagram() -> str

Return a Mermaid diagram string for the compiled graph.

Source code in src/agentic_architectures/architectures/base.py
def diagram(self) -> str:
    """Return a Mermaid diagram string for the compiled graph."""
    from agentic_architectures.ui.diagram import graph_to_mermaid

    return graph_to_mermaid(self.build())

explain

explain() -> str

Return the theory section (markdown) for this architecture.

Source code in src/agentic_architectures/architectures/base.py
def explain(self) -> str:
    """Return the theory section (markdown) for this architecture."""
    return self.description or self.__doc__ or "(no description provided)"

ArchitectureResult

The standardized return type from every Architecture.run().

ArchitectureResult dataclass

ArchitectureResult(output: str, state: dict[str, Any] = dict(), trace: list[dict[str, Any]] = list(), metadata: dict[str, Any] = dict())

Standardized return type so notebooks can render results uniformly.