Implementing Agents in JavaScript
Timotheus Kampik
TL;DR
This work addresses the challenge of making agent-oriented programming practical in JavaScript by presenting both from-scratch and library-based (JS-son) approaches to reasoning-loop agents and multi-agent systems. It introduces core abstractions (beliefs, percepts, plans) and demonstrates belief revision and plan deliberation, including LLM-enabled agents, within single-agent and multi-agent contexts. Concrete examples include a vanilla JavaScript porter agent, a JS-son LLM agent, centralized Game of Life MAS, and distributed MAS using WebSockets, illustrating cross-environment applicability. The chapter argues for JavaScript as an accessible platform for agent technologies, highlights the potential for edge and cloud deployments, and outlines future directions that connect traditional AOP with modern LLM-agent patterns and library maturation.
Abstract
This chapter gives an introduction to agent-oriented programming in JavaScript. It provides an example-based walk-through of how to implement abstractions for reasoning loop agents in vanilla JavaScript. The initial example is used as a stepping stone for explaining how to implement slightly more advanced agents and multi-agent systems using JS-son, a JavaScript library for agent-oriented programming. In this context, the chapter also explains how to integrate reasoning loop agents with generative AI technologies--specifically, large language models. Finally, application scenarios in several technology ecosystems and future research directions are sketched.
