A Python framework for building LLM-powered agents with modular state, tools, and MCP support.
Project description
Pygent
A Python framework for building LLM-powered agents with modular state management, composable operators, and LLM tool-calling integration (including MCP).
Features
- Modular architecture — Agents, sessions, context, tools, and plans as composable modules
- State management — Consistent save/load and serialization via
PygentOperator - LLM-native — Messages and tools align with OpenAI-style APIs
- MCP support — Use Model Context Protocol (SSE and stdio) tools via
ToolManager - Toolkits — Built-in toolkits such as
TerminalToolkitsfor shell access;RestrictedTerminalremains as a compatibility alias.
Requirements
- Python 3.11+
Installation
From the project root:
pip install -e .
Or with uv:
uv pip install -e .
Examples that read .env files use python-dotenv:
pip install -e ".[examples]"
Quick Start
from pygent.agent import BaseAgent
from pygent.context import BaseContext
from pygent.llm import AsyncRequestsClient
from pygent.message import UserMessage
from pygent.module.tool import ToolManager
from pygent.toolkits import TerminalToolkits
class MyAgent(BaseAgent):
def __init__(self):
super().__init__()
self.llm = AsyncRequestsClient(
base_url="https://api.openai.com/v1",
api_key="YOUR_API_KEY",
model_name="gpt-4",
)
self.tool_manager = ToolManager()
terminal = TerminalToolkits(session_id="quickstart", workspace_root=".")
self.tool_manager.add_module("terminal", terminal)
self.tool_manager.register_tools(terminal.get_all_tools())
async def run(self, user_input: str):
context = BaseContext(system_prompt="You are a helpful assistant.")
context.add_message(UserMessage(content=user_input))
# ... tool loop and LLM calls (see examples/react_agent)
return context
See examples/react_agent.py for a ReAct-style agent with tool calling, and examples/multi_session_agent.py for a session-aware variant.
Compatibility note: AsyncOpenAIClient is still exported as an alias of
AsyncRequestsClient, and RestrictedTerminal(root_dir=...) still delegates to
TerminalToolkits.
Project Layout
- pygent/ — Core package: agents, sessions, context, LLM clients, messages, modules, and toolkits
- examples/ — Example agents (e.g. ReAct agent)
- docs/ — Architecture and API documentation
- scripts/ — Local smoke tests and utility scripts
- tests/ — Pytest tests
Documentation
- Architecture — Design, layers, and components
- API — API reference
License
Apache-2.0. See LICENSE for details.
Project details
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.1.7.tar.gz.
File metadata
- Download URL: pygent_ai-0.1.7.tar.gz
- Upload date:
- Size: 83.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf587bca4f9318ae2d7c676afff13812e9095b764768afb4ac789df989f2d50d
|
|
| MD5 |
a2cf32088b933c2f260393a1cdf8fd22
|
|
| BLAKE2b-256 |
3f71c66bb1b83c83cc8f43267070250fbc7c173342538116a91b2eac2fae9479
|
Provenance
The following attestation bundles were made for pygent_ai-0.1.7.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.1.7.tar.gz -
Subject digest:
bf587bca4f9318ae2d7c676afff13812e9095b764768afb4ac789df989f2d50d - Sigstore transparency entry: 1652690354
- Sigstore integration time:
-
Permalink:
pygent-ai/pygent@da9f7102e54c8be6e2e6a93e4af6baa2b0e095dc -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/pygent-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@da9f7102e54c8be6e2e6a93e4af6baa2b0e095dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file pygent_ai-0.1.7-py3-none-any.whl.
File metadata
- Download URL: pygent_ai-0.1.7-py3-none-any.whl
- Upload date:
- Size: 72.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fde79bc085b1079fa376f1012dbed8bc89b7b12ab322aeaa62feccd93b28cb6b
|
|
| MD5 |
04de5a5cf48ba69fbf08c3db0d37c37a
|
|
| BLAKE2b-256 |
517147467cad12f4e5ba4176a0a239e582068b3a66292419459bf88a5dec8afc
|
Provenance
The following attestation bundles were made for pygent_ai-0.1.7-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.1.7-py3-none-any.whl -
Subject digest:
fde79bc085b1079fa376f1012dbed8bc89b7b12ab322aeaa62feccd93b28cb6b - Sigstore transparency entry: 1652690404
- Sigstore integration time:
-
Permalink:
pygent-ai/pygent@da9f7102e54c8be6e2e6a93e4af6baa2b0e095dc -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/pygent-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@da9f7102e54c8be6e2e6a93e4af6baa2b0e095dc -
Trigger Event:
release
-
Statement type: