Stuart Farmer

Evolutionary algorithms, adaptive systems, and tools for quantitative research.

Selected projects

8 projects

2026

Hacking the Economy with AgentsEvolving agentic swarms to simulate income and economic inequality and pen-test organizational incentives and social exploitsGitHub, Demo Video - Ongoing

Project Description

  • It's no secret that the world is a bit of a tough place right now. One of those reasons, arguably, is that the system is not working for everyone. However, divising or measuring a new economic or social system has to take in a myriad of factors that are all intertwined and dependent on one another.

  • Luckily, agents offer a potential solution. They can model complex thinking patterns and cover a broader behavioral space than traditional explicit agent-based modelling solutions where each type of player must be explicitly determined prior. We therefore can propose new social and economic systems, encoded into a blockchain where value and 'businesses' in the form of smart contracts can be created, and then measure the economic factors for things like wealth inequality and link that back to the initial conditions and designs of the system.

    Each agent receives currency, context, goals, and tasks. For a fixed number of steps, agents take turns reading the ledger and acting under the policy. Researchers use the final balances and transaction history to measure wealth creation and inequality and score the policy. Adjusting the economic parameters returns the workflow to agent initialization. Otherwise the experiment ends. Agents receive currency, context, goals and tasks. Under fixed policy rules, agents take turns reading the ledger and acting for a fixed number of steps. Researchers score wealth creation and inequality. Changed parameters start a fresh run with newly initialized agents.
    The standard workflow the agentic swarm and researchers follow when interacting with a blockchain or other standardized environment.
  • I am currently leading a team and developing the core technology for this type of system. We've demonstrated agentic swarms in a Runescape virtual economy specializing and improving as a group over time. They explore, create their own skills, and come up with novel strategies to making money.

  • We can change the fitness function to success rate in security testing and have a 'red team versus blue team' product designed for organizations. Phishing, impersonation, and leveraging organizational exploits do more economic damage to companies than explicit technical penetrations which can be patched more easily.

Skills used
Multi-agent systems, evolutionary computation, fitness function design, fitness-proportionate selection, agent-based economic modeling, experimental validation, project management, experiment design
Technology
TypeScript, Node.js, Bun, SQLite, Docker Compose, RuneBench
EliteTableApplying a leaderboard-like self-improving agentic strategy to classic control problems and blackjackGitHub, arXiv, Breakdown -

Project Description

  • While using self-improving agents, I discovered that often times elites were not weighted properly according to the simplicity of the task at hand. As a result, I often spent way more time generating solutions, burning tokens, and wasting compute to evaluate around the solution rather than just adding a bit more 'hill-climbing' to the equation.

  • My solution was to design an agent that retained a fix table of elites that were always randomly drawn from for selection. New candidates that out-performed any of the existing elites were placed in their earned spot on the leaderboard, kicking out the lowest scoring elite.

    The elite table supplies parents for edits and remixes. The proposer can also invent a policy from scratch. Failed candidates can return for repair. Scored candidates compete with incumbents for the top K places. An empty elite table starts with invention. Later, the proposer can invent, edit one sampled elite or remix several. The evaluator checks the candidate on shared seeds. A failure can be repaired within the retry budget. At generation end, scored candidates compete with incumbents to fill the top K places.
    The first generation invents every policy. Once the table has elites, edits and remixes draw parents uniformly. At the end of each generation, candidates compete with incumbents on mean reward across the same episode seeds.
  • The loop was simple, but performed reasonably well on control tasks which can often times be hard for discrete policies to solve. I published a preprint covering 60 independent searches across six Gymnasium control tasks. Parallel workers evaluated 30,000 candidates total and tracked their in and out of sample performance.

  • The search improved, or solved, five of the six tasks, while failing to find a usable out-of-sample policy for one. I independently applied the optimier to a finite-shoe blackjack problem using no context about how to play. After 2,500 proposals, the end result was a policy that tracked Hi-Lo count and used an adaptive betting strategy. The policy performed profitably in and out of sample for all seeds.

Skills used
Evolutionary program synthesis, meta-optimization, genetic operator design, elite selection, held-out evaluation
Technology
Python, RSIKit, Gymnasium, GPT-OSS-120B, SQLite
Slick BitsExecutable Implementations of 152 Research MethodsGitHub -

Project Description

  • I adapted 152 published methods for evolutionary search, planning, and prompt optimization into Python agents built with Slick. Each package has its own test module. A feedback optimizer I developed alongside the published methods brings the collection to 153 packages, giving researchers working implementations they can inspect directly, run on their own tasks, and extend.

  • Each agent defines how to propose candidates, select among them, and decide when to stop. Callers supply the task and any evaluator the method requires. I traced six implementations into RSIKit’s shared optimizer interface, including Promptbreeder, ReEvo, and STOP, for evaluation on the same tasks with matching episode seeds.

  • ReEvo compares two candidates with different scores and asks what the stronger one did better. That reflection guides how it combines the parents into a new candidate. QUBE groups candidates by observed behavior, then chooses where to search next using the average quality of each group’s offspring and an exploration bonus that favors groups with fewer trials.

  • I tested AlphaEvolve on circle packing, maximizing the sum of ten circles’ radii while fitting them inside a square. Over 25 attempts across four islands, the best sum rose from 1.000 to 1.591. Every circle fit inside the square, and none of the 45 pairs overlapped.

Skills used
Evolutionary computation, hyper-heuristics, program synthesis, research implementation, constrained optimization
Technology
Python, Slick, Jinja2, OpenAlex API, DataLab OCR
MAKERHierarchical Generation with Language-Model VotingGitHub -

Project Description

  • I built a Python engine that extends MAKER’s sequential voting procedure to open-ended generation. Given a topic and a target count, the engine asks a language model to organize the collection before writing its entries. The same process generated trading strategies across five scientific disciplines and produced research briefs for work on control and adaptive systems.

    The engine requests candidate splits, checks their categories and quotas, then asks model judges to vote. It tallies each vote and can request another.
    At the root of the trading-strategy tree, judges voted on five valid splits. Voting stopped when the leading split reached eight votes and the runner-up had five, satisfying the required three-vote lead.
  • A shared interface lets me reuse the engine across tasks. Each task supplies rules for splitting a branch, judging proposals, and deciding when to stop. The engine handles sampling and voting as it works down the tree. That division lets a researcher try different ways of organizing the same collection while keeping the voting procedure and the target count fixed.

    The elected ARIMA split assigns eight slots across five child briefs. The Standard ARIMA brief has two slots and produces two descriptions.
    Judges voted on this split as a whole. The five child quotas add up to eight. The two titles under Standard ARIMA come from the descriptions generated for that brief.
  • In taxonomy-local, each branch proposes its own categories. Python rejects splits whose quotas fail to add up, then model judges weigh the remaining proposals for coverage and overlap. In taxonomy-global, judges elect a sequence of dimensions for the whole tree. Researchers can pin one dimension, let the model discover the rest, and reuse the saved sequence.

    Scatterplot of 500 trading-strategy descriptions. Control Theory clusters on the right, while Statistics and Econometrics overlap on the left. Scatterplot of 500 trading-strategy descriptions. Control Theory clusters on the right, while Statistics and Econometrics overlap on the left.
    Each point represents one description. Color and shape identify its parent discipline. The first two principal components capture 17.4% of the variation in the text embeddings.
  • Starting from one brief for 500 trading strategies, the engine allowed up to 20 attempts to collect five valid proposals per split. All 171 splits preserved their quotas, yielding 500 descriptions with no exact duplicates. My audit of the tree uncovered a category error. The judges had accepted ARIMA variants as trading horizons.

Skills used
Hierarchical planning, agent workflow design, sequential voting, taxonomy induction, constrained generation
Technology
Python, asyncio, OpenRouter, GPT-OSS-120B, GPT-4.1 mini
MordecaiA peer-to-peer development ecosystem for everyoneGitHub, Testnet, Docs -

Project Description

  • The peer-to-peer and blockchain communities, ironically, don't mix. The ideologies of true peer-to-peer are rooted in personal librerties, but understand unfettered economic liberty leads to people being free to stifle others' personal liberties. Yet, funding, distribution, and true opportunties generally lie in the blockchain space.

  • Mordecai is my solution to that problem. It makes peer-to-peer application development extremely simple through a clean SDK and API while allowing for native payments and smart contracts, only when the developer or community wants them.

    A file drop runs independently. A dataset repository can send state commitments and use settlement currency. A chess tournament can settle bets through its own wager contract. A whistleblower file drop works entirely among its peers. A community dataset repository commits state and can use settlement currency for donations and bounties. A chess tournament connects through its own contract to settle wagers. The settlement layer uses the same core P2P app unit.
    Each app has its own peers. A file drop can run entirely among its users, a dataset repository can pay bounties on L1, and a chess tournament can use its own L1 contract to settle wagers.
  • I leveraged the Pears ecosystem from Holepunch to provide the networking and state primitives required and CosmWASM from the Cosmos project for a deterministic atomic computing sandbox. I also built a Pythonic DSL for CosmWASM to allow for faster smart contract development.

    Files, transactions and state requests enter the interface. Core app logic reads and writes distributed state. Files, transactions and state requests enter the interface. The interface exchanges data with core app logic, which reads and writes distributed state.
    Users interact through an app-defined API. The app’s peers replicate its state and serve it to other users.
  • In many ways, it is the spiritual successor of what I actually wanted to build when running Lamden, my last layer-one blockchain company. Transactions per second hit 10,000, smart contracts are legible and easy to build, and the chain is cheap and developer focused. It only came about, unfortunately, several years after closing down my prior company.

Skills used
Peer-to-peer networking, distributed state management, mechanism design, blockchain architecture, programming language design, context-free grammars
Technology
Python, Backus–Naur Form (BNF), Rust, CosmWasm, TypeScript, Pear SDK
High-Frequency ResearchEvolving Market-Making Policies and Testing Executable Bitcoin SpreadsProprietary Research -

Project Description

  • I built a replay system to test Bitcoin market-making policies and studied whether trading the gap between spot and perpetual prices paid after costs. One simulated hedge illustrates why attribution mattered. It gained $3,237.65 before spot fees, but the spot holding contributed $3,308.84 and the futures premium cost $71.19.

    Illustrative one-bitcoin trade. Sell spot at $100,200 and buy the perpetual at $100,000. Five minutes later, buy spot at $100,100 and sell the perpetual at $100,070.
    Illustrative prices for one bitcoin per leg. The entry gap of $200 narrowed to $30. Selling spot earned $100 and buying the perpetual earned $70, leaving $170 before fees on the four fills.
  • Separating quote decisions from order handling let me test new policies with the same replay engine. Each policy could request up to 32 orders through a Numba interface. Stable identifiers let the engine keep an unchanged bid in the queue, replace it when its price or size changed, or cancel it when the policy withdrew it.

    One policy decision describes up to 32 quotes. In this example the engine keeps Bid 1, modifies Bid 2, cancels Ask 1, and submits Ask 2. Fills update the next decision.
    Several quotes can rest in the book at once. The engine checks the whole desired set before sending changes, and modifies or cancels a resting order only when the exchange model allows it.
  • My ShinkaEvolve search rewarded fills farther from the midpoint and penalized inventory exposure. The Bybit spread replay priced both legs at the next executable quotes. Across 659 updates around 19 gaps on two days, only 19% yielded a profit after costs. The median five-minute trade lost 5.21 basis points.

    The raw score sums fill rewards less inventory penalties, then deducts 100 per trade short of 1,000. For a nonnegative raw score, the search score is one plus the raw score divided by 10,000. For a negative raw score, it is ten to the minus twelve plus the reciprocal of one minus the raw score divided by 10,000.
    The evaluator adds up step rewards and deducts the trade shortfall penalty to get the raw score. It then converts that total into the fitness score ShinkaEvolve uses. In the conservative replay, 43,238.40 raw points gave a search score of 5.32384. Simulated portfolio profit was 50.64 evaluator units.
  • After a 100-generation search, I replayed one policy on three Bybit days. Both profiles cleared the 1,000-trade target with zero invalid actions. Stricter execution assumptions cut simulated profit 49%, from 99.64 to 50.64 evaluator units. Live profitability remains untested.

Skills used
Island-model evolution, fitness function design, market microstructure, order reconciliation, execution simulation, basis attribution
Technology
Python, Numba, Rust, ShinkaEvolve, HftBacktest, Parquet, WebSockets
RSIKitDevelopment kit for rapid prototyping, evaluation, and deployment of self-improving agentsGitHub, DeepWiki -

Project Description

  • Self-improving agents all follow a similar "select - propose - evaluate" optimization loop. However, there has yet to be standardization around this. Abstracting this concept out allows for a more streamlined environment to tinker, propose, combine, and remix ideas across all domains to see how they effect baseline self-improvement behavior.

  • The project evolved from the need to test many small additions to the ShinkaEvolve algorithm, but not needing any of the boilerplate around it. Isolating the actual agentic loops from other implementations is no easier.

    A script supplies an optimizer or a metaoptimizer proposes one. The optimizer proposes a candidate policy. For each seed, its Solution instance acts in the environment and observes each transition until the episode ends. Episodes feed back to the optimizer after each round. When search finishes, the outer experiment scores the run. A script or metaoptimizer supplies an optimizer. Each candidate runs an act-and-observe loop per seed. The optimizer updates from episodes until the search ends. The experiment scores the run for reporting or for the next metaoptimizer proposal.
    A script can test a fixed optimizer and report how its best policy performs on held-out seeds. A metaoptimizer can use the same result to choose which optimizer to try next.
  • I designed a Python SDK that leveraged my previous agentic SDK, Slick, to create the higher level abstractions needed to easily create complex self-improving loops and experiment with their architecture. This makes things like ablation and comparative studies so much easier. It also allows self-improving agents to be part of higher order agentic systems, rather than being the entire program.

Skills used
Developer experience design, recursive self-improvment, evolutionary computing, optimizer design, abstraction, system design
Technology
Python, Gymnasium, NumPy, Slick, Pydantic