NexusAgent
A modular runtime for AI agents in Python — zero runtime dependencies, a small readable core, and an honest feature list.
Most agent frameworks hand you a galaxy of abstractions. NexusAgent is the opposite: ~800 statements of typed, contract-tested core that you can read in one sitting — providers, tools, a bounded autonomous tool loop, an async mirror of the whole stack, and a CLI. Nothing hidden, nothing magic.
from nexusagent import create_application_runtime
runtime = create_application_runtime() # offline `fake` provider by default
result = runtime.run("Hello NexusAgent")
print(result.output) # fake response: Hello NexusAgent
print(result.success) # True
print(runtime.execute_tool("calculator", "2 + 3")) # 5
Why NexusAgent
- Zero runtime dependencies — the whole core is the Python standard library.
pip install nexusagent-runtimepulls nothing else. - Readable by design — the core is small enough to audit in an afternoon; architecture rules are enforced by tests, not comments.
- Honest — the feature list below says what exists and what doesn't. No fake benchmarks, no aspirational docs.
- Typed — ships
py.typed; the source itself passesmypy --strict. - Tested — 850+ contract tests, ≥95% coverage floor enforced in CI.
Features
| Capability | Status |
|---|---|
| Provider abstraction (bring any backend) | ✅ |
Autonomous tool loop, bounded by max_iterations |
✅ |
| OpenAI-compatible adapter (OpenAI, Ollama, LM Studio, vLLM, …) | ✅ ADR 0005 |
| Anthropic-compatible adapter (Anthropic, gateways, …) | ✅ ADR 0007 |
| Vendor-neutral HTTP wire protocol | ✅ docs/protocol.md |
Built-in tools: echo, uppercase, calculator |
✅ |
| Custom tools / custom providers via small ABCs | ✅ guides |
Configuration via NEXUS_* environment variables |
✅ |
CLI (nexusagent, python -m nexusagent) |
✅ |
Fully typed (py.typed), strict mypy clean |
✅ |
| Async execution (additive layer, same contracts) | ✅ ADR 0006 |
| Streaming responses | ❌ |
| Memory, planning, multi-agent orchestration | ❌ |
| Native Gemini adapter | ❌ |
| Retries / backoff on HTTP failures | ❌ |
Architecture
flowchart LR
U["your code / CLI"] --> R["Runtime"]
R --> A["Agent"]
A -- "generate_response()" --> P["Provider<br/>(fake · scripted · http · openai · anthropic)"]
P -- "TextResponse" --> A
P -- "ToolCallRequest" --> A
A --> X["ToolExecutor"]
X --> T["ToolRegistry<br/>echo · uppercase · calculator"]
X -- "ToolResult" --> A
The Provider answers with text or requests a tool; the Agent runs the tool and feeds the result back, repeating until a text answer or the iteration limit. Deeper details: docs/architecture.md · concepts: docs/concepts.md · decisions: docs/adr/.
Installation
pip install nexusagent-runtime
The import name is
nexusagent; the PyPI distribution isnexusagent-runtime— the exact namenexusagentis blocked on PyPI by an unrelated placeholder package (nexus-agent), see ADR 0004.
Requires Python 3.10–3.13. From source:
git clone https://github.com/Abolfazlrwm/nexusagent
cd nexusagent
pip install -e ".[dev]"
python scripts/check.py # lint + format + mypy --strict + tests
Usage
Agent with tools
from nexusagent import create_application_runtime
runtime = create_application_runtime()
print(runtime.list_tools())
# [EchoTool, UppercaseTool, CalculatorTool]
# The provider decides when to request a tool; the agent runs the loop.
result = runtime.run("What is 19 + 23?")
The tool loop, end to end, offline
python examples/tool_loop_demo.py
Starts a local "model backend" speaking the HTTP protocol, requests the calculator, and turns the result into a final answer — no API key, no internet.
OpenAI-compatible providers
The openai provider speaks the Chat Completions wire format — OpenAI
itself, plus every compatible server (Ollama, LM Studio, vLLM, OpenRouter,
Groq, ...). Tool calling works end to end: tools are advertised as functions
with a single input string parameter, and results (including errors) are
fed back to the model. Zero dependencies — no vendor SDK.
export NEXUS_PROVIDER=openai
export NEXUS_MODEL=gpt-4o-mini
export NEXUS_API_KEY=sk-... # optional for local servers
nexusagent "What is 19 + 23?"
To run against a local server instead, set
NEXUS_ENDPOINT=http://localhost:11434/v1/chat/completions (Ollama) and drop
the API key. Design details: ADR 0005.
Anthropic-compatible providers
The anthropic provider speaks the Anthropic Messages wire format — Anthropic
itself, plus compatible gateways. Tool calling works end to end: tools are
advertised with a JSON Schema of a single input string parameter, and results
(including errors, via the native is_error flag) are fed back to the model.
Zero dependencies — no vendor SDK.
export NEXUS_PROVIDER=anthropic
export NEXUS_MODEL=claude-sonnet-4-5
export NEXUS_API_KEY=sk-ant-... # required by the official API
nexusagent "What is 19 + 23?"
To run against a compatible gateway instead, set
NEXUS_ENDPOINT=https://your-gateway.example/v1/messages. The wire format
requires max_tokens on every request; NexusAgent sends 1024 by default.
Design details: ADR 0007.
Async runtime
The async layer mirrors the sync contracts one-to-one — await runtime.run(...),
await runtime.execute_tool(...), and awaited AsyncTool tools. Sync providers
(including openai) keep working under the event loop through a thread bridge,
with zero runtime dependencies.
import asyncio
from nexusagent import create_async_runtime
async def main() -> None:
runtime = create_async_runtime() # offline `fake` provider by default
result = await runtime.run("Hello NexusAgent")
print(result.output) # fake response: Hello NexusAgent
asyncio.run(main())
Details, async tools and concurrency: guide · design: ADR 0006.
CLI
nexusagent "your prompt" # or: python -m nexusagent "your prompt"
nexusagent tool list
nexusagent tool run calculator "2 + 3"
Configuration
| Variable | Meaning | Default |
|---|---|---|
NEXUS_PROVIDER |
fake, http, openai or anthropic |
fake |
NEXUS_ENDPOINT |
HTTP/OpenAI/Anthropic provider URL (optional for openai/anthropic) |
— |
NEXUS_MODEL |
model identifier passed to the provider (required for openai/anthropic) |
— |
NEXUS_API_KEY |
sent as Bearer token (OpenAI) or x-api-key (Anthropic); never logged, masked in reprs |
— |
NEXUS_TIMEOUT |
HTTP timeout in seconds | 30 |
Examples
All examples run offline, with no API keys:
examples/basic.py— smallest possible runexamples/custom_tool.py— define and register your own toolexamples/tool_loop_demo.py— the autonomous tool loop over local HTTPexamples/async_tool_loop.py— the async tool loop with an awaited toolexamples/http_provider_local.py—httpprovider against a local backend
Documentation
- Architecture — layers, module map, dependency rules
- Concepts — Agent, Provider, Tool, Runtime, Settings
- Guides — write a custom provider, tool or async runtime
- HTTP protocol — wire format for backends
- ADRs — architecture decision records (0001–0006)
- Security policy · Changelog · Contributing
Project status
Actively developed, pre-1.0. See PROJECT_STATUS.md for a candid snapshot of what works and what the next steps are. Breaking public API changes require an ADR and are discussed in the open.
License
Metadata
Release files for nexusagent-runtime 0.7.0
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 |
|---|---|---|---|---|
| nexusagent_runtime-0.7.0.tar.gz | 64.5 kB | With provenance | Details for nexusagent_runtime-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nexusagent_runtime-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for nexusagent_runtime-0.7.0-py3-none-any.whl |
Total release size: 98.5 kB
Release files / nexusagent_runtime-0.7.0.tar.gz
| Download URL | nexusagent_runtime-0.7.0.tar.gz |
|---|---|
| Size | 64.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d1ae80f7b6655afc36b21500586571ffd631a5c93d7151d506f0a76f2939112
|
|
BLAKE2b-256 checksum How to use checksums |
01fdd6af1cc9d75692c751447ce64fe82f980c8d0776269db0f7630501d30d8d
|
| 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 Nov 12, 2026.
Transparency logRelease files / nexusagent_runtime-0.7.0-py3-none-any.whl
| Download URL | nexusagent_runtime-0.7.0-py3-none-any.whl |
|---|---|
| Size | 34.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9feac31d3ed134fdfc561c8f02c2b3bd65253cc36624d50d643e02b667b721c1
|
|
BLAKE2b-256 checksum How to use checksums |
4ba090664df58f63f8d2acf023cbaed7f5da7070a38c73f80998c51ed4419384
|
| 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 Nov 12, 2026.
Transparency logSecurity for nexusagent-runtime 0.7.0
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.
Attestation for nexusagent_runtime-0.7.0.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 Nov 12, 2026.
Transparency logA 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.