agex
Agents that work in a versioned world.
agex is an agent loop over nontainer workspaces: a filesystem, a shell and sandboxed Python, with history. It has two front doors:
- A session drives a workspace turn by turn. Its conversation is stored in the workspace's branch, so checking out a commit rewinds the agent's memory with its files, and a fork carries both.
- A task is a typed function an agent runs on a world of its own and answers with a value of the declared type.
pip install "agex[anthropic]" # or [openai], [openrouter], [google], [all]
A session
from agex import Agent
from nontainer import Store
agent = Agent("anthropic:claude-sonnet-5-5")
store = Store(memory=True)
ws = store.open("demo")
chat = agent.session(ws)
out = chat.say("Write fib.py printing the first ten Fibonacci numbers, and run it.")
print(out.status, out.text) # completed, and the model's reply
print(ws.files.read("fib.py").decode()) # the file it wrote
out = chat.say("Make it print twenty.") # it remembers the last turn
Tool calls that change the workspace commit as they land, and a turn's
end lands one more commit, stamped with how the run ended: completed,
cancelled, failed or interrupted. None of them raise.
A task
from dataclasses import dataclass
@dataclass
class Recipe:
name: str
steps: list[str]
minutes: int
@agent.task
def plan_dinner(ingredients: list[str]) -> Recipe:
"""A dinner recipe using only these ingredients, plus salt and oil."""
...
recipe = plan_dinner(["eggs", "spinach", "feta"]) # a Recipe
The docstring is the job, and the body holds no code (... is for a
type checker). The agent works in a scratch world (or a fork of
world=), and its code hands back the value with task.success(...).
The value is checked against the return type, so the caller gets a
Recipe or a TaskFailed.
Your code
An agent works with your libraries and your live objects, not copies. They are granted to the workspace, so a fork or a delegate holds them too:
from nontainer import Profile, PythonConfig
from nontainer.presets import dataframes
profile = Profile(python=PythonConfig(
modules=[dataframes()], # pandas, numpy, pyarrow
host_objects={"db": my_pool}, # your real connection pool
))
ws = store.open("analyst", profile=profile)
agent.session(ws).say("Which customers churned last month? db has the tables.")
A task can take a live object as an input too. Its agent calls it where it is, guided by the class's methods and docstrings:
@agent.task
def churned(month: str, db: Customers) -> list[str]:
"""The customers who left in the month (YYYY-MM)."""
...
names = churned("2026-09", db=customers)
Agent-defined tasks
A session's agent can define tasks of its own, for the judgment work in
a script: classify, extract, summarize. Grant agex to its workspace:
from agex import agent_tasks
from nontainer import Profile, PythonConfig
profile = Profile(python=PythonConfig(host_objects={"agex": agent_tasks(agent)}))
ws = store.open("reviews", profile=profile)
and the agent's code can write
@agex.task
def sentiment(review: str) -> str:
"""positive, negative or mixed"""
labels = sentiment.map(reviews) # helpers run them at once
More
- Quick start: install, the first session and task, reading an outcome
- Examples: runnable scripts for each of the above
- Design notes: the shape, and why
- Plan: what is done and what is next
agex 0.13 is a new API. The 0.12 API is at the
v0.12.4 tag and on
PyPI as agex==0.12.4.
Development
uv sync
uv run pre-commit install --hook-type pre-commit --hook-type pre-push
uv run pytest
See CONTRIBUTING.md.
Metadata
Release files for agex 0.13.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agex-0.13.1.tar.gz | 191.7 kB | Without provenance | Details for agex-0.13.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agex-0.13.1-py3-none-any.whl | Python 3 | none | any | Details for agex-0.13.1-py3-none-any.whl |
Total release size: 320.6 kB
Release files / agex-0.13.1.tar.gz
| Download URL | agex-0.13.1.tar.gz |
|---|---|
| Size | 191.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e57e582b4c5fd72a7a26b0f0a80a94b8d9920943426633de539e42e3a6440442
|
|
BLAKE2b-256 checksum How to use checksums |
a37c619bee5ca8f89491a0c8c3374a889d7df8664e33fe71f6ace7e5b439c765
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / agex-0.13.1-py3-none-any.whl
| Download URL | agex-0.13.1-py3-none-any.whl |
|---|---|
| Size | 128.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90a03d49308e908e7b1c555354a5472981e27ebfd08be7e1ce2cf031ee92dea6
|
|
BLAKE2b-256 checksum How to use checksums |
4b16c5f10156bd046983e327784da6533be676a230fd44bd46326ae351d2d254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for agex 0.13.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.