Skip to main content

A glass-box, minimal library for building LLM agents — modern techniques as opt-in primitives, no hidden control flow.

Project description

glia

English · Русский · 📖 Docs

A glass-box, minimal library for building LLM agents. Every model call, tool call, and state transition is a plain object you can log, snapshot, and replay. No hidden control flow. The whole loop fits in one file you can read in an afternoon.

glia (n.): the cells that support and connect neurons. This is the connective tissue for LLM agents — not a framework you submit to, a small library you build on.

CI  Python 3.10+  ·  MIT  ·  zero required dependencies  ·  typed


Why another agent library?

The 2026 agent-framework field is crowded, and the loudest, most consistent complaint about the incumbents is the same: too much abstraction, hidden control flow, painful to debug. Developers keep stripping the framework out to call the model API directly, just to see what's happening.

glia is the opposite bet. It ships the modern techniques — tools, structured outputs, context compaction, durable checkpoints, guardrails, subagents, evals-as-tests — as opt-in primitives you can read, not a monolith you must trust. The design goal is understandability and control, not feature count.

If you want a graph engine, use LangGraph. If you want role-play crews, use CrewAI. If you want a small, transparent loop you fully understand — glia.

See docs/STRATEGY.md for the full market analysis.

Install

pip install glia-agents               # core — no dependencies
pip install "glia-agents[anthropic]"  # + the Claude provider

The distribution is glia-agents (the bare name glia was taken on PyPI); the import stays import glia. For development: git clone then pip install -e ".[anthropic,dev]".

30-second tour

import asyncio
from glia import Agent, tool
from glia.providers import ClaudeLLM

@tool
async def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return {"Paris": "18°C, cloudy"}.get(city, "unknown")

async def main():
    agent = Agent(ClaudeLLM(), tools=[get_weather], system="Be concise.")
    result = await agent.run("What's the weather in Paris?")
    print(result.output)          # the answer
    print(result.usage)           # what it cost

asyncio.run(main())

No API key handy? Every example runs offline with the deterministic EchoLLM provider — same code, no network:

from glia.providers import EchoLLM, call
llm = EchoLLM([call("get_weather", {"city": "Paris"}), "It's 18°C and cloudy."])

See the whole glass box

Because the loop emits an event for everything it does, you can watch it work:

async for event in agent.run_events("What's the weather in Paris?"):
    print(event.kind)
# run_started → model_call → model_response → tool_called → tool_returned → model_call → ... → run_finished

And the entire run state is one serialisable object:

from glia.checkpoint import save, load
save(result.trajectory, "run.json")     # durable execution: it's just JSON
resumed = load("run.json")
await agent.run("follow-up question", trajectory=resumed)   # pick up where you left off

What's in the box

Primitive What it gives you
Transparent loop agent.run() / agent.run_events() — no hidden control flow
Streaming Agent(..., stream=True) — tokens arrive as ModelDelta events
Typed tools @tool on a plain function; JSON schema derived from type hints
Parallel tools a turn's tool calls run concurrently, results kept in order
Approval gate approval=... — an inspectable human-in-the-loop verdict before any tool runs
Provider boundary one ~40-line LLM protocol; Claude + offline adapters
Trajectory the full, JSON-serialisable run state and event log
Structured output generate_structured(...) → a dataclass / Pydantic model / dict
Context engineering SummarizingCompactor, TrimmingCompactor
Durable execution checkpoint & resume — a run is a JSON file
Guardrails (text) -> None validators for input and output
Subagents agent.as_tool(...) — any agent becomes a tool
Evals-as-tests a pytest-style regression harness for agent behaviour

Examples

Runnable, offline, no API key needed:

python examples/01_hello_agent.py       # basic agent + event stream
python examples/02_tools.py             # tools
python examples/03_structured_output.py # typed output
python examples/04_subagents.py         # subagent as a tool
python examples/05_checkpoint_resume.py # durable execution
python examples/06_evals.py             # eval suite
python examples/07_streaming_and_approval.py # streaming + parallel tools + approval gate

Desktop app

glia ships a graphical shell — a chat window that also shows the live glass box (streaming tokens, tool calls, approvals) as it happens.

  • Download a standalone build for your OS from the latest release (glia-shell-windows.exe / -macos / -linux) — no Python needed.
  • Or pip install "glia-agents[shell]" then glia-shell for a native window.

It works offline in demo mode out of the box; add an Anthropic API key in Settings to chat with real Claude. The whole app is stdlib + one HTML file — see docs/app.md.

Design in one picture

Agent.run() → [ call model → (tools? run them, loop) : done ]
                     │              │
                every step emits an Event you can see, log, and replay
                     │
              all state lives in one serialisable Trajectory

Full details in docs/ARCHITECTURE.md.

Project docs

Status

v0.3 — alpha. The core thesis is proven end-to-end with a full test suite (119 offline tests) and green CI. v0.3 adds a downloadable desktop shell; v0.2 added streaming, parallel tool execution, and a human-in-the-loop approval gate. APIs may still change before 1.0. Feedback and issues welcome.

License

MIT — see LICENSE.

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

glia_agents-0.3.0.tar.gz (78.9 kB view details)

Uploaded Source

Built Distribution

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

glia_agents-0.3.0-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

Details for the file glia_agents-0.3.0.tar.gz.

File metadata

  • Download URL: glia_agents-0.3.0.tar.gz
  • Upload date:
  • Size: 78.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glia_agents-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6b9018677186df8726c244cb98cb75b17a47c88d4e926c5664a9a23ddc5250a1
MD5 bed727c86e17f6a2d611bace6f476333
BLAKE2b-256 479c8b73d3a3d5733802f2e2ed973e7c3954154ca4535e82be912b8ca2e8adbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for glia_agents-0.3.0.tar.gz:

Publisher: publish.yml on DenisDrobyshev/glia

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

File details

Details for the file glia_agents-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: glia_agents-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glia_agents-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbb7e59e3f054220df88a2bd06f3a3ae2d196e16886f46159c2ba5256bc667f5
MD5 c232fa95da5a7bac8acacef5afc680ec
BLAKE2b-256 599ad896eaecb1a146bd66416a10a52771bce10b747fa10fb1d8d1c10cb6e4f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for glia_agents-0.3.0-py3-none-any.whl:

Publisher: publish.yml on DenisDrobyshev/glia

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

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