Pygent 0.2
Pygent is a PyTorch-like framework for composing stateless LLM agents from reusable Module graphs. Version 0.2 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.
First principles
Pygent 0.2 第一原则 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, Module, UserMessage
class Echo(Module[UserMessage, AIMessage]):
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 the same graph to LocalRuntime when the application needs bounded concurrency, cancellation, deadlines, remote placement, durable history, or advanced Execution control. Both modes execute the same forward() graph and return (message, context); see the 0.2 Execution contract.
Documentation
- 渐进式 Agent 开发教程 — 从零密钥离线示例到工具、流式、Runtime 与动态模型配置
- Layered documentation
- Execution contract
- Module, Context, Runtime
- Agent, LLM, Tool
- Executionnable service example
- Runnable tutorial example
- Native full-path load system
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygent_ai-0.2.2.tar.gz.
File metadata
- Download URL: pygent_ai-0.2.2.tar.gz
- Upload date:
- Size: 137.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d3d43ae9ab5049a2c9d4f1e59a2a6b077a699016756a4da8992093e090899e9
|
|
| MD5 |
177f68dc285b89102c679c3c4fcc4c9f
|
|
| BLAKE2b-256 |
95de4683d50e6f8b0e12456d07a83a3b68b80f1844ca5cf8da91abb503796a9f
|
Provenance
The following attestation bundles were made for pygent_ai-0.2.2.tar.gz:
Publisher:
python-publish.yml on pygent-ai/pygent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygent_ai-0.2.2.tar.gz -
Subject digest:
9d3d43ae9ab5049a2c9d4f1e59a2a6b077a699016756a4da8992093e090899e9 - Sigstore transparency entry: 2368577897
- Sigstore integration time:
-
Permalink:
pygent-ai/pygent@8c5e435c1ba10a367f390fad16bcd3acd6d1f23b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/pygent-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8c5e435c1ba10a367f390fad16bcd3acd6d1f23b -
Trigger Event:
release
-
Statement type:
File details
Details for the file pygent_ai-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pygent_ai-0.2.2-py3-none-any.whl
- Upload date:
- Size: 157.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
265706b8db12a498502ed65128fad3b2c92c57ce7c492b4005624b027d2d58df
|
|
| MD5 |
6c8c36ffd98d413a5fce78a9ceda6ca5
|
|
| BLAKE2b-256 |
d19b901ff8f4f1bc716e98b719ceda76071392567a094bd2e9806999fe8e16ec
|
Provenance
The following attestation bundles were made for pygent_ai-0.2.2-py3-none-any.whl:
Publisher:
python-publish.yml on pygent-ai/pygent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygent_ai-0.2.2-py3-none-any.whl -
Subject digest:
265706b8db12a498502ed65128fad3b2c92c57ce7c492b4005624b027d2d58df - Sigstore transparency entry: 2368577962
- Sigstore integration time:
-
Permalink:
pygent-ai/pygent@8c5e435c1ba10a367f390fad16bcd3acd6d1f23b -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/pygent-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8c5e435c1ba10a367f390fad16bcd3acd6d1f23b -
Trigger Event:
release
-
Statement type: