The Universal Language for AI Agents

AgentML is to agent frameworks what HTML is to web browsers. Write your agent's behavior once and run it anywhere—ending the cycle of costly rewrites caused by framework fragmentation.

The Problem: Framework Fragmentation

The AI agent landscape is fragmented and accelerating, with new frameworks appearing weekly. This creates vendor lock-in and forces costly rewrites when a chosen framework becomes limiting or unmaintained.

AgentML : Agent Frameworks = HTML : Web Browsers

Just as HTML lets you write content once and have it render in any browser, AgentML lets you define your agent's behavior once and run it anywhere. This is achieved by building on the battle-tested W3C SCXML standard, a formal model for state machines that has been proven for over 20 years in complex industrial systems.

By separating behavior from runtime, your agents outlive framework trends.

Key Features

Deterministic Behavior
AgentML uses SCXML state machines to define deterministic behavior, moving beyond prompt-only approaches where behavior is emergent and unpredictable. Explicitly define valid states, transitions, and the agent's lifecycle for formal verification and testing.
Schema-Guided Events
LLM outputs are constrained to structured JSON events validated against schemas using the event:schema attribute. This ensures reliability and type safety, with detailed descriptions guiding LLMs to generate correct event data.
Efficient Token Usage
The runtime provides the LLM with a "snapshot" of the current state, datamodel, and available events. This context allows prompts to be minimal, and the static parts (the agent's SCXML definition) can be cached by the LLM provider, reducing token consumption.
Modular & Composable
Complex agents can be broken down into smaller, reusable state machines using the <invoke> tag. This is ideal for managing complexity and sharing components like authentication or payment processing.
Extensible Namespaces
Functionality is extended through namespaces (e.g., for Gemini, Ollama, Memory) declared with the import:prefix="uri" directive. Plug in custom functionality for LLMs, memory, I/O, and more.
Write Once, Deploy Anywhere
Run agents with agentmlx, the native Go/WASM runtime, or transform to other frameworks like LangGraph, CrewAI, and n8n (planned). This provides framework insurance, eliminating vendor lock-in and allowing you to choose a runtime based on deployment needs, not sunk costs.

Why AgentML?

The core promise of AgentML is to end the cycle of constant rewrites caused by framework fragmentation. By providing a universal agent definition language built on proven standards, AgentML gives you framework insurance.

Write your agent logic once in AgentML, then run it natively with the high-performance agentmlx runtime (Go/WASM), or transform it to integrate with existing ecosystems like LangGraph, CrewAI, or n8n. Your choice of runtime is based on deployment needs, not sunk costs or vendor lock-in.

By unifying LLMs with state machines, AgentML provides the best of both worlds: the creativity of AI and the reliability of software engineering. This consistency accelerates development and facilitates a growing ecosystem of shareable, reusable agents.

Simple Example

<agentml xmlns="github.com/agentflare-ai/agentml"
       datamodel="ecmascript"
       xmlns:gemini="github.com/agentflare-ai/agentml-go/gemini">
  
  <datamodel>
    <data id="user_input" expr="''"/>
    <data id="response" expr="''"/>
  </datamodel>

  <state id="main">
    <state id="awaiting_input">
      <onentry>
        <assign location="user_input" expr="getUserInput()"/>
      </onentry>
      <transition target="processing"/>
    </state>

    <state id="processing">
      <onentry>
        <gemini:generate model="gemini-2.0-flash-exp"
                        location="_event"
                        promptexpr="'Process: ' + user_input"/>
      </onentry>
      <transition event="action.response"
                  event:schema='{"type":"object","properties":{"message":{"type":"string"}}}'
                  target="responding"/>
    </state>

    <state id="responding">
      <onentry>
        <assign location="response" expr="_event.data.message"/>
        <log expr="'Response: ' + response"/>
      </onentry>
      <transition target="awaiting_input"/>
    </state>
  </state>
</agentml>

Example Use Cases

AgentML is suitable for complex, long-running AI agents that require structured decision logic. Examples include:

  • Multi-step customer support bots with flows for checking policies, booking flights, and more
  • Autonomous research agents that invoke specialized sub-tools and coordinate complex workflows
  • Agent swarms with supervisor-worker delegation patterns
  • Any scenario where you need the AI to follow a strict, auditable workflow

See the provided examples (e.g., a full customer support bot with flight, hotel, and rental booking flows) for real-world AgentML implementations.

Getting Started

Installation
Set up AgentML in your project
Quick Start
Build your first agent in minutes
Core Concepts
Understand state machines and events