Skip to main content

KQML messaging classes in Python.

Project description


PyKQML is an implementation of KQML messaging in Python.


PyKQML can be installed as

pip install pykqml

Note that releases of PyKQML up to 0.5 work in Python 2 only, whereas releases above and including 1.0 work in Python 3 only.

To install for Python 2, use:

pip install pykqml==0.5

To install for Python 3 (or force an upgrade to a compatible version), use

pip install "pykqml>0.5"


PyKQML implements the following KQML classes, which allow constructing and manipulating KQML messages programmatically:


You can import KQML classes as, for instance,

from kqml import KQMLList

You can create a new KQML messaging agent in the context of the TRIPS system as

from kqml import KQMLModule

class MyAgent(KQMLModule):
    name = "MyAgent" # This is the name of the agent to register with

    def __init__(self, **kwargs):
        # Call the parent class' constructor which sends a registration
        # message, setting the agent's name to be recognized by the
        # Facilitator.
        super(MyAgent, self).__init__(, **kwargs)

        # Subscribe to REQUESTs of interest. The list will change
        # depending on the role of the agent
        for req in ('what-next', 'commit', 'evaluate'):

        # Subscribe to TELLs of interest if needed. This list will change
        # depending on the role of the agent
        for tell in ('log-speechact', ):

        # Now signal that the agent is ready to receive messages

        # Finally, start the listener for incoming messages

    def receive_request(self, msg, content):
        # First, figure out what kind of request this is
        task = content.head().upper()
        # Here you typically decide what to do based on the
        # type of request.

        # Construct reply message's content
        reply_content = KQMLList()
        # Set whatever needs to be set in the reply content

        # Finally, wrap the content in a message and reply
        reply_msg = KQMLPerformative('reply')
        reply_msg.set('content', reply_content)
        self.reply(msg, reply_msg)


You can run all tests by running nosetests in the top level folder.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pykqml, version 1.3
Filename, size File type Python version Upload date Hashes
Filename, size pykqml-1.3-py3-none-any.whl (16.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pykqml-1.3.tar.gz (15.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page