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.1.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.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygents-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 878336ac93d5fca2d7dc6723d25f0b088d9bc594d9ee522c51ff55a09a7a3fa0
MD5 bc0451f6d773604dcafd0fca409f09be
BLAKE2b-256 7abe89eaf84d42cd238a9cc8e565b8d63822c539079b9530bc5e378f4bd62326

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygents-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf472c806ed76cf65df16413735f3b1d6adb22f6f347783ae06ba2350df67cb5
MD5 f4b683c2a4d07f8e5a45ab81a8a07e7d
BLAKE2b-256 7687ae17a7db51910132e12b6775d10eace6719cbd09635e3be9f975b3a89eaf

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