Skip to main content

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, context, tools, memory, 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 RestrictedTerminal for safe shell access

Requirements

  • Python 3.11+

Installation

From the project root:

pip install -e .

Or with uv:

uv pip install -e .

Quick Start

from pygent.agent import BaseAgent
from pygent.context import BaseContext
from pygent.llm import AsyncOpenAIClient
from pygent.message import UserMessage
from pygent.module.tool import ToolManager
from pygent.toolkits import RestrictedTerminal

class MyAgent(BaseAgent):
    def __init__(self):
        super().__init__()
        self.llm = AsyncOpenAIClient(
            base_url="https://api.openai.com/v1",
            api_key="YOUR_API_KEY",
            model_name="gpt-4",
        )
        self.tool_manager = ToolManager()
        terminal = RestrictedTerminal(root_dir=".")
        self.tool_manager.add_module("terminal", terminal)
        self.tool_manager.register_tools(terminal.get_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/react_agent.py for a full ReAct-style agent with tool calling.

Project Layout

  • pygent/ — Core package: agents, context, LLM client, messages, modules (tool, plan, memory, etc.), toolkits
  • examples/ — Example agents (e.g. ReAct agent)
  • MCPs/ — Example MCP servers (e.g. LocalMemoryMCP)
  • docs/Architecture and API documentation
  • tests/ — Pytest tests

Documentation

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

pygent_ai-0.1.1.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygent_ai-0.1.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pygent_ai-0.1.1.tar.gz.

File metadata

  • Download URL: pygent_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygent_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 628c363ec37f0e85546fc1080aed68afea51c89b6db5c9c9c0dd86ef2f2133a4
MD5 da2f9b0366d66abf182027acc33e02b1
BLAKE2b-256 7ec78854b3b6ff0b67be8660c4b0905e5ece2f9bca01d2ed50bd8479d0ec1020

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygent_ai-0.1.1.tar.gz:

Publisher: python-publish.yml on pygent-ai/pygent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygent_ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pygent_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygent_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1ccaeaa13d6c30fbe7bc662cfded6f4b72bcc137903e9818f6f8aac847f4d82
MD5 b44d4cdb9f365efa519675f05473a765
BLAKE2b-256 aa29af7b1fd457dfd26193530c8863e1b14b4600441937270128342bc7d2376f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygent_ai-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on pygent-ai/pygent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page