Metadata-Version: 2.4
Name: agex
Version: 0.12.0
Summary: Library-friendly agents that work directly with your existing Python codebase.
Author: ashenfad
License-Expression: MIT
Project-URL: Homepage, https://ashenfad.github.io/agex/
Project-URL: Documentation, https://ashenfad.github.io/agex/
Project-URL: Repository, https://github.com/ashenfad/agex
Project-URL: Issues, https://github.com/ashenfad/agex/issues
Keywords: agents,ai,llm,python,runtime,sandbox
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Operating System :: OS Independent
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: termish<0.2.0,>=0.1.6
Requires-Dist: kvgit<0.4.0,>=0.3.0
Requires-Dist: sandtrap<0.3.0,>=0.2.1
Requires-Dist: reprobate<0.2.0,>=0.1.1
Requires-Dist: monkeyfs<0.2.0,>=0.1.4
Requires-Dist: tiktoken
Requires-Dist: diskcache
Requires-Dist: pydantic
Requires-Dist: pygments
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-asyncio; extra == "test"
Requires-Dist: pytest-timeout; extra == "test"
Requires-Dist: anyio; extra == "test"
Requires-Dist: numpy; extra == "test"
Requires-Dist: pandas; extra == "test"
Requires-Dist: anthropic; extra == "test"
Requires-Dist: google-genai; extra == "test"
Requires-Dist: openai; extra == "test"
Requires-Dist: matplotlib; extra == "test"
Requires-Dist: plotly; extra == "test"
Requires-Dist: kaleido; extra == "test"
Requires-Dist: cloudpickle; extra == "test"
Requires-Dist: uvicorn; extra == "test"
Requires-Dist: fastapi; extra == "test"
Requires-Dist: sse-starlette; extra == "test"
Requires-Dist: modal; extra == "test"
Provides-Extra: examples
Requires-Dist: plotly[express]; extra == "examples"
Requires-Dist: kaleido; extra == "examples"
Requires-Dist: numpy; extra == "examples"
Requires-Dist: nbformat; extra == "examples"
Requires-Dist: pandas; extra == "examples"
Requires-Dist: osmnx>=2.0.0; extra == "examples"
Requires-Dist: folium; extra == "examples"
Provides-Extra: openai
Requires-Dist: openai; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic; extra == "anthropic"
Provides-Extra: gemini
Requires-Dist: google-genai; extra == "gemini"
Provides-Extra: http
Requires-Dist: cloudpickle; extra == "http"
Requires-Dist: httpx; extra == "http"
Provides-Extra: modal
Requires-Dist: modal; extra == "modal"
Provides-Extra: server
Requires-Dist: fastapi; extra == "server"
Requires-Dist: uvicorn; extra == "server"
Requires-Dist: sse-starlette; extra == "server"
Requires-Dist: cloudpickle; extra == "server"
Provides-Extra: all-providers
Requires-Dist: agex[openai]; extra == "all-providers"
Requires-Dist: agex[anthropic]; extra == "all-providers"
Requires-Dist: agex[gemini]; extra == "all-providers"
Provides-Extra: all-hosts
Requires-Dist: agex[http]; extra == "all-hosts"
Requires-Dist: agex[modal]; extra == "all-hosts"
Dynamic: license-file

# agex: Library-Friendly Agents

`agex` (a portmanteau of **age**nt **ex**ecution) is a Python library for building AI agents that work directly with your code.

You define a typed Python function with `@task` and the agent fills it in. It writes sandboxed Python that calls into the modules you've whitelisted, returning real Python objects (DataFrames, Plotly figures, your Pydantic models) that flow back into your code unchanged. There's no JSON serialization at the boundary and no separate runtime to deploy: agex runs inside your application's Python process.

Because the sandbox is pure-Python AST rewriting, the same agent code runs in-process, in a subprocess, in a kernel-isolated worker, or (via Pyodide) entirely in a browser tab. [agex-studio](https://agex.studio) is the proof-of-concept: pandas, scikit-learn, plotly, and a chat agent all running client-side with no backend.

```python
import pandas as pd
from agex import Agent

agent = Agent()
agent.module(pd)

@agent.task
def summarize(df: pd.DataFrame) -> dict[str, float]:
    """Return summary statistics for the numeric columns."""
    pass

stats = summarize(my_dataframe)  # real dict[str, float]
```

![Demo of an agex agent returning pandas DataFrames and plotly figures in an IPython REPL](docs/assets/teaser.gif)

## What you get

- **Typed function tasks** - `@task` declares the input/output contract; the agent fulfills it.
- **Curated Python environment** - whitelist exactly which modules and classes the agent can use, with per-member visibility.
- **Versioned workspace** - virtual filesystem, the agent's session memory, and event log are all kvgit-backed, with checkpoints and time-travel.
- **Multi-agent orchestration** - coordinate agents with regular Python control flow; sub-agents are just functions.
- **Flexible execution** - in-process by default; subprocess, kernel-isolated, browser (Pyodide), or remote ([Modal](https://modal.com/), HTTP) when you need them.

For a deeper dive, see the [agex101 tutorial](https://ashenfad.github.io/agex/examples/agex101/) or the [geospatial routing example](https://ashenfad.github.io/agex/examples/routing/) for multi-library integration. For a NiceGUI integration demo, see [`agex-ui`](https://github.com/ashenfad/agex-ui).

## Documentation

Complete documentation is hosted at **[ashenfad.github.io/agex](https://ashenfad.github.io/agex/)**.

Key sections:
- **[📚 Quick Start Guide](https://ashenfad.github.io/agex/quick-start/)**
- **[🔭 The Big Picture](https://ashenfad.github.io/agex/concepts/big-picture/)**
- **[💡 Examples](https://ashenfad.github.io/agex/examples/overview/)**
- **[📖 API Reference](https://ashenfad.github.io/agex/api/overview/)**

## Installation

Install agex with your preferred LLM provider:

```bash
pip install "agex[openai]"        # OpenAI models
pip install "agex[anthropic]"     # Anthropic Claude models
pip install "agex[gemini]"        # Google Gemini models

# Or with all providers
pip install "agex[all-providers]"
```

## Project Status

This is a hobby project in active development. The core concepts are stabilizing but the API should be considered experimental.

If you're looking for a more battle-tested library built on the same "agents-that-think-in-code" idea, [`smolagents`](https://github.com/huggingface/smolagents) (Hugging Face) is the closest cousin and a good choice. agex explores a different shape: an embeddable library you import into your application, with typed function contracts and a pure-Python sandbox that runs anywhere Python runs (including the browser).

## Built On

agex is composed of several focused libraries that can also be used independently:

| Library | Purpose |
|---------|---------|
| [sandtrap](https://github.com/ashenfad/sandtrap) | In-process Python sandbox via AST rewriting |
| [kvgit](https://github.com/ashenfad/kvgit) | Versioned key-value store with git-like semantics |
| [monkeyfs](https://github.com/ashenfad/monkeyfs) | Filesystem interception via monkey-patching |
| [termish](https://github.com/ashenfad/termish) | Virtual terminal with shell-like commands |
| [reprobate](https://github.com/ashenfad/reprobate) | Budget-controlled repr for Python objects |

## Contributing

Bug reports, ideas, and pull requests welcome - see [GitHub Issues](https://github.com/ashenfad/agex/issues) or the [Contributing Guide](CONTRIBUTING.md).
