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, 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 for bash, file operations, grep/glob, and web search/fetch.

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 BashToolkits

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()
        bash = BashToolkits(session_id="quickstart", workspace_root=".")
        self.tool_manager.add_module("bash", bash)
        self.tool_manager.register_tools(bash.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. Built-in tool names are lowercase: bash, read, write, edit, edit_notebook, read_lints, glob, grep, web_search, and web_fetch.

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

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.12.tar.gz (101.0 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.12-py3-none-any.whl (81.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pygent_ai-0.1.12.tar.gz
Algorithm Hash digest
SHA256 449a3f977749f93ce2d4326ec205ecc8897e19a8622d2b69d7f1879b26a07762
MD5 8b323d209c47d5c295937ee5cc8b5460
BLAKE2b-256 74a1f54258f25aee89129312b758a95b6854ff6e97d9ef2a31e486a7aac09ff3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygent_ai-0.1.12.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.12-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pygent_ai-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 a74c0d977a83603c8f1bb5009348e8de1a458d89b09182682f99bf79f83a3ec7
MD5 e0d6a8392e7c26c35826071b37a180d3
BLAKE2b-256 05d89a7d8053933897ee4a5fc7b6d9a346536bbb61167f917663b77a137f344f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygent_ai-0.1.12-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