Skip to main content

No project description provided

Project description

agents-builder

agents-builder is a small Python framework for building retrieval-aware agents on top of LangGraph, LangChain, and MCP tools.

The package gives you a few focused primitives:

  • A base Agent that owns graph construction, LLM factories, and MCP tool loading.
  • Config-driven runtime objects via Pydantic settings models.
  • Reusable Prompt, LLMNode, ToolBasedNode, and RouterNode building blocks.
  • Lightweight support for multiple LLM backends such as Ollama and OpenRouter.

The design is intentionally narrow: compose agents from small graph nodes, keep configuration explicit, and avoid framework-heavy abstractions that hide behavior.

What This Project Contains

Core package layout:

src/agents_builder/
├── __init__.py          # Base Agent
├── constants.py         # Shared typing aliases and config path
├── exceptions.py        # Domain-specific exceptions
├── mixins.py            # Config loading helpers
├── settings.py          # Pydantic settings models
├── utils.py             # Dynamic loading, MCP caching, message helpers
├── llm/
│   ├── __init__.py
│   ├── factory.py       # LLMFactory and role-based model lookup
│   └── llm.py           # OllamaLLM / OpenRouterLLM implementations
└── langgraph/
    ├── __init__.py      # Prompt, Node, LLMNode, DeletionStrategy
    ├── nodes.py         # Ready-made retrieval/answering node types
    └── states.py        # Typed graph state

Tests are split by intent:

  • tests/unit: isolated behavior for factories, nodes, mixins, utils, and errors.
  • tests/integration: config loading and caching behavior.
  • tests/e2e: a full retrieval-answer graph wired together end to end.

Installation

This project uses uv and Python 3.12.

uv sync --group dev --all-extras

Common local commands:

make lint
make type-check
make test
make test-cov
make ci

Core Concepts

1. Agent

Subclass agents_builder.Agent and implement build_graph().

The base class already handles:

  • config storage
  • lazy graph compilation
  • LLM factory initialization
  • MCP tool loading with caching
  • graph export via push()

2. Settings-first runtime objects

Most runtime classes follow the same pattern:

  • define a Pydantic settings model
  • inherit from FromConfigMixin[...]
  • construct the runtime object from validated config

This keeps runtime behavior strongly tied to validated configuration instead of ad hoc dictionaries.

3. Role-based LLM selection

LLMFactory maps roles like query, grader, or answer to specific model configs.

That makes it easy to:

  • use different models for different steps
  • swap providers without changing graph code
  • keep model selection in config rather than inside node logic

4. LangGraph node building blocks

The package exposes low-level but reusable graph parts:

  • Prompt: render a system prompt from state
  • SchemaBasedPrompt: prompt plus structured output schema
  • LLMNode: invoke an LLM against rendered messages
  • ToolBasedNode: base for MCP-backed tool nodes
  • RouterNode: return route keys for conditional edges
  • DeletionStrategy: trim message history in a controlled way

Configuration

Configuration is built around Pydantic settings models in src/agents_builder/settings.py.

Important settings types:

  • AgentSettings
  • LLMFactorySettings
  • OllamaLLMSettings
  • OpenRouterLLMSettings
  • MCPServerSettings

The package-level default YAML path is:

/config/config.yaml

You can also construct objects directly from Python with .from_config(...) or load from YAML with .from_yaml(...).

Development Workflow

Quality checks already configured in the project:

  • ruff for linting and formatting
  • ty for type checking
  • pytest for unit, integration, and e2e tests
  • bandit for security checks

Recommended local loop:

make lint
make type-check
make test

Before merging broader changes:

make ci

Design Principles

This repository works best when changes stay aligned with a few constraints:

  • Prefer explicit graph nodes over magic orchestration layers.
  • Keep configuration typed and validated.
  • Use small runtime classes with narrow responsibilities.
  • Let tests describe behavior at the node and graph level.

If you are contributing code or using AI coding agents in this repository, read AGENTS.md next.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agents_builder-1.2.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agents_builder-1.2.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file agents_builder-1.2.0.tar.gz.

File metadata

  • Download URL: agents_builder-1.2.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for agents_builder-1.2.0.tar.gz
Algorithm Hash digest
SHA256 fca55cee7cf01ca2f40e93a3b62c6e2b5cb6adc79725bc7420752a3e244444ea
MD5 cb823b52a3b43923373d67723e2b40eb
BLAKE2b-256 d957036c121daf934064332fa452754a71592e050356c8d16eb2f27b3948fd38

See more details on using hashes here.

File details

Details for the file agents_builder-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: agents_builder-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for agents_builder-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 220f3ceb7fba0272a57da3f5a1d608e6b31f64eb642cfecf7e874e7b6998c947
MD5 b657f1174b8f66d8302715f49a40b0f3
BLAKE2b-256 3f856df9d26e9cb590cfc40e422769b6137a10533185e0b9da0c2fd348b8ba61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page