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
  • Fixed kwargs — decorator kwargs (e.g. @tool(permission="admin")) are merged into every invocation; call-time kwargs override
  • Hooks — async callbacks at turn, agent, and tool level
  • Serializationto_dict() / from_dict() for turns and agents

Docs

Full documentation: uv run mkdocs serve. MkDocs is an optional dependency—install with pip install -e ".[docs]" (or use uv run as above) so the library itself does not depend on it.

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.5.tar.gz (9.6 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.5-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygents-0.1.5.tar.gz
  • Upload date:
  • Size: 9.6 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.5.tar.gz
Algorithm Hash digest
SHA256 01610d14ffa82cb350d61dd114651ca82ad2c1fb0b0b4336ad2148eeb4953908
MD5 5481e9f2f1118a446d43f3b5a9fd7c7b
BLAKE2b-256 58baa79d68c5298f38c2f9ece0f737647df8f63d7560936b920026c753a5b624

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygents-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.5 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 775229f8dd8628d36c2c0ddd6c6aa5f3fa782849f99aca3c8b2ef3c0759f461d
MD5 3e2fa8e69c267a5ddd8cf4fd4f737261
BLAKE2b-256 1b9572a103a4a789d5cca89fa81081ae8c4941aaac38c1b1a4a3eed2c0d55479

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