Skip to main content

lovia

PyPI Python 3.10+ CI License: MIT Docs

English | 简体中文

One agent loop, three ways to use it. lovia is a Python agent framework you can import as a library, run as a ready-made assistant in your browser, or take apart to build your own. Each layer is built on the one below, so going from a script to a product never means switching frameworks. The core depends only on httpx, pydantic and pyyaml; everything else is opt-in.

Use lovia as… What you get Start with
A library An agent loop in ordinary Python: tools, streaming, sessions, approvals, context management pip install lovia
A ready-made harness A local assistant that works in your project folders, with files, shell, memory, skills and MCP pip install "lovia[web]", then lovia web
The base for your own That assistant as a toolkit: add tools, brand the page, add views, or keep only the API lovia[web], then default_app() or create_app()

A library

pip install lovia
export OPENAI_BASE_URL=https://your-endpoint/v1  # any OpenAI-compatible endpoint
export OPENAI_API_KEY=...
from lovia import Agent, tool


@tool
def get_order(order_id: str) -> str:
    """Look up an order's status by id."""
    return f"Order {order_id}: shipped 2 days ago, arriving Thursday."


agent = Agent(
    name="support",
    instructions="Look the order up before answering, in one or two sentences.",
    model="glm-5.3",  # a model your endpoint serves
    tools=[get_order],
)

print(agent.run_sync("Where is my order A-1042?").output)

From async code, use await Runner.run(agent, ...), or Runner.stream(...) for typed events. For Anthropic, set ANTHROPIC_API_KEY and write model="anthropic:<model>" (configure a model).

What the loop gives you, each a few lines away:

  • Tools from typed functions, run concurrently, and structured output validated into Pydantic models.
  • Multi-agent by agent-as-tool, or background subagents that report back, message their parent mid-run when it must know, and take follow-ups — fresh, or forked from the conversation so far, on a model picked per task.
  • Approvals for sensitive tools: answer from any UI, or suspend the run until someone does.
  • Sessions and checkpoints: conversations persist, and a crashed run resumes where it stopped, without repeating a call that may already have run unless its tool is idempotent.
  • Context compaction that never rewrites the transcript and keeps provider prompt caches warm.
  • A workspace: file and shell tools under one policy for paths and commands, locally, over SSH, or in a container.
  • Plugins: Skills, MCP, Todo and long-term Memory, built on the same extension point you get.
  • Guardrails, retries and budgets, cancellation and steering, and offline testing with evals.

→ Cheatsheet, every feature in one snippet · Quickstart · Examples, a numbered path of runnable scripts

A ready-made harness: lovia web

pip install "lovia[web]"
lovia web

Open http://127.0.0.1:8000 and add a model on first launch. New chats work in the directory you started from; lovia web ~/code/app picks another.

The lovia web UI

A profile charted in the chat, the fix it wrote, and on the right what is still running in the background: two tasks and two commands.

  • It works in your folders. It reads and edits files, runs commands, searches the web, keeps a plan, and hands independent work to background subagents. When a subagent reports or messages mid-run, or a background command exits, the chat picks the work up again on its own (one stopped at its turn or budget limit waits for your message, and reads them with it). A subagent's own chat is view-only, and its commands stop when its run ends. Editing or regenerating an earlier message stops the subagents and background commands the removed turns started. /goal holds it to a goal until that is met. The Files panel shows the folder beside the chat; ⌘P (Ctrl+P) goes to any file in it.
  • Many projects at once. Chats are grouped by workspace. Each has its own folder, model and permission mode — on this machine, an SSH host, or in a container.
  • You stay in control. Permission modes range from read-only to full access. By default, irreversible commands ask first and say why; dangerous ones are refused in every mode. A file the assistant edits keeps what it held before each message: the Files panel shows that version, compares it with the file now, and restores it in one click, undoably — or ask the assistant to put it back.
  • A complete chat. Streaming, branching, steering a run while it works, attachments, scheduled runs, and long-term memory you can edit. A run keeps going when you close the tab.

It keeps everything in ~/.lovia — those earlier versions of files too — never in your repository. On 127.0.0.1 no credentials are needed; binding any other address requires a token.

→ Web UI guide

The base for your own harness

lovia web is assembled from public pieces. Pick the depth you need:

You want Use What you keep
The same assistant, plus your tools default_app(customize=...) All of lovia web: Settings, memory, workspaces, schedules
Your own agent in a branded, extended chat page create_app(agent, ui=ChatUI(...)) The chat page: streaming, approvals, history, files
Your own front end create_app(agent, ui=False) The JSON + SSE API behind the page (/api/docs)

The same assistant, plus your tools. default_app() builds exactly what lovia web serves, and customize hands you each agent it builds:

from lovia import tool
from lovia.web import default_app, serve


@tool
def order_status(order_id: str) -> str:
    """Look up an order."""
    return "shipped"


serve(default_app(customize=lambda agent: agent.clone(tools=[*agent.tools, order_status])))

Your agent, your page. create_app(agent) serves the agent you built, exactly as you built it. It returns a FastAPI app, so your own routes sit beside it:

from lovia.web import ChatUI, create_app, serve

app = create_app(
    agent,
    title="Acme",
    auth=my_auth,          # any FastAPI dependency
    run_deps=my_run_deps,  # who is asking, and what the page picked -> ctx.deps
    ui=ChatUI(assets="ui", styles=["theme.css"], logo="logo.svg", scripts=["acme.js"]),
)
serve(app)
  • Tool results that draw UI. A tool returns ui_result(kind, props). Tables, ECharts charts and sandboxed HTML pages are built in.
  • A scriptable page. Through window.lovia, your scripts add renderers, tool cards, slash commands, and whole views beside the chat. Template blocks, design tokens and data-i18n keys change the page's markup, look and wording. lovia web init-ui ui scaffolds the directory.
  • Worked examples. Examples 26–27 and 31–35 cover serving, components, branding and extensions. lovia-react extends the bundled chat with React views.

Your own front end. create_app(agent, ui=False) serves only the API — on its own, or mounted into your own FastAPI app with app.mount(...).

→ Web server guide · HTTP API · Deployment

Design principles

  • Concise. An immutable Agent, a stateless Runner, @tool, and plugins as the one extension axis. Every piece fits one screen of mental model.
  • Lightweight. Three hard dependencies. MCP, the web app and PDF reading are extras, imported only when used.
  • Readable. Model calls, tool execution, retries and persistence run in one explicit loop. When something surprises you, there is one chain to follow.
  • Extensible, with restraint. Extension points are dataclasses, Protocols and decorators, never subclassing. What fits in a short recipe on your side stays out of the framework.

Install

lovia needs Python 3.10 or newer.

Need Install
Core library pip install lovia
MCP pip install "lovia[mcp]"
PDFs in web_fetch pip install "lovia[pdf]"
Web app (includes MCP and PDF) pip install "lovia[web]"
Runnable examples pip install "lovia[examples,web]"

Status

lovia is in beta, on its way to 1.0. Until then, breaking changes can ship in patch releases; pin a version if that matters to you. Stability lists what 1.0 will promise to keep.

License

MIT

Metadata

Release files for lovia 0.9.366

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lovia 0.9.366
File Size Uploaded Provenance Actions
lovia-0.9.366.tar.gz 4.8 MB With provenance Details for lovia-0.9.366.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lovia 0.9.366
File Interpreter ABI Platform Actions
lovia-0.9.366-py3-none-any.whl Python 3 none any Details for lovia-0.9.366-py3-none-any.whl

Total release size: 7.5 MB

Release files / lovia-0.9.366.tar.gz

Download URL lovia-0.9.366.tar.gz
Size 4.8 MB
Tags Source
SHA-256 checksum
How to use checksums
000514ad09c6f83c6bf049c18e17e79c25b095266051bf0f260e4aab8e3d1e68
BLAKE2b-256 checksum
How to use checksums
0a5b3871dfb0e54830f20b5c721ce32c7ec7e29fe94f3e27ebe59f813e322557
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

Release files / lovia-0.9.366-py3-none-any.whl

Download URL lovia-0.9.366-py3-none-any.whl
Size 2.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9c4171956b973a6198a87ab570b4eb61e6d6741c178d9f57171e3275d3740594
BLAKE2b-256 checksum
How to use checksums
cd58359e19507a3ab2cd00f9001677a4542c8bd45716b9f209e6a1dbbec11772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

Security for lovia 0.9.366

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lovia-0.9.366.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.366 This release

2 release files Full provenance

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