Skip to content

agentlang-ai/agentlang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

日本語 | Español | français | Deutsch | Português | Русский | 한국어 | 中文

    Agentlang - Reliable Enterprise AI Agents

Node Version CILicense npm downloads


Agentlang - Team as Code

Agentlang is a declarative DSL (built on TypeScript) for creating AI Agents and full-stack Agentic Apps. With Agentlang, you define, version, run, mentor, and monitor teams of AI agents, along with the app infrastructure they need: data model, workflows, RBAC, integrations, and UI. We refer to this approach - bringing together AI agent development and App development into a single coherent discipline - as Team-as-Code (our riff on IaC).

  • For Devs and Non-Devs: Code and vibe-code in your IDE, focusing on the business-logic of your app, not wiring. Alternatively, you can build, run, mentor and monitor your AI Team in Studio - our visual-builder (coming soon). Switch back-and-forth between the two modes seamlessly.

  • Robust Integrations: The Agentlang runtime ships with native integrations for LLMs, databases, vector DBs, and auth providers. Our connector architecture is built for the enterprise, with a rapidly growing catalog for systems like Salesforce, ServiceNow, HubSpot, Snowflake, and more. Also, because Agentlang compiles to Node.js (and runs in the browser), you can use any existing JavaScript library out of the box.

  • Production-grade: Under the hood, it’s all modern TypeScript—strong typing, tooling, testing, and CI/CD-friendly workflows—built for enterprise-class reliability, governance, and scale.

Agentlang introduces two foundational innovations: Agentic Reliability Modeling and AgentLang Ontology

Agentic Reliability Modeling
  • First-class AI Agents
  • Flows
  • Decisions
  • Directives
  • Scenarios
  • Glossary
image
Agentlang Ontology
  • Data Model
  • Auto-gen CRUD
  • Events & Workflows
  • Declarative RBAC
  • Auto-gen UI

🎯 Agentic Reliability Modeling

Build AI Agents that actually work!

Build teams of reliable AI Agents that follow your organization's processes closely, while adapting to new scenarios. Agents collaborate with each other and humans to handle complex, time-consuming, monotonous tasks and get work done!

Depending solely only on instructions for agents is a recipe for failure. Natural language is beautiful, but ambiguous - forcing us to be stuck in an endless cycle of prompt-tweaking to achieve our goal. Agentlang offers just enough structure, to augment natural language instructions, to model various aspects of your agents - unambiguously, but still effortlessly - to make them reliable.

An Example

flow TicketFlow {
    ticketTriager --> "DNS" ticketInProgress
    ticketTriager --> "WLAN" ticketInProgress
    ticketTriager --> "NotEnoughInfo" ticketPending
}

agent TicketFlow {
    llm "gpt4o",
    role "You are a network ticket management application. Your job is to triage any ticket passed to you
          and update the ticket with appropriate assigned_to, status and triaging comments.",
	glossary [
		{"name": "incident", "meaning": "a problem report", "synonyms": "ticket"},
		{"name": "task", "meaning": "a record that captures some work that needs to be done", "synonyms": "ticket"},
		{"name": "DNS", "meaning": "Domain Name Service - is used to translate human-readable domain names to IP addresses", "synonyms": "DNS name, CNAME, DNS HOST record"}
		{"name": "WLAN", "meaning": "Wireless LAN - wireless network to connect devices to each other and the internet", "synonyms": "Office network"}
    ]
}

decision ticketTriager {
   case ("Ticket is related to DNS provisioning. If the request is to point one host/DNS name to an IP address") {
      DNS
   }
   case ("Ticket is related to WLAN provisioning. If the request is to add/whitelist a MAC address on the wireless network") {
      WLAN
   }
   case ("There is not enough information in the ticket about what the category is") {
      NotEnoughInfo
   }
   default {
      Other
   }
}

workflow ticketInProgress {
    // workflow body is declarative code that is executed by the symbolic runtime
    ...
}

✨ First-class AI Agents

Agents and many concepts agents use are built-in language constructs.

agent TicketFlow {
    llm "gpt4o",
    role "You are a network ticket management agent. Your job is to triage any ticket passed to you and
          update the ticket with appropriate assigned_to, status and triaging comments."
}

directive TicketFlow {
    if ("the context indicates the ticket as handled") {
        "set status to done"
    }
}

Flows

Flows are central to Agentlang's reliability modeling. Define your business processes using an intuitive flow syntax - flows guide (not enforce) an agent's behavior closely. Agentlang's adaptive runtime will execute them, dynamically adapting the execution flow as needed.

Each step in the flow can be an agent or a tool (workflow).

flow networkProvisioningRequestManager {
    classifyProvisioningRequest --> "DNS" provisionDNS
    classifyProvisioningRequest --> "WLAN" provisionWLAN
    classifyProvisioningRequest --> "Other" reportFailure
    provisionDNS --> ticketUpdater
    provisionWLAN --> ticketUpdater
}

Decisions

An agent that takes a decision for branching in a flow can be expressed as a decision table of case expressions. Each case specifies a condition as pure text or a logical expression. The consequence of a case will be a tag that tells the flow-evaluator which node to branch to.

decision classifyOrder {
    case ("if requested car type is SUV and customer tier is premier") {
      LuxurySUV
    }

    case ("if the requested car type is SUV and segment is economy") {
      EconomySUV
    }
}

flow carOrderRequestManager {
   analyseCarOrderRequest --> classifyOrder
   classifyOrder --> "EconomySUV" orderEconomySUV
   classifyOrder --> "LuxurySUV" orderLuxurySUV
}

The case conditions may also be written as logical expressions:

   case (carType == "SUV" and segment == "luxury") {
      LuxurySUV
   }

   case (carType == "SUV") {
      EconomySUV
   }

As the flow executes an agent that specializes in evaluating decision tables will be invoked for the node classifyOrder. The tag returned by this agent will be used to select either the orderEconomySUV or orderLuxurySUV node of the flow.

Directives

Directives enhance the decision making capability of agents by providing precise actions to be taken under specific conditions.

agent salaryHikeAgent {
    instruction "Give an employee a salary-hike based on his/her sales performance",
    tools acme/employee
}

directive salaryHikeAgent.hike5p { if ("employee sales exceeded 5000") { "Give a salary hike of 5 percent" }}
directive salaryHikeAgent.hike2p { if ("sales is more than 2000 but less than 5000") { "hike salary by 2 percent" }}

As the salaryHikeAgent tries to compute the salary-increment for a particular employee, the directives will guide it to take a more accurate decision based on specific conditions.

Scenarios

Scenarios provide agents with concrete examples of user-requests and their corresponding LLM-responses.

agent salaryHikeAgent {
    instruction "Give an employee a salary-hike based on his/her sales performance",
    tools acme/employee
}

directive salaryHikeAgent.hike5p { if ("employee sales exceeded 5000") { "Give a salary hike of 5 percent" }}
directive salaryHikeAgent.hike2p { if ("sales is more than 2000 but less than 5000") {  "hike salary by 2 percent" }}

scenario salaryHikeAgent.outperform {
    if ("Jake's sale exceeded 5000") {
        handleOutperform
    }
}

workflow handleOutperform {
  {acme/employee {email? "jake@acme.com"}} @as [employee];
  {acme/employee {id? employee.id,
                  salary employee.salary + employee.salary * 0.5}}
}

Here, the provided scenario helps the agent to take a well-specified action in the case an employee is said to have "outperformed".

Glossary

Glossaries help the agent understand the meaning of domain-specific vocabulary that the user may use while interacting with the agent.

agent campaignAnalyzer {
    instruction "Evaluate and optimize marketing campaign performance based on key performance indicators (KPIs) and assign a performance rating",
    tools acme/campaign_eval,
    // ...
}

glossaryEntry campaignAnalyzer.entry1 {
    word "outstanding",
    meaning "CTR ≥ 5%, Conversion Rate ≥ 10%, ROI ≥ 50%",
    synonyms "exceptional, high-impact"
}

glossaryEntry campaignAnalyzer.entry2 {
    word "satisfactory",
    meaning "CTR 2-4.9%, Conversion Rate 5-9.9%, ROI 20-49%",
    synonyms "solid, effective"
}

glossaryEntry campaignAnalyzer.entry3 {
    word "underperforming",
    meaning "CTR < 2%, Conversion Rate < 5%, ROI < 20%",
    synonyms "needs improvement, low-impact"
}

Agentlang Ontology

Agentlang's sophisticated modeling capabilities allow you to design the data-schema, workflows and access control constructs of your application in a declarative way. Agents can work directly with this ontology and dynamically generate business workflows, making your application into a living system that constantly adapts to new requirements and demands.

This simple blogging application demonstrates Agentlang’s powerful data modeling and agent integration capabilities.

module blog.core

entity Post {
    id UUID @id @default(uuid()),
    title String,
    content String,
    postedBy Email,
    createdAt DateTime @default(now()),
    @rbac [(roles: [manager], allow: [create, read])]
}

entity Comment {
   id UUID @id @default(uuid()),
   content String,
   postedBy Email,
   postedOn DateTime @default(now())
}

relationship PostComment contains(Post, Comment)

entity Category {
    id UUID @id @default(uuid()),
    name String
}

relationship PostCategory between(Post, Category)

@public agent postEditor {
    instruction "Create a new blog post based on the outline provided to you.",
    tools [blog.core/Post]
}

Entities like Post, Comment, and Category define a clear domain schema connected through declarative relationships such as contains and between. Access rules, like the @rbac annotation on posts, show how policies can be built directly into the model itself.

What makes this model special is how seamlessly an agent can interact with it — for instance, the postEditor agent can create new posts directly using the Post entity as a tool. This tight coupling between schema and agent logic allows intelligent automation to operate safely and predictably within a structured data framework.

To get started with Agentlang Ontology, please see the Agentlang Tutorial or explore the following example applications:

🚀 Getting Started

Installation

Install the Agentlang CLI globally using npm:

npm i -g @agentlang/cli

Running Agentlang Applications

# switch to example directory where package.json is located
cd example/blog

# Parse and validate an Agentlang file present in that directory
agent parseAndValidate blog.al

# Run the app
agent run

👨‍💻 Development

For contributors who want to build and develop Agentlang itself:

Setup

# Install dependencies
npm install

OR

# Install pnpm: https://pnpm.io/installation
# Use pnpm
pnpm install

Note: If pnpm shows build script warnings, run pnpm approve-builds and approve esbuild and sqlite3.

⚡ Build

# Generate parser and build
npm run langium:generate
npm run build

⚡ Test

# Run all tests
npm test

# Run tests with verbose output
npm run test:verbose

Run from Source

# Parse and validate an Agentlang file
node ./bin/cli.js parseAndValidate example/blog/blog.al

# Run a specific app
node ./bin/cli.js run example/blog

Code Quality

# Lint code
npm run lint

# Lint and auto-fix issues
npm run lint:fix

# Format code
npm run format

# Check formatting without changes
npm run format:check

Watch Mode

# Watch for changes and rebuild
npm run watch

About

Build Reliable AI Agents and Agentic Apps

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages