Skip to main content

Async agent orchestration for Python

Project description

pygents

Async agent orchestration for Python. Define tools, queue turns, stream results.

Install

pip install pygents

Requires Python 3.12+.

Example

import asyncio
from pygents import Agent, Turn, tool

@tool()
async def greet(name: str) -> str:
    return f"Hello, {name}!"

async def main():
    agent = Agent("greeter", "Greets people", [greet])
    await agent.put(Turn("greet", kwargs={"name": "World"}))

    async for turn, value in agent.run():
        print(value)  # "Hello, World!"

asyncio.run(main())

Tools are async functions. Turns say which tool to run and with what args. Agents process a queue of turns and stream results. The loop exits when the queue is empty.

Features

  • Streaming — agents yield (turn, value) as results are produced
  • Inter-agent messaging — agents can send turns to each other
  • Dynamic arguments — callable kwargs evaluated at runtime
  • Timeouts — per-turn, default 60s
  • Per-tool locking — opt-in serialization for shared state
  • Hooks — async callbacks at turn, agent, and tool level
  • Serializationto_dict() / from_dict() for turns and agents

Docs

Full documentation: uv run mkdocs serve

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

pygents-0.1.2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

pygents-0.1.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pygents-0.1.2.tar.gz.

File metadata

  • Download URL: pygents-0.1.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pygents-0.1.2.tar.gz
Algorithm Hash digest
SHA256 27b95892792658ffdb9c0fc6e3047183fab6bac3603c6f4c287b3fe8ba428a4d
MD5 567c0338e03e739d7c892505c41f0216
BLAKE2b-256 bab81a333f4a35a9613145df99a7e43cd8351da3d78f4dace340a3111f124ac0

See more details on using hashes here.

File details

Details for the file pygents-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pygents-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pygents-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b260246f34a61389a54cefab56896411420e299ecf2744d16b5e3984299a8f1
MD5 fed59d4a3bdcec562ea304cfccb8a39a
BLAKE2b-256 fc1f2842adcafc2df4661bffaa9bea32850aa6c2a2386d30990f150bb6aeccc6

See more details on using hashes here.

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