Pygent 0.3
Pygent is a PyTorch-like framework for composing LLM agents with no hidden per-call state from reusable Module graphs. Version 0.3 provides a single Execution owner for direct and managed calls, an asyncio Runtime, observable model/tool events, OpenAI-compatible adapters, portable tools and MCP adapters, ReAct, SQLite recovery, and HTTP/SSE workers.
Resource benchmark
Pygent 0.3.10 had the highest composite score among qualifying durable-runtime configurations at both tested loads. It recorded the lowest run time, P95, process-tree CPU, and peak RSS in each table.
| Concurrent requests | Durable rank | Run | P95 | CPU | Peak RSS | Disk writes |
|---|---|---|---|---|---|---|
| 200 | 1 of 4 | 3.828 s | 3.758 s | 4.906 s | 102.2 MB | 95.958 MB |
| 1,000 | 1 of 3 | 23.070 s | 22.603 s | 23.453 s | 211.1 MB | 718.838 MB |
This is not an all-metrics win: Pygent wrote 95.958 MB and 718.838 MB, respectively—74.2% and 156.8% more than LangGraph. The benchmark measures framework overhead on Windows with a local OpenAI-compatible mock, not model quality or production capacity, and the durable semantics are not identical. See the full methodology, tables, qualification rules, limitations, and optimization targets.
First principles
Pygent 0.3 第一原则 is the repository's highest authority. Module-specific first principles, SDK contracts, tests, examples, and code derive from it.
Quickstart
from pygent import AIMessage, Context, RecurrentModule, UserMessage
class Echo(RecurrentModule):
async def forward(self, message, context):
output = AIMessage(content=message.content.upper())
return output, context + message + output
message, context = await Echo().invoke(UserMessage(content="hello"), Context())
Direct invoke(), stream(), and start() need no Runtime. Bind a Module to LocalRuntime when its call contract is supported and the application needs bounded concurrency, cancellation, deadlines, remote placement, durable history, or advanced Execution control. This standard recurrent example returns (message, context); ordinary Module inputs and results are user-defined. See the Execution contract.
Install pygent-ai[video] to enable PyAV-backed video inspection and normalization
in the standard read tool. The base package does not install PyAV; an independently
installed av package or system ffmpeg/ffprobe is detected automatically.
Documentation
- 渐进式 Agent 开发教程 — 从零密钥离线示例到工具、流式、Runtime 与动态模型配置
- Layered documentation
- Execution contract
- Module, Context, Runtime
- Agent, LLM, Tool
- Executionnable service example
- Runnable tutorial example
- Native full-path load system
- Cross-framework resource benchmark
Development
uv sync --all-extras
uv run pytest -q
uv run ruff check src tests examples benchmarks
uv run mypy src benchmarks
uv build
python -m examples.service.main
uv run --extra performance python -m benchmarks run synthetic-smoke
Python 3.11+ is required. Apache-2.0; see LICENSE.
Metadata
Release files for pygent-ai 0.3.24
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pygent_ai-0.3.24.tar.gz | 1.1 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pygent_ai-0.3.24-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| pygent_ai-0.3.24-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| pygent_ai-0.3.24-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| pygent_ai-0.3.24-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
| pygent_ai-0.3.24-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 14.1 MB
Release files / pygent_ai-0.3.24.tar.gz
| Download URL | pygent_ai-0.3.24.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0cb8736de8e6864ddb6469c2b5ab60a5332ae6f5178515252fa243d42bfa01d1
|
|
BLAKE2b-256 checksum How to use checksums |
22f67f66449d7be0c1e9003100cda5ca8f48028282e2206a5123213ab7d24e39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency logRelease files / pygent_ai-0.3.24-cp311-abi3-win_amd64.whl
| Download URL | pygent_ai-0.3.24-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ee9a997017923f147b92726d1e594469285a643479877ea3bfe6c91621068100
|
|
BLAKE2b-256 checksum How to use checksums |
363316967f126af784fbde3f5daa971ac401ef89180013303bc0a111c40b8106
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency logRelease files / pygent_ai-0.3.24-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pygent_ai-0.3.24-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f4c9a0bab59614108e687970e5039053b461bcb4a18f78ba5d9064f4f9b8ed05
|
|
BLAKE2b-256 checksum How to use checksums |
bb56b697488933336bd19e3bb1a999391bdec1a67235a32ad9570b5392eab528
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency logRelease files / pygent_ai-0.3.24-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pygent_ai-0.3.24-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
68e8a082f6ad6ba6e7bdd63db3e4709980617a72aa5e3c19e848b4a0ec23188f
|
|
BLAKE2b-256 checksum How to use checksums |
5afd9e270f39923d3c174dbaabc9ac3672aa6414637afbbca4698b344cd6a3d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency logRelease files / pygent_ai-0.3.24-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | pygent_ai-0.3.24-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e2b8797e8f31913a522a4df5b6191f1dbe26b6c0ff6d481ea87a5530b83cc718
|
|
BLAKE2b-256 checksum How to use checksums |
8a0c25b22f759cc87a793b412f36cf16495163a4f3119b97f935972d89794033
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency logRelease files / pygent_ai-0.3.24-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | pygent_ai-0.3.24-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e8e21aa39af0670653a5585e7047552cce34a154f67a2ba5ca76b0a9471093e1
|
|
BLAKE2b-256 checksum How to use checksums |
d77a96e70a038ceb7464d9ed974c549f99b25e62b923aca67834c023c019ddae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 12, 2026.
Transparency log