A programming language for AI agents
Write agents in minutes, not hours. Type-safe. Parallel. Observable.
agent Researcher {
systemPrompt: "You research topics thoroughly and cite sources."
model: "gpt-4o-mini"
}
let findings = Researcher.userPrompt("quantum computing 2025").run()
println(findings)AI agent frameworks require endless boilerplate. GENT is a dedicated language that makes agents first-class citizens.
| Python + LangChain | GENT | |
|---|---|---|
| Define an agent | 15+ lines of imports and setup | 4 lines |
| Parallel execution | Manual async/await, error handling | parallel { } block |
| Structured output | Runtime schema validation | Compile-time type checking |
| Tool definition | Decorators, docstrings, type hints | tool greet(name: string) -> string |
| RAG | Vector DB setup, chunking, retrieval | knowledge: { source: docs } |
| Error handling | Try/except scattered everywhere | try { } catch { } with agent context |
# LangChain: 20+ lines before you even start
from langchain.agents import create_react_agent
from langchain.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from langchain.tools import tool
llm = ChatOpenAI(model="gpt-4")
prompt = ChatPromptTemplate.from_messages([...])
# ... more setup ...// GENT: Just describe what you want
agent Helper {
systemPrompt: "You help users with their questions."
model: "gpt-4"
}
let answer = Helper.userPrompt("What is 2+2?").run()Declarative agent definitions with all configuration in one place:
agent DataAnalyst {
systemPrompt: "You analyze data and provide insights."
model: "gpt-4o-mini"
}
let insight = DataAnalyst.userPrompt("Analyze this: [1,2,3,4,5]").run()Type-safe tool definitions that agents can use:
tool add(a: number, b: number) -> number {
return a + b
}
tool multiply(a: number, b: number) -> number {
return a * b
}
agent MathTutor {
systemPrompt: "Help with math problems."
tools: [add, multiply]
model: "gpt-4o-mini"
}First-class knowledge base support with automatic context injection:
// Create and index a knowledge base
let docs = KnowledgeBase("./docs")
docs.index({
extensions: [".md", ".txt"],
recursive: true
})
// Agent with automatic RAG
agent DocHelper {
knowledge: {
source: docs,
chunkLimit: 5,
scoreThreshold: 0.7
}
model: "gpt-4o-mini"
systemPrompt: "Answer based on the documentation."
}
let answer = DocHelper.userPrompt("How do I configure tools?").run()Get typed responses from agents with compile-time validation:
struct Analysis {
sentiment: string
confidence: number
keywords: string[]
}
agent Analyzer {
systemPrompt: "Analyze text sentiment."
model: "gpt-4o-mini"
output: Analysis
outputRetries: 3
}
let result = Analyzer.userPrompt("I love this product!").run()
// result.sentiment, result.confidence, result.keywords are typedRun multiple agents concurrently with built-in timeout:
agent WebSearcher { systemPrompt: "Search the web." model: "gpt-4o-mini" }
agent NewsAnalyst { systemPrompt: "Analyze news." model: "gpt-4o-mini" }
agent AcademicSearcher { systemPrompt: "Find papers." model: "gpt-4o-mini" }
parallel research {
agents: [
WebSearcher.userPrompt("AI trends 2025"),
NewsAnalyst.userPrompt("AI news today"),
AcademicSearcher.userPrompt("latest AI papers")
]
timeout: 30s
}
let results = research.run() // Returns array of all resultsDefine enums with optional data and match on them:
enum Status {
Pending
Active
Completed
Failed(message)
}
let status = Status.Failed("connection timeout")
let message = match status {
Status.Pending => "Waiting..."
Status.Active => "Running"
Status.Completed => "Done!"
Status.Failed(msg) => "Error: {msg}"
}
// Check variants with .is()
if status.is(Status.Failed) {
println("Something went wrong")
}Define reusable functions with typed parameters:
fn formatName(first: string, last: string) -> string {
return "{first} {last}"
}
fn isPositive(n: number) -> boolean {
return n > 0
}
let name = formatName("John", "Doe")Full suite of functional array operations:
let numbers = [1, 2, 3, 4, 5]
// Transform with map
let doubled = numbers.map((x) => x * 2) // [2, 4, 6, 8, 10]
// Filter elements
let evens = numbers.filter((x) => x % 2 == 0) // [2, 4]
// Reduce to single value
let sum = numbers.reduce((acc, x) => acc + x, 0) // 15
// Find first match
let firstEven = numbers.find((x) => x % 2 == 0) // 2
// Chaining
let result = numbers
.filter((x) => x > 2)
.map((x) => x * 2)
.reduce((a, b) => a + b, 0)
// Other methods: indexOf, join, slice, concat, push, pop, lengthBuilt-in string manipulation:
let text = " Hello, World! "
text.trim() // "Hello, World!"
text.toLowerCase() // " hello, world! "
text.toUpperCase() // " HELLO, WORLD! "
text.split(",") // [" Hello", " World! "]
text.contains("World") // true
text.startsWith(" H") // true
text.replace("World", "GENT") // " Hello, GENT! "
text.length() // 17Graceful error handling with context:
try {
let result = RiskyAgent.run()
println("Success: {result}")
} catch error {
println("Failed: {error}")
}cargo install gent-langOr with Homebrew:
brew tap gent-lang/tap && brew install gent- Create a file
hello.gnt:
agent Greeter {
systemPrompt: "You are friendly and cheerful."
model: "gpt-4o-mini"
}
let greeting = Greeter.userPrompt("Say hello!").run()
println(greeting)- Set your API key:
export OPENAI_API_KEY="your-key-here"- Run it:
gent hello.gnt| Example | Description |
|---|---|
| hello.gnt | Minimal agent example |
| structured_output.gnt | Typed agent responses |
| parallel_agents.gnt | Run agents concurrently |
| rag_example.gnt | Knowledge base with auto-RAG |
| user_tools.gnt | Define custom tools |
| enum_examples.gnt | Enums and pattern matching |
| array_examples.gnt | Array methods and lambdas |
| functions.gnt | Function definitions |
| try_catch.gnt | Error handling |
Run any example:
gent examples/hello.gntRun with mock LLM (for testing):
gent --mock examples/hello.gntagent Name {
systemPrompt: "Instructions for the agent"
model: "gpt-4o-mini" // Required: LLM model
tools: [tool1, tool2] // Optional: available tools
output: StructName // Optional: structured output type
outputRetries: 3 // Optional: retry on parse failure
maxSteps: 5 // Optional: max tool call iterations
knowledge: { // Optional: auto-RAG configuration
source: knowledgeBase,
chunkLimit: 5,
scoreThreshold: 0.7
}
}tool name(param: type, ...) -> returnType {
return value
}fn name(param: type, ...) -> returnType {
return value
}enum Name {
Variant1
Variant2(field)
Variant3(a: type, b: type)
}parallel name {
agents: [Agent1.userPrompt("..."), Agent2.userPrompt("...")]
timeout: 30s // Required: 30s, 2m, 500ms
}
let results = name.run() // Array of resultsstruct Name {
field1: string
field2: number
field3: string[]
}// Conditionals
if condition {
// ...
}
// Pattern matching
let result = match value {
Pattern1 => expression1
Pattern2(x) => expression2
}
// Loops
for item in items {
// ...
}
while condition {
// ...
}
// Error handling
try {
// ...
} catch error {
// ...
}string, number, boolean, array, object, any
GENT follows these principles, in order of priority:
-
Agent-first — Agents are the primary abstraction, not an afterthought bolted onto a general-purpose language.
-
Fail fast — Catch errors at parse time, not in production. Type mismatches, missing fields, and invalid configurations are caught before your code runs.
-
Minimal boilerplate — If you're writing the same thing twice, the language should handle it. No decorators, no factory patterns, no dependency injection.
-
Observable by default — Tracing, logging, and debugging are built into the language, not libraries you have to configure.
-
One way to do things — Reduce cognitive load. There's one way to define an agent, one way to run it, one way to handle errors.
GENT is in alpha. The language is functional but:
- Syntax may change between versions
- Some features are still being developed
- Not recommended for production use yet
- Agent declarations
- Tool definitions
- Structured output
- Parallel execution
- Error handling (try/catch)
- Control flow (if/for/while)
- Functions
- Enums & pattern matching
- Array methods (map, filter, reduce, find, etc.)
- String methods
- Built-in RAG (knowledge field)
- Multi-model support (Anthropic, local models)
- Built-in observability dashboard
- Package system
- LSP for editor support
cargo buildcargo testcargo run -- examples/hello.gnt
cargo run -- --mock examples/hello.gnt # Mock LLM modeContributions are welcome! Whether it's:
- Bug reports
- Feature requests
- Documentation improvements
- Code contributions
Please see CONTRIBUTING.md for guidelines.
MIT License. See LICENSE for details.
GENT draws inspiration from:
- Gleam — Friendly, type-safe language design
- Pkl — Configuration as code
- Dhall — Principled language design
- Jason — Agent-oriented programming research
Built with Rust, powered by pest parser.