Author(s): Francisco Bueno.

An agent is an active module which has a main execution thread. Simultaneously (i.e., in concurrent execution with the main thread), the agent receives messages from other agents, which trigger the execution of a predicate by the name of the message. Messages can also be sent to other agents, by calling the predicate by the name of the message in the context of the receiver agent (see ::/2 below). Agents are identified by name. The name of an agent is usually the name of its (main) file, but this depends on the protocol used (see protocol/1 below).

A simple agent that sends inform messages and at the same time receives them from other agents, answering back ok, will look like:

:- agent(simple,[inform/2,ok/1]).
:- protocol('actmods/filebased').

agent :-
    display('Agent id:message?- '), read(Agent:Mess),

    display(Agent), display(' has sent: ', display(Mess), nl,


Usage and interface

  • Library usage:
    :- agent(AgentName,[Message|...]).
    for the main file of the agent.
    :- use_module(library(agent(agent_call))).
    for the rest of modules of the agent that need to send messages.
  • New operators defined:
    ::/2 [550,xfx].
  • New declarations defined:

Documentation on new declarations

A protocol is formed by a pair of modules which allow to locate connection addresses of agents. By convention, the names of these modules have a common prefix, which makes reference to the protocol, and have suffixes '_locate' and '_publish'. The 'publish' part of the protocol must define a multifile predicate save_addr_actmod/1 and the 'locate' part export a predicate module_address/2. The first one publishes an agent address; the second one locates the address of an agent. Together, both make it possible for agents to send and receive messages. All agents in a multi-agent system must therefore use the same protocol. Upon compilation, they will then be (automatically) instrumented as active modules under the corresponding rendezvous method.

Usage: :- protocol(Protocol).

  • Description: Protocol is the prefix to a library path where an active module rendezvous protocol can be found.

Documentation on multifiles


The predicate is multifile.

Usage: save_addr_actmod(Address)

  • Description: (protocol defined) publishes the agent's Address.

Documentation on internals


Usage: module_address(Agent,Address)

  • Description: (protocol defined) gives the Address of Agent.

No further documentation available for this predicate.

No further documentation available for this predicate.

Other information

This package is intended as a sample of how to program agents in Ciao, based on active modules. It probably lacks many features that an agent might need. In particular, it lacks language-independence: it is thought for multi-agent systems where all agents are programmed in Ciao.

You are welcome to add any feature that you may be missing!


A platform is an active module which holds connection addresses of agents in a multi-agent system. A protocol is provided which enables the use of platforms: agent/platformbased. A suitable platform must be up and running when agents which run under this protocol are started up. The host id and port number (IP address/socket number) of the platform must then be given as arguments to the agents executables. The protocol also allows to give an agent name to the agent upon start-up. A module suitable for a platform can be found in library(actmods/examples/webbased_server/webbased_server).

Known bugs and planned improvements

  • Currently, the agent has to be compiled explicitely as an active module. The same protocol than in the agent source code must be used for this. Automatic compilation is not working.
  • It seems that there are running-ahead problems with threads that prevent to correctly publish agent addresses, sometimes.