| Crates.io | gent-lang |
| lib.rs | gent-lang |
| version | 0.3.2 |
| created_at | 2025-12-27 12:13:27.683693+00 |
| updated_at | 2025-12-27 14:59:13.031218+00 |
| description | A programming language for AI agents |
| homepage | https://github.com/gent-lang/gent |
| repository | https://github.com/gent-lang/gent |
| max_upload_size | |
| id | 2007119 |
| size | 1,431,944 |
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 |
| Error handling | Try/except scattered everywhere | try { } catch { } with agent context |
| Learning curve | Days to weeks | Hours |
# 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"
maxSteps: 10
}
let insight = DataAnalyst.userPrompt("Analyze this: [1,2,3,4,5]").run()
Type-safe tool definitions that agents can use:
tool calculate(expression: string) -> number {
// Tool implementation
return eval(expression)
}
tool fetchWeather(city: string) -> string {
return http_get("https://api.weather.com/{city}")
}
agent Assistant {
systemPrompt: "You help with calculations and weather."
use calculate, fetchWeather
model: "gpt-4o-mini"
}
Run 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 results
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
}
let result = Analyzer.userPrompt("I love this product!").run()
// result.sentiment, result.confidence, result.keywords are typed
Compose agents naturally with variables:
agent Summarizer {
systemPrompt: "Summarize in 2 sentences."
model: "gpt-4o-mini"
}
agent Translator {
systemPrompt: "Translate to French."
model: "gpt-4o-mini"
}
let summary = Summarizer.userPrompt(longDocument).run()
let french = Translator.userPrompt(summary).run()
Graceful error handling with context:
try {
let result = RiskyAgent.run()
println("Success: {result}")
} catch error {
println("Failed: {error}")
}
cargo install gent-lang
Or with Homebrew:
brew tap gent-lang/tap && brew install gent
hello.gnt:agent Greeter {
systemPrompt: "You are friendly and cheerful."
model: "gpt-4o-mini"
}
let greeting = Greeter.userPrompt("Say hello!").run()
println(greeting)
export OPENAI_API_KEY="your-key-here"
gent hello.gnt
| Example | Description |
|---|---|
| hello.gnt | Minimal agent example |
| chaining.gnt | Chain multiple agents |
| parallel_agents.gnt | Run agents concurrently |
| structured_output.gnt | Typed agent responses |
| user_tools.gnt | Define custom tools |
| try_catch.gnt | Error handling |
Run any example:
gent examples/hello.gnt
Run with mock LLM (for testing):
gent --mock examples/hello.gnt
agent Name {
systemPrompt: "Instructions for the agent"
model: "gpt-4o-mini" // Required: LLM model
maxSteps: 5 // Optional: max tool calls
output: StructName // Optional: structured output type
outputRetries: 3 // Optional: retry on parse failure
use tool1, tool2 // Optional: available tools
}
tool name(param: type, ...) -> returnType {
// Implementation
return value
}
Types: string, number, boolean, array, object, any
parallel name {
agents: [Agent1.userPrompt("..."), Agent2.userPrompt("...")]
timeout: 30s // Required: 30s, 2m, 500ms
}
let results = name.run() // Array of results
struct Name {
field1: string
field2: number
field3: string[]
}
// Conditionals
if condition {
// ...
}
// Loops
for item in items {
// ...
}
while condition {
// ...
}
// Error handling
try {
// ...
} catch error {
// ...
}
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:
cargo build
cargo test
cargo run -- examples/hello.gnt
cargo run -- --mock examples/hello.gnt # Mock LLM mode
Contributions are welcome! Whether it's:
Please see CONTRIBUTING.md for guidelines.
MIT License. See LICENSE for details.
GENT draws inspiration from:
Built with Rust, powered by pest parser.