Skip to main content

Summary

Agency is a python library that provides an Actor model framework for creating agent-integrated systems.

The library provides an easy to use API that enables you to connect agents with traditional software systems in a flexible and scalable way, allowing you to develop any architecture you need.

Agency's goal is to enable developers to create custom agent-based applications by providing a minimal foundation to both experiment and build upon. So if you're looking to build a custom agent system of your own, Agency might be for you.

Features

Easy to use API

Performance and Scalability

  • Supports multiprocessing and multithreading for concurrency
  • AMQP support for networked agent systems

Observability and Control

  • Action and lifecycle callbacks
  • Access policies and permission callbacks
  • Detailed logging

Demo application available at examples/demo

  • Multiple agent examples for experimentation
    • Two OpenAI agent examples
    • HuggingFace transformers agent example
    • Operating system access
  • Includes Gradio UI
  • Docker configuration for reference and development

API Overview

In Agency, all entities are represented as instances of the Agent class. This includes all AI-driven agents, software interfaces, or human users that may communicate as part of your application.

All agents may expose "actions" that other agents can discover and invoke at run time. An example of a simple agent could be:

class CalculatorAgent(Agent):
    @action
    def add(a, b):
        return a + b

This defines an agent with a single action: add. Other agents will be able to call this method by sending a message to an instance of CalculatorAgent and specifying the add action. For example:

other_agent.send({
    'to': 'CalcAgent',
    'action': {
        'name': 'add',
        'args': {
            'a': 1,
            'b': 2,
        }
    },
})

Actions may specify an access policy, allowing you to control access for safety.

@action(access_policy=ACCESS_PERMITTED) # This allows the action at any time
def add(a, b):
    ...

@action(access_policy=ACCESS_REQUESTED) # This requires review before the action
def add(a, b):
    ...

Agents may also define callbacks for various purposes:

class CalculatorAgent(Agent):
    ...
    def before_action(self, message: dict):
        """Called before an action is attempted"""

    def after_action(self, message: dict, return_value: str, error: str):
        """Called after an action is attempted"""

    def after_add(self):
        """Called after the agent is added to a space and may begin communicating"""

    def before_remove(self):
        """Called before the agent is removed from the space"""

A Space is how you connect your agents together. An agent cannot communicate with others until it is added to a common Space.

There are two included Space implementations to choose from:

  • LocalSpace - which connects agents within the same application.
  • AMQPSpace - which connects agents across a network using an AMQP server like RabbitMQ.

Finally, here is a simple example of creating a LocalSpace and adding two agents to it.

space = LocalSpace()
space.add(CalculatorAgent, "CalcAgent")
space.add(MyAgent, "MyAgent")
# The agents above can now communicate

These are just the basic features that Agency provides. For more information please see the help site.

Install

pip install agency

or

poetry add agency

The Demo Application

The demo application is maintained as an experimental development environment and a showcase for library features. It includes multiple agent examples which may communicate with eachother and supports a "slash" syntax for invoking actions as an agent yourself.

To run the demo, please follow the directions at examples/demo.

The following is a screenshot of the Gradio UI that demonstrates the example OpenAIFunctionAgent following orders and interacting with the Host agent.

Screenshot-2023-07-26-at-4-53-05-PM

Contributing

Please do!

If you're considering a contribution, please check out the contributing guide.

Planned Work

See the issues page.

If you have any suggestions or otherwise, feel free to add an issue or open a discussion.

Metadata

Release files for agency 1.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agency 1.6.3
File Size Uploaded
agency-1.6.3.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agency 1.6.3
File Interpreter ABI Platform
agency-1.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.7 kB

Release files / agency-1.6.3.tar.gz

Download URL agency-1.6.3.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c4e8392ee628c628ef05c41e0d579d53778cbc46f8aef8e942407dec4c70dd2c
BLAKE2b-256 checksum
How to use checksums
816ae6500c20ac3dcf5bc123b70bfbd7acaf14b1c3f6822849754327f55dbe12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.12 Linux/6.5.0-1018-azure

Release files / agency-1.6.3-py3-none-any.whl

Download URL agency-1.6.3-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9087dc7b6c3c5332303019a6921413c3e1b0fdeec9502777fe845fe7880c26f
BLAKE2b-256 checksum
How to use checksums
393105c87e235ac902852b4ebda382a09f16ea8384b4bf698c4e6bbd0fbba9bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.12 Linux/6.5.0-1018-azure

Release history Release notifications | RSS feed

This release

1.6.3 This release

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page