Gnosis Labs: Developing an autonomous agent


From Gnosis by Gnosis

Introduction

This is the second post by the Gnosis Labs team - if you haven’t yet, take a look at the inaugural post by the team, where we introduce our work.

In this article, we aim to shed some light into one of the agents we are building, the General Agent (link to repo), which can autonomously read information on-chain (e.g. balances, positions) as well as interact with protocols (e.g. place bets and redeem winnings on Omen, a prediction market running on the Gnosis chain).

The Concept of the General Agent

The idea behind the General Agent (as the name says) was to make it as general as possible, i.e. we wanted to answer the question, “Is it possible to have an agent that behaves like a living organism on-chain, which tries to survive, evolve and reproduce”?

The question above can be controversial (see a great video on this topic), but we focus here on the technical side of it - if we were to have such an agent, what kinds of tools would we have to provide to it so that it can fulfill its goals?

The first goal (”survive”) is closely related to earning money, because if it has a zero balance, then the agent will lose its ability to execute any reasonable actions on the blockchain due to its inability to pay fees.

The initial way we envision the agent to make money (among an ocean of other possible ways) is to bet on prediction markets, more specifically on Omen. If the agent has a reasonable accuracy, then it’s expected that it will earn a positive amount of money over time, hence it will be able to survive.

We note that the major source of costs for the agent is related to API calls to LLM providers, specially OpenAI (roughly $0.25 per run). For further explanation in this blog post, we neglect these AI inference costs.

Blazing fast introduction to Prediction Markets

Prediction markets (link) are markets where people can speculate on top of future events. They are very similar to future contracts, however the event they are tracking does not need to be a price of a financial asset.

Prediction markets have several use-cases: they can be used for futarchy (link) to guide government decisions; they can be used for speculating on top of sport events, and several others.

For our ensuing agents discussion, we will restrict our analysis to prediction markets that follow the Constant Product Market Maker (CPMM) mechanism (link), which in turn closely resembles the mechanism of Automated Market Makers (AMM).

Without entering the nitty gritty math details, the basic idea is the following: