Skip to main content

LazyBridge

tests docs CodeQL Python 3.11+ License: Apache 2.0

Status: stable (1.0.1+). The core public API (Agent, Plan, Tool, Envelope) will not break without a major version bump — see CHANGELOG and the Maturity table for which subsystems are still Alpha/Experimental.

Zero-boilerplate, multi-provider Python framework for LLM agents. One Agent class, swappable engines (LLM / Plan / Human / Supervisor), and one tool contract — plain Python functions, other Agents, MCP servers, and full pipelines all compose through tools=[...]. Parallelism is automatic when the engine emits N tool calls in a turn; deterministic when you declare it.

from lazybridge import Agent, LLMEngine

agent = Agent(
    engine=LLMEngine("claude-opus-5"),
)
result = agent("hello")
print(result.text())

That's the whole surface when you start. It grows only when your problem grows.

The mental model

Every Agent is the composition Engine + Tools + State:

  • Engine — what decides next. LLMEngine is the common case; swap for Plan (deterministic DAG), HumanEngine (approval gate), or SupervisorEngine (REPL).
  • Tools — anything the agent can invoke. Functions, other Agents, Plan-backed pipelines, MCP servers, and provider-native tools live in the same tools=[...] list.
  • StateMemory (in-prompt history), Store (durable blackboard), Session (event bus + observability).

The same Agent(engine=..., tools=..., ...) shape supports a one-shot helper, a hierarchical multi-agent system, and a checkpointed production pipeline — only the engine= argument changes. See Concepts → Mental model.

Pick your tier

LazyBridge grows with you — every tier is additive.

Tier For Key imports
Basic one-shot or tool-calling agents Agent · LLMEngine · Tool · NativeTool · Envelope
Mid real apps with memory, tracing, guardrails, composition Memory · Store · Session · Guard* · verify= · MCP · HumanEngine · EvalSuite
Full production pipelines: typed hand-offs, routing, resume, OTel Plan · Step · sentinels · SupervisorEngine · checkpoint · exporters
Advanced extending the framework BaseProvider · Plan.to_dict · custom engines · OpenTelemetry · Visualizer

See Decisions → Pick your tier for a flowchart.

Install

PyPI version note. Releases before 0.7.0 (0.4.x and the withdrawn 1.0.0) expose the legacy LazyAgent / LazyTool / LazySession API and do not match this README — see Migrating from 1.0.0 if you have one of those installed. Pin lazybridge>=1.0.1:

pip install "lazybridge[anthropic]"
pip install "lazybridge[anthropic]"
# or [openai], [google], [deepseek], [litellm], [yaml], [otel], [encryption], [all]
# Concrete tools (MCP, Gmail, Telegram, gateways, doc readers) ship in the
# sibling lazytoolkit package: pip install "lazytoolkit[mcp]"  (see https://tools.lazybridge.com/)

Naming note — lazytoolkit vs lazytools. The concrete tools ship in a single sibling package whose distribution name (what you pip install) is lazytoolkit, while its import name (what you write in code) is lazytools:

pip install "lazytoolkit[mcp]"            # distribution name
from lazytools.connectors.mcp import MCP  # import name

This mirrors well-known packages such as pip install beautifulsoup4import bs4.

Confirm you're on the modern API:

import lazybridge
assert lazybridge.__version__ != "1.0.0" and lazybridge.__version__.startswith(
    ("0.7", "0.8", "0.9", "1.")
), (
    f"LazyBridge {lazybridge.__version__} predates the modern API — this "
    f"README requires >=0.7.9 and not the withdrawn 1.0.0.  "
    f"See https://github.com/selvaz/LazyBridge."
)

Set an API key for your provider of choice (ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, DEEPSEEK_API_KEY).

Worked examples

1 · Function becomes a tool, auto-schema

from lazybridge import Agent, LLMEngine, Tool


def get_weather(city: str) -> str:
    """Return current temperature and conditions for ``city``."""
    return f"{city}: 22°C, sunny"


agent = Agent(
    engine=LLMEngine("claude-opus-5"),
    tools=[Tool.wrap(get_weather, name="get_weather")],
)
result = agent("what's the weather in Rome and Paris?")
print(result.text())

No decorators, no JSON schemas. Type hints + docstring become the tool's LLM-facing schema automatically. The explicit Tool.wrap(fn, name=...) factory pins the LLM-visible name so refactors don't break tool-maps or plan references; the bare-callable form tools=[get_weather] works too (backward-compatible auto-wrap). See Guides → Basic → Tool.

2 · Native tools (no code at all)

from lazybridge import Agent, LLMEngine, NativeTool

agent = Agent(
    engine=LLMEngine("claude-opus-5"),
    native_tools=[NativeTool.WEB_SEARCH],
)
agent("AI news this week")

WEB_SEARCH · CODE_EXECUTION · FILE_SEARCH · COMPUTER_USE · GOOGLE_SEARCH · GOOGLE_MAPS (each supported by a subset of providers). CODE_EXECUTION and COMPUTER_USE require allow_dangerous_native_tools=True — they execute code or click your screen.

3 · Tool-is-tool — agents wrap agents

from lazybridge import Agent, LLMEngine

def search(query: str) -> str:
    """Search the web and return a short result (stub for the example)."""
    return f"results for {query!r}"


researcher = Agent(
    engine=LLMEngine("claude-opus-5"),
    tools=[search],
    name="research",
)
editor = Agent(
    engine=LLMEngine("claude-opus-5"),
    tools=[researcher],
    name="editor",
)
result = editor("summarise AI trends April 2026")
print(result.text())

Parallelism is emergent: when editor decides to call two tools in the same turn, they run concurrently via asyncio.gather. No flag, no config, no "parallel mode".

4 · MCP servers as tool catalogues

from lazybridge import Agent, LLMEngine
from lazytools.connectors.mcp import MCP  # pip install lazytoolkit (import name: lazytools)

fs = MCP.stdio(
    "fs",
    command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem", "/tmp/project"],
    allow=["fs.read_*", "fs.list_*"],   # required since 0.7.9 (deny-by-default)
    cache_tools_ttl=60.0,
)
agent = Agent(
    engine=LLMEngine("claude-opus-5"),
    tools=[fs],
)
agent("Read README.md and summarise the install steps")

The MCP server expands into one LazyBridge Tool per remote tool — no separate engine, no graph wrappers. See LazyTools → MCP.

5 · Declared typed pipeline with crash resume

from lazybridge import Agent, LLMEngine, Plan, Step, Store, from_prev, from_step

store = Store(db="pipeline.sqlite")

researcher = Agent(engine=LLMEngine("claude-opus-5"), name="search")
ranker     = Agent(engine=LLMEngine("claude-opus-5"), name="rank")
writer     = Agent(engine=LLMEngine("gpt-5.4-mini"),          name="write")

pipeline = Agent(
    engine=Plan(
        Step("search", writes="hits"),
        Step("rank",
             task="Rank these search hits by relevance; return the top 5.",
             context=from_prev),
        Step("write",
             task="Write a 200-word brief from the ranked items.",
             context=from_step("rank")),
        store=store,
        checkpoint_key="research",
        resume=True,
    ),
    tools=[researcher, ranker, writer],
)
pipeline("AI trends April 2026")

If a step fails mid-plan, the next run with resume=True retries from the failing step only. Concurrent runs on the same checkpoint_key are serialised via compare_and_swap — first writer wins, second raises ConcurrentPlanRunError. Pass on_concurrent="fork" for fan-out workflows. See Guides → Full → Checkpoint & resume.

6 · Human-in-the-loop with a full REPL

from lazybridge import Agent, LLMEngine
from lazybridge.ext.hil import supervisor_agent

sup = supervisor_agent(
    tools=[search],
    agents=[researcher],   # human can `retry research: <feedback>`
)
result = sup("publish a policy brief")
print(result.text())

REPL commands: continue, retry <agent>: <feedback>, store <key>, <tool>(<args>). For approval-only flows use the lighter human_agent(...) or HumanEngine — see Decisions → HumanEngine vs SupervisorEngine.

What makes LazyBridge different

  1. Tool-is-Tool. Functions, Agents, Agents-of-Agents, Plan-backed pipelines, and tool providers (MCP servers, external HTTP gateways) all plug into tools=[...] with the same contract.
  2. Compile-time plan validation. PlanCompileError at construction catches broken DAGs — duplicate names, forward references, broken from_step / from_parallel sentinels — before any LLM call.
  3. CAS-protected crash resume. Plan checkpoints to Store via compare_and_swap. Two concurrent runs on the same checkpoint_key deterministically converge instead of silently overwriting.
  4. Parallelism as capability. When the engine emits N tool calls in one turn, they run concurrently via asyncio.gather. No flag, no tool_choice="parallel" knob.
  5. Transitive cost roll-up. Envelope.metadata.nested_* aggregates token / cost telemetry across an Agent-of-Agents tree — the outer envelope reports total pipeline spend without double-counting.
  6. OTel GenAI conventions out of the box. OTelExporter ships gen_ai.* attributes and proper parent-child spans; existing GenAI dashboards render LazyBridge traces unchanged.
  7. First-class LLM-assistant artifact. A signature-first Claude Skill ships with the library at lazybridge/skill/, loadable by any LLM coding assistant. See For LLM assistants.

Documentation

The full docs live at https://core.lazybridge.com. Highlights:

  • Concepts — the mental model, "everything is a tool", progressive complexity, and canonical-vs-sugar.
  • Guides — one focused page per public concept, all following the same Signature → Synopsis → When to use / NOT → Example → Pitfalls → See also template.
  • Recipes — runnable examples from examples/, embedded verbatim.
  • Decisions — "which one do I use?" trees for tier, return type, state layer, composition, parallelism, HumanEngine vs SupervisorEngine, verify= placement, checkpointing.
  • Errors — cause → diagnosis → fix table for every framework exception.
  • For LLM assistants — Claude Skill install, /llms.txt index, /llms-full.txt corpus.

Contributing

Issues and PRs welcome at https://github.com/selvaz/LazyBridge. Run the test suite with pip install -e ".[test,all]" then pytest. See SECURITY.md for the disclosure policy.

Licence

Apache 2.0 — see LICENSE.


How This Was Built

LazyBridge is designed by selvaz with Claude Code and ChatGPT Codex as primary implementation partners. I focus on architecture, mental model, and trade-offs — they handle the building under my direction.

Download files

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

Source Distribution

lazybridge-1.4.0.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

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

lazybridge-1.4.0-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file lazybridge-1.4.0.tar.gz.

File metadata

  • Download URL: lazybridge-1.4.0.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lazybridge-1.4.0.tar.gz
Algorithm Hash digest
SHA256 128b65721c8f11647d0321e93744169ed97e687a492872b93fc135f07f14f8ba
MD5 8c9ecbf3532adb547225404acd620fd4
BLAKE2b-256 8bde81d66da531fb4fd2230f2769b6f99ab0f89fb092d565b49494e540af91fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for lazybridge-1.4.0.tar.gz:

Publisher: release.yml on selvaz/LazyBridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lazybridge-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: lazybridge-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lazybridge-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 652ed98034cdb895d3189e5f68a678cd47578d336d7e79dd7c0a51b5fbaf9aa0
MD5 30b7d48f46e4635a4dd1bb936f50e7d0
BLAKE2b-256 f5b0ec89aa51ebc41efea90ad6e3eeeb03c7666d93e38e2c36d91794af1365c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lazybridge-1.4.0-py3-none-any.whl:

Publisher: release.yml on selvaz/LazyBridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

0.9.0

2 files

0.7.9

2 files

0.4.0

2 files

0.3.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page