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

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.3.tar.gz (9.3 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.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygents-0.1.3.tar.gz
  • Upload date:
  • Size: 9.3 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.3.tar.gz
Algorithm Hash digest
SHA256 d021d4bbbab4d0fe00b28d30cc47a31852023874588986cfd285a9739a6e1a82
MD5 cd68b11509a5f5984b5c84f594b01058
BLAKE2b-256 cda658071be51d5da7c908a746218701ac25d6ca72c50c5c3c91967356bab962

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygents-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c227adf40bdf04641d9120f0a8b2ccd9eab0f3d7b90e026b240f8e960c77f6ce
MD5 9a487ec43519c881bd217d183ae14a8e
BLAKE2b-256 f604cdf54ae9ac2f0ddadabc3f62449ec75092e51a111d6bc5e92baeeba3ccf8

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